請問小編,我依照以下設定了移動停利腳本,但回測都沒觸發,可否幫忙看是否有錯誤的地方 謝謝
input: profit_percent(40, "停利(%)");
input: profit_drawback_percent(15, "停利回跌(%)");
input: loss_percent(50, "停損(%)");
if Position = 1 and Filled = 1 then begin
var: intrabarpersist max_profit_percent(0); { 啟動停利後最大獲利點 }
if loss_percent > 0 and Close <= FilledAvgPrice*(1-0.01*loss_percent) then begin
{ 停損 }
SetPosition(0);
max_profit_percent = 0;
end else begin
{ 判斷是否要啟動停利 }
if max_profit_percent = 0 and Close >= FilledAvgPrice*(1+0.01*loss_percent) then begin
max_profit_percent = Close;
end;
if max_profit_percent <> 0 then begin
if Close <= max_profit_percent*(1-0.01*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 評論