請問一下,我試寫了MTM 10金叉的自動交易
{
多單停損(點)
}
input: loss_point(10, "停損(點)");
Input: Length(10, "期數");
var: long_condition(false); { 進場買進作多 }
{
範例:
// 多方進場策略:MTM黃金交叉0軸;出場策略:MTM死亡交叉0軸
}
long_condition = Momentum(Close, Length) Crosses Above 0;
if Position = 0 and long_condition then begin
SetPosition(1); { 以市價買進 }
Print("買進");
end;
if Position = 1 and Filled = 1 then begin
{ 依照成本價格設定停損/停利 }
if loss_point > 0 and Close <= FilledAvgPrice - loss_point then begin
{ 停損 }
SetPosition(0);
Print("停損");
end else if Momentum(Close, Length) Crosses below 0 then begin
{ 停利 }
SetPosition(0);
Print("停利");
end;
end;
希望金叉0時買,但最大虧了20點時先出場,然後停利設死叉才停利,把虧20的條件擺在前面,讓他優先執行。
但回測時,還是會有看到單筆超過20點的虧損,請問是我程式的問題嗎
另我有印log,也在啟動時勾選 print ,請問log可以在哪裡看到?謝謝
圖中的這筆是不合理的虧損
2 評論