假如CLOSE上穿MA(C,100);开仓,当MA5下穿MA10平仓;图表限制500根K线。
这时候,我希望当CLOSE第一次穿越MA100的时候开仓,平仓过后,当CLOSE再次穿越MA100的时候就不再开仓了。这个代码怎么写 啊
variable:n=0;
if cross(.....) and n=0 then begin
buy........;
n:=n+1;
end
if 平仓条件 and holding>0 then begin
sell......;
n:=0;
end
用全局变量来记录上穿次数并且在第一次的时候开仓并且在平仓时重置变量