buy11 :=;
sel11 :=;
buy22 :=;
sel22 :=;
//交易系统
平空:if holding<0 and trendr=1 then sellshort(1,holding,marketr);
开多1:if holding=0 and buy11 then buy(1,1,marketr);
开多:2:if holding=0 and buy22 then buy(1,1,marketr);
平多:if holding>0 and trendr=-1 then sell(1,holding,marketr);
开空1:if holding=0 and sel11 then buyshort(1,1,marketr);
开空:2:if holding=0 and sel22 then buyshort(1,1,marketr);
这样开平仓不会混乱吧?
不会,你这个相当于 开仓时候先尝试按照开多1去开,开多1如果不满足条件再开开多2,2个开仓每次最多只能开一个,且开多1优先。下面开空也是类似。逻辑上理清楚了就OK。