想寫一個台指期日盤用的腳本
頻率5分K,9:30過後才進場,8:45-9:30的高低點作為區間,突破區間做多,移動停損設區間的1/2,如果沒碰到就在13:30將部位平倉
試跑6個月回測,結果我好像寫得完全不對XD,麻煩小幫手看看哪邊有錯
if date<>date[1] and currentTime=093001 then begin
value1=highest(h[1],9);
value2=lowest(L[1],9);
var:loss_point(0);
loss_point=0.5*(value1-value2);
end;
if c>value1 then setposition(1);
if Position = 1 and Filled = 1 then begin
var: intrabarpersist stoploss_point(0);
{ 計算停損價格 }
if stoploss_point = 0 then begin
stoploss_point = FilledAvgPrice - loss_point;
end;
{ 如果價格上漲的話, 則往上挪動停損價格. 停損價格只會越來越高 }
if Close > FilledAvgPrice then begin
if Close - loss_point > stoploss_point then begin
stoploss_point = Close - loss_point;
end;
end;
if Close <= stoploss_point then begin
{ 停損 }
SetPosition(0);
stoploss_point = 0;
end;
if currenttime=133000 then begin
SetPosition(0);
end;
end;
3 評論