各位大神好,
我有個階段式停損停利的想法,我把進場張數改成2張,其餘進場條件不變
階段式停利為以下
但不知哪裡出了問題,回測時完全沒有數據,可以幫我看看原因嗎? 謝謝
if position = 0 and condition1 and condition2 and condition3 and condition4 and condition5 then
begin
EntryPrice1 = Close;
EntryBar = CurrentBar;
setposition(2, market, label:="進場"); // 進場2張
end;
// 出場邏輯
if position > 0 then
begin
// 停損
if Close <= EntryPrice1 * (1 - StopLoss / 100) then
begin
setposition(0, market, label:="停損");
return;
end;
// 階段式停利
if Close >= EntryPrice1 * (1 + TakeProfit1 / 100) then // 第一階段停利5%
begin
setposition(1, market, label:="第一階段停利"); // 出場1張
return;
end;
if Close >= EntryPrice1 * (1 + TakeProfit2 / 100) then // 第二階段停利7.5%
begin
setposition(0, market, label:="第二階段停利"); // 出場1張
return;
end;
// 持有時間到
if CurrentBar >= EntryBar + HoldDays then
begin
setposition(0, market, label:="持有時間到");
return;
end;
end;
4 評論