俺是后台交易a条件开仓,b条件平仓,a再开仓,b不平仓
就是只平一次仓的意思,不知道什么函数能够实现?
再加个变量控制罢。
60.28.160.67/金字塔各类问题解答大全20100928.htm#_Toc282767033
看看这里全局变量的用法
平仓一次后就吧你设置的全局变量a设置为1
以后检测a的时候 发现是1则不下单即可
variable:a=0; //初始化s=0
if (cmc2 or cmc4) then begin
a:=1;
end;
if (ccm2 or ccm4) then begin
a:=1;
end;
新手根据例子写的。但图表上没有执行哎!
//论坛里的例子,贴出来供参考
//亏损3次则不再开仓
variable:lossnum=0;// 全局变量,平仓时判断一下是盈利/亏损,若亏损lossnum就加1
if cond1 and holding>0 then
begin
sell(1,1,thisclose);
if c<enterprice then lossnum:=lossnum+1;
end
if cond2 and holding=0 and lossnum<3 then buy(1,1,thisclose);
if time=150000 then lossnum:=0;// 商品期货,收盘的同时,lossnum赋值为0
//收盘lossnum不赋值为0,后面就不再开仓了
if buycond and not(texitbars(0)>0) then begin
buy(1,1,limitr,close);
end