XS 回測時,停損的點異常

  •   91 
  • 最後發表   Garlic774  2023 一月 05
Garlic774 發文於   2023/01/03

您好,以下是我的語法,多單停損的點位有幾筆遠遠超過設定值(設定低於下單價格30點時,出場),請問可以幫我找出問題嗎? 謝謝您。附件有回測紀錄

 

 

 

 

// 宣告參數

if barFreq="min" then begin 

value1=average(c,960/barInterval);

end;

var: stop_point(0), controller(0);

var: intrabarpersist max_profit_point(0); { 啟動停利後最大獲利點 }

input: profit_point(30, "停利(點)");

input: profit_drawback_point(5, "停利回跌(點)");

input: loss_point(30, "停損(點)");

 

 

// 多方進場策略

if position = 0 and filled = 0 and close cross over value1-110 then setposition(1);

 

 

//停損單

if position > 0 and filled > 0 then begin

    if loss_point > 0 and Close <= FilledAvgPrice - loss_point then begin

{ 停損 }

SetPosition(0);

max_profit_point = 0;

    end else begin

//停利單

 

if max_profit_point = 0 and Close >= FilledAvgPrice + profit_point then begin

max_profit_point = Close;

end;

 

if max_profit_point <> 0 then begin

if Close <= max_profit_point - profit_drawback_point then begin

{ 停利 }

SetPosition(0);

max_profit_point = 0;

end else if Close > max_profit_point then begin

{ 移動最大獲利點 }

max_profit_point = Close;

end;

end;

end;

 

end;

附加文件

XQ小幫手 發文於   2023/01/05

Hello Garlic774,

 

這是因為當條件符合停損出場時,已經價格已經超過了停損價格,所以才會有這種狀況。

舉例來說:

2022/02/12 03:41 這筆在18201進場,出場的條件就會是close <= 18171。

而這個條件會在 03:51 的 low 達成,故會在這個價格出場。(在那以前的價格都達於 18171)

2022/08/07 08:45 這筆在開盤時 17800進場,而接下來在同根Bar的low就達成條件,故成交在 low 上 (17752)。

 

建議您可以在腳本中加上print將相關資訊印出或是拿回測的交易資訊和線圖比對,會比較容易理解。

發表回覆
Close