我print出來確定我的停損條件_condition10是2

表示有執行條件

可是為什麼我的setposition不會變成0?我改用position+1也是一樣

我用停利去試setposition也是不會變動

請問小幫手原因出在哪邊 我用各種方法print都沒看到原因

回測條件以及語法如下

input: profit_percent(9, "停利(%)");
{input: loss_percent(9, "停損(%)");}

input:
  Length(20,"MA的天數"),
  UpperBand(2,"上通道標準差倍數"),
  LowerBand(2,"下通道標準差倍數"),
  day(5,"前幾根k棒平均量");
 variable: 
  _condition1(0);  

variable: 
  mid(0),up(0),down(0),C5(0);  

up=bollingerband(GetField("收盤價", "D"),Length,UpperBand);
mid=average(GetField("收盤價", "D"),Length);
down=bollingerband(GetField("收盤價", "D"),Length,-1*LowerBand);
C5=average(volume,day);

setbackbar(400);

///變數定義
variable:barcount(0),_condition2(0),stoploss(0),highest1(0),lowest1(99999),_condition9(0),_condition10(0);

///barcount 定義///

if date <> date[1] and position=0 then ///參數定義
begin
    barcount=1;
    _condition1=0;
    _condition2=0;
    stoploss=0;
    highest1=0;
    lowest1=99999;
    _condition9=0;
    _condition10=0;
end
else
    barcount+=1;

if high>highest1 then highest1=high; 
if filled < 0 and l<lowest1 then lowest1=l; 

if GetSymbolInfo("買賣現沖")=true and GetSymbolInfo("處置股")=false then 
begin 
_condition2=1;
end;

if barcount=1 then stoploss=(c+h)/2;

input: openhigh(1.02, "開盤衝高(%)");
input: kill(3, "下殺(%)");
input: highpercent(1.2, "一段時間內衝高幾(%)");
input: period(864, "多長時間內衝高幾趴");

value1 = fastLowest(c,period)*highpercent;

if barcount<5 and barcount>1and GetField("收盤價", "D")[1]>value1 and h>O[1]*1.02 and ((highest1-c)/highest1)*100>kill and GetField("最高價", "D")>up and o>GetField("收盤價", "D")[1]*1.02
then begin
  _condition1=1;
end;

if  _condition1=1 and _condition2=1 
then begin
setposition(-2);
end;





///停利
if filled[1] < 0 and profit_percent > 0 and Close[1] <= FilledAvgPrice * (1 - 0.01 * profit_percent) 
then begin
        setposition(0);
        _condition9=3;

end;


///停損
if filled[1] < 0 and c[1] >lowest1*1.025
then begin 
        setposition(0);
        _condition10=2;

end;

Print(file("C:\print\"),date,filled, c, lowest1*1.025, Position,_condition9,_condition10); // 確認變數值