請問停損一次就不在進場,應該如何用程式表達,比如二均策略,我該加些什麼
If time >= 0845 and time <= 1300
and marketposition = 0 then begin
If value1 cross over value2 then buy next bar at open;
If value1 cross under value2 then sellshort next bar at open;
End;
if marketposition <> 0 then begin
setstoploss(200*loss);
end;
If Time > 1300 then begin
sell next bar at open;
buytocover next bar at open;
End;
一個簡單的方法,加一個參數去分辦!設a=false是停損過,要計算次數,就改為計數也可以,停損一次可以如下寫法:
========================================
If time >= 0845 and time <= 1300 and marketposition = 0 and a then begin
If value1 cross over value2 then buy next bar at open;
If value1 cross under value2 then sellshort next bar at open;
End;
if marketposition <> 0 then begin
setstoploss(200*loss);
a=false;
end;
If Time > 1300 then begin
sell next bar at open;
buytocover next bar at open;
a=true;
End;