欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 混合持仓如何编写

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有2464人关注过本帖平板打印复制链接

主题:混合持仓如何编写

帅哥哟,离线,有人找我吗?
qwer123
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小飞侠 帖子:1966 积分:0 威望:0 精华:1 注册:2013/6/15 21:56:35
  发帖心情 Post By:2015/4/22 10:10:55    Post IP:60.164.27.35[只看该作者]

//股指期货自动交易程序(净单交易)
//编制:
//日期:

r1:=barslast(date<>ref(date,1));
//********************************
rr1:=stkindiex('if00','qq25.持仓',0,22,80,0);
rr2:=stkindiex('if00','qq25.持仓',0,22,85,0);
rr3:=stkindiex('if00','qq25.持仓',0,22,90,0);


r12:=rr1+rr2+rr3,noaxis;

//***************第一遍***************
if holding=0 and r12>0 then buy(1,r12,limitr,c);
if holding=0 and r12<0 then buyshort(1,abs(r12),limitr,c);

if holding>0 and r12>0 and holding>r12 then sell(1,holding-r12,limitr,c);
if holding>0 and r12>0 and holding<r12 then buy(1,r12-holding,limitr,c);
if holding>0 and r12<0 then
begin
sell(1,holding,limitr,c);
buyshort(1,abs(r12),limitr,c);
end

if holding<0 and r12<0 and holding>r12 then buyshort(1,holding-r12,limitr,c);
if holding<0 and r12<0 and holding<r12 then sellshort(1,r12-holding,limitr,c);
if holding<0 and r12>0 then
begin
sellshort(1,holding,limitr,c);
buy(1,r12,limitr,c);
end 

if (r12=0 or time>=151500) and holding>0 then sell(holding>0,holding,limitr,c);
if (r12=0 or time>=151500) and holding<0 then sellshort(holding<0,abs(holding),limitr,c);
//********************************
盈亏:asset-1000000,colorred,linethick1,noaxis;
日盈亏:asset-ref(asset,todaybar),noaxis,colorred,linethick0;
持仓:holding,linethick0;


注意,如果是1根k线开几次仓,“第一遍”之后的语句就要运行几遍
你还有一个错误理解,这个方法并不能节省交易费的,自己好好琢磨一下。

 回到顶部