請教~ 回測後停在第1次停利,後面2、3次停利腳本沒進續進行,請教原因,謝謝!!
if Position = 0 and short_condition then begin setposition(-10); { 進場做空 }
end;
if Position = -10 and Filled = -10 then begin
{ 空10張 }
{ 範本移動停損腳本}
var: intrabarpersist stoploss_point(0);
if stoploss_point = 0 then begin
stoploss_point = FilledAvgPrice*(1+0.01*loss_percent);
end;
if Close < FilledAvgPrice then begin
if Close *(1+0.01*loss_percent) < stoploss_point then begin
stoploss_point = Close *(1+0.01*loss_percent);
end;
end;
if Close >= stoploss_point or short_condition2 then begin
SetPosition(0);
stoploss_point = 0;
end
else begin
//--------------------------------------------------------------------------------------------------------------
{ 自編移動固定停利腳本}
var: plratio(0);
if position <> 0 and filled <> 0 then begin
if plratio = 0 and Close <= FilledAvgPrice*(1-0.01*profit_percent) then begin //-1.2%
plratio = 1 ;
SetPosition(-6);
end else
if plratio = 1 and profit_percent > 0 and Close <= FilledAvgPrice*(0.99-0.01*profit_percent) then begin //-2.2%
SetPosition(-2);
plratio = 2 ;
end else
if plratio = 2 and profit_percent > 0 and Close <= FilledAvgPrice*(0.98-0.01*profit_percent) then begin //3.2%
SetPosition(0) ;
plratio = 0 ;
end;
end;
end;
end;
3 評論