VARIABLE:isp:=0;//定义一个全局变量用来记录平仓1是否触发了
开仓条件:TODAYBAR=1;
平仓1:all(c>o,5);
平仓2:c>ma(c,5);
if holding=0 and 开仓条件 then
begin
buy(1,2,market);
isp:=0;//开仓后始终重置全局变量为0
end
if 平仓1 and holding>0 and isp=0 then
begin
平1:sell(1,50%,market);
isp:=1;
end
//平仓2需要平仓1触发过,且不在同一个K触发
if 平仓2 and holding>0 and isp=1 and not(平仓1) then
begin
平2:sell(1,0,market);
isp:=0;//重置全局变量为0
end