以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  [原创]  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=98573)

--  作者:苦麻菜真好吃
--  发布时间:2016/6/15 14:35:43
--  [原创]
麻烦老师帮我写个代码,当持有多仓时,1、设置初始止损20个点,
                                                 2、当盈利20个点时,加仓一手,同时把止损移动到第一次开仓位置。
                                                  3、加仓的基础上盈利20个点,再次加仓1手,同时把止损移动到第一次加仓位置;
                                                  4、以此类推,每盈利20个点加仓一次、同时移动止损。。最大加仓次数不超过5次。。。




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


--  作者:jinzhe
--  发布时间:2016/6/15 14:45:14
--  
开仓价位和加仓价位是指定的还是市价?
--  作者:苦麻菜真好吃
--  发布时间:2016/6/15 14:55:44
--  
开仓是指定价、加仓是市价
--  作者:jinzhe
--  发布时间:2016/6/15 15:09:38
--  

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


--  作者:jinzhe
--  发布时间:2016/6/15 15:09:55
--  

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

[此贴子已经被作者于2016-6-15 15:10:02编辑过]

--  作者:苦麻菜真好吃
--  发布时间:2016/6/15 15:17:02
--  
谢谢老师!