casper0425 發表於 11-7-26 17:18

新手請問停損一次就不在進場,應該如何用程式表達

請問停損一次就不在進場,應該如何用程式表達,比如二均策略,我該加些什麼
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;

samuelho 發表於 11-7-26 17:59

TS 區應該很多,請多爬文.....有次數的.也有虧多少錢的....

titl 發表於 11-7-26 18:09

本帖最後由 titl 於 11-7-26 06:10 PM 編輯

一個簡單的方法,加一個參數去分辦!設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;
頁: [1]
查看完整版本: 新手請問停損一次就不在進場,應該如何用程式表達