請問 空單 設定固定停損2% 有獲利2%時啟動移動停損1%
相關編輯如下是否有誤 經常遇到空單沒有回補的狀況
如何在底下追加 最晚收盤前要回補
以及開啟逐筆下單時間經常提早下單
追加下單時的訊息顯示停損停利價格
input: profit_percent(2, "停利(%)");
input: profit_drawback_percent(1, "停利回跌(%)");
input: loss_percent(2, "停損(%)");
if profit_percent = 0 then raiseruntimeerror("請設定停利(%)");
if profit_drawback_percent = 0 then raiseruntimeerror("請設定停利回跌(%)");
if profit_drawback_percent > profit_percent then raiseruntimeerror("停利(點)需大於停利回跌(%)");
if Position = -1 and Filled = -1 then begin
var: intrabarpersist max_profit_percent(0);{ 啟動停利後最大獲利% }
if loss_percent < 0 and Close >= FilledAvgPrice + loss_percent then begin
{ 停損 }
SetPosition(0);
max_profit_percent = 0;
end else begin
{ 判斷是否要啟動停利 }
if max_profit_percent = 0 and Close <= FilledAvgPrice - profit_percent then begin
max_profit_percent = Close;
end;
if max_profit_percent <> 0 then begin
if Close >= max_profit_percent + profit_drawback_percent then begin
{ 停利 }
SetPosition(0);
max_profit_percent = 0;
end else if Close < max_profit_percent then begin
{ 移動最大獲利點 }
max_profit_percent = Close;
end;
end;
end;
end;
1 評論