sell(holding>0,0,enterprice-30*mindiff);
改成
sell(holding>0,0,limitr,enterprice-30*mindiff);
if L<enterprice-30*mindiff then sell(holding>0,0,limitr,min(o,enterprice-30*mindiff));//30跳止损
if holding>0 and 平多 then sell(1,1,thisclose);
if holding=0 and 开多 then buy(1,1,thisclose);
if H>enterprice+30*mindiff then sellshort(holding<0,0,limitr,max(o,enterprice+30*mindiff));//止损
if holding<0 and 平空 then sellshort(1,1,thisclose);
if holding=0 and 开空 then buyshort(1,1,thisclose);
sell(holding>0,0,enterprice-30*mindiff);
改成
sell(holding>0,0,limitr,enterprice-30*mindiff);
if L<enterprice-30*mindiff then sell(holding>0,0,limitr,min(o,enterprice-30*mindiff));//30跳止损
if holding>0 and 平多 then sell(1,1,thisclose);
if holding=0 and 开多 then buy(1,1,thisclose);
if H>enterprice+30*mindiff then sellshort(holding<0,0,limitr,max(o,enterprice+30*mindiff));//止损
if holding<0 and 平空 then sellshort(1,1,thisclose);
if holding=0 and 开空 then buyshort(1,1,thisclose);
你的顺序是错误的
开空的位置是在close ,此时K线已经走完。接下来再用low来判断是否止损,就错了,具有隐性未来函数。
所以,要等到下一根才判断止损,放到开仓语句的前面也是这个作用
另外,如果单单这样写
sell(holding>0,0,limitr,enterprice-30*mindiff);
也有点问题。如果触发止损的K线跳空低开触发止损后一路下行,此时以enterprice-30*mindiff下单是无法成交的。所以需要和K线的open做个比较
你的顺序是错误的
开空的位置是在close ,此时K线已经走完。接下来再用low来判断是否止损,就错了,具有隐性未来函数。
所以,要等到下一根才判断止损,放到开仓语句的前面也是这个作用