想請教小編
想要在吞噬K收K後進場
然後在吞噬K跟前一根K棒的最高點(做空)或最低點(做多)作停損
回測的時候,進場後卻無法正確觸發停損
請問要怎麼修正腳本


var:
long_condition(false), //做多進場
in_low(0), //進場低點
short_condition(false), //做空進場
in_high(0); //進場高點
//多頭吞噬進場
long_condition = close[2] <= open[2] and close[1] > open[1] and close[1] > high[2];
//空頭吞噬進場
short_condition = close[2] >= open[2] and close[1] < open[1] and close[1] < low[2];
//多頭進場
if Position = 0 and long_condition then begin
SetPosition(1, MARKET); { 以市價買進 }
in_low = lowest(low,3);
end;
//多頭出場
if Position = 1 and close < in_low then begin
SetPosition(0, MARKET); { 以市價賣出 }
end;
//空頭進場
if Position = 0 and short_condition then begin
SetPosition(-1, MARKET); { 以市價買進 }
in_high = highest(high,3);
end;
//空頭出場
if Position = -1 and close > in_high then begin
SetPosition(0, MARKET); { 以市價賣出 }
end;
5 評論