Rss & SiteMap

金字塔客服中心 - 专业程序化交易软件提供商 http://www.weistock.com/bbs/

专业程序化软件提供商
共2 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:后台限制日内连续亏损次数

1楼
lc1227 发表于:2016/9/22 13:53:10
请帮忙写一个代码,限制日内连续亏损次数的代码,例如限制当天连续亏损次数超过3次就停止交易(交易所时间)
2楼
jinzhe 发表于:2016/9/22 14:01:38

用全局变量来记录一下

globalvariable:cs=0,tt=0;

 

if 平多条件 and 持仓判断 then begin

   tsell();

   sleep(1000);//暂停1秒等成交

   if tnumprofit(1)>=0 then cs:=0;

   if tnumprofit(1)<0 and tt<>time then begin

         cs:=cs+1;

         tt:=time;//用记录time的方式来防止反复迭代

   end

end

 

 

if 平空条件 and 持仓判断 then begin

   tsellshort();

   sleep(1000);//暂停1秒等成交

   if tnumprofit(1)>=0 then cs:=0;

   if tnumprofit(1)<0 and tt<>time then begin

         cs:=cs+1;

         tt:=time;

   end

end

 

if time=closetime(0) then cs:=0;//收盘后重置全局变量

 

开平仓条件加入:cs<3;

共2 条记录, 每页显示 10 条, 页签: [1]


Powered By Dvbbs Version 8.3.0
Processed in 0.01563 s, 3 queries.