OO:VALUEWHEN(DATE<>REF(DATE,1),O);//表示今日第一根K线的开盘价
if C=OO+2 and (TIME>=090000 and TIME<145500) and holding=0 then buy(1,1,marketr);//开多
if C=OO-1 and (TIME>=090000 and TIME<145500) and holding=0 then buyshort(1,1,marketr);//开空
if C=enterprice-8 or C=enterprice+4 then sell(holding>0,holding,marketr) ;//多头止盈止损
if C=enterprice+8 or C=enterprice-4 then sellshort(holding<0,holding,marketr);//空头止盈止损
if (TIME>=145900 and TIME<200000) or (TIME>=225500) then begin //收盘前全平
sell(holding>0,holding,marketr);
sellshort(holding<0,holding,marketr);
end
测试

此主题相关图片如下:1.png

止损止盈用不了,没有止损止盈是那里代码错误了
起作用了,止盈止损和收盘平仓动作一样是平仓,所以直接从字面上看一样是平仓。
除了收盘前的平仓其他都是止盈止损的平仓