小幫手 您好:
兩個問題想請教您,謝謝您。
Q1.下面為部位達到停損停利後,策略即停止的程式,不知道寫法是否正確?
(主要是為了避免出場後,在同一根K棒又達到進場條件,而再次進場)
-------------------------------------
var: intrabarpersist record(0);
if Position = 1 and Filled = 1 then begin
if profit_point > 0 and Close >= FilledAvgPrice + profit_point and record = 0
then begin SetPosition(0); { 停利 }
record = 1;
end else if loss_point > 0 and Close <= FilledAvgPrice - loss_point and record = 0
then begin SetPosition(0); { 停損 }
record = 1;
end else if condition1 and record = 0
then begin SetPosition(0); { 條件一成立後平倉 }
record = 1;
end;
end;
if position = 0 and filled = 0 and record = 1 then raiseruntimeerror("出場");
Q2:這樣的策略,在達到出場之後,新一輪部位(position=0-->1)策略會如何再次啟動? 是隔天自動啟動,還是必須要人工去啟動?
5 評論