以下是用選股策略的商品做買進,
並用D1=0跟D1=1限制賣出後,不再買進,
但回測無效(如附圖)
------------------------------------------
Input:profit_percent(30, "停利(%)");
Input:loss_percent(10, "停損(%)");
var:D1(0);
if filled=0
and D1=0
Then
SetPosition(1, MARKET);
if filled>0
and Close >= FilledAvgPrice*(1+0.01*profit_percent) then begin
D1=1;
SetPosition(0, MARKET); { 停利 }
end else if loss_percent > 0 and Close <= FilledAvgPrice*(1-0.01*loss_percent) then begin
D1=1;
SetPosition(0, MARKET); { 停損 }
end;
---------------------------------------------------------------------------
請問問題出在哪?謝謝
1 評論