求解:限制賣出後不再買進,但回測無效

  •   198 
  • 最後發表   KK333  2025 一月 16
KK333 發文於   2025/01/15

以下是用選股策略的商品做買進,
並用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;   


---------------------------------------------------------------------------
請問問題出在哪?謝謝

附加文件

虎科大許教授 發文於   2025/01/16

宣告D1時,加intrabarpersist。

Input:profit_percent(30, "停利(%)");  
Input:loss_percent(10, "停損(%)");  
var: intraBarPersist D1(0); 
if position=0 and filled=0 and D1=0 Then SetPosition(1, MARKET);  
if position>0 and filled>0 then
    if 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;   

發表回覆
Close