Hello xqyi,
 
您可以參考 intrabarpersist 的說明。
且您的寫法順序會導致 value31 先被更新為當次洗價的價格才判斷close是否有大於value31。
建議可以多加上條件來判斷,舉例來說:
var: intrabarpersist _price(0);
 
if value3 > 0 then begin
    //如果_price為0則記錄成交價,如果_price不為0的話則用當下的成交價與其相比,若比較高則進場,相同或低於該數值的話則歸0
    if _price = 0 and position = 0 and filled = 0 then _price = close
    else if _price <> 0 and close > _price and position = 0 and filled = 0 then setposition(1,close) 
    else if _price <> 0 then _price = 0;    
    if filled=1 and close >= filledAvgPrice *1.01 then setposition(0,close);
    end;
 
您可以將相關數值印出,即可知道策略運作的狀況。
             
                
3 評論