打印本文打印本文 关闭窗口关闭窗口

[原创]

作者:金字塔 来源:cxh99.com 发布时间:2016年08月19日
  • 咨询内容: 麻烦老师帮我写个代码,当持有多仓时,1、设置初始止损20个点,                                                 2、当盈利20个点时,加仓一手,同时把止损移动到第一次开仓位置。                                                  3、加仓的基础上盈利20个点,再次加仓1手,同时把止损移动到第一次加仓位置;                                                  4、以此类推,每盈利20个点加仓一次、同时移动止损。。最大加仓次数不超过5次。。。



    空仓我就自己写了,麻烦老师示范一下

     

  • 金字塔客服: 开仓价位和加仓价位是指定的还是市价?

     

  • 用户回复: 开仓是指定价、加仓是市价

     

  • 网友回复:

    variable:N=0;
    variable:zs=0;
    if holding=0 and 开仓条件 then BEGIN 
        buy(1,1,limitr,指定的价格);
       
    end
    if holding>0 and c>enterprice+20 and n<5 then begin
        zs:=enterprice;
        buy(1,1,marketr);
        n:=n+1;
    end

    if holding>0 and n=0 and c<enterprice-20  then begin
         sell(1,0,marketr);
    end
    if holding>0 and n>0 and c<zs-20 then begin
         sell(1,0,marketr);
         n:=0;
    end

     

  • 网友回复:

    这里有“平仓后加仓次数重置为0”的设定

    [此贴子已经被作者于2016-6-15 15:10:02编辑过]
打印本文打印本文 关闭窗口关闭窗口