Size:  
    
        Color:  
    
    
 
    
        
     
    
        
    
 
    
    
    
        Eugene, hello!
 In your code, entering a position in the cycle at step bar (eg, bar = 100) is carried out at the bar+1=101 and the values of p.LowestLowAsOfBar or p.HighestHighAsOfBar are determined only from the bar=101. Then on the next iteration of the loop bar = 101 in the determination of the stop values p.LowestLowAsOfBar(bar-1)=p.LowestLowAsOfBar(100) or p.HighestHighAsOfBar(bar-1)=p.HighestHighAsOfBar(100) are not defined (p.LowestLowAsOfBar(bar-1)=1.79E+308 and p.HighestHighAsOfBar(bar-1)=-1.79E+308) and the values ??of the stop on the chart does not appear. They only appear on the next bar. I think when we are determining the stop (stop = p.LowestLowAsOfBar( bar-1 ) + atr[bar] * DistShort; or stop = p.HighestHighAsOfBar( bar-1 ) - atr[bar] * DistLong;)  bar-1 must be replaced by a bar. Then all will be well. 
Regards, Yury
    
    
        
    
    
        
    
    
        Size:  
    
        Color:  
    
    
 
    
        
     
    
        
    
 
    
    
    
        Hi Yury,
I think what you're proposing makes sense. Thanks.
    
    
        
    
    
        
    
    
        Size:  
    
        Color:  
    
    
 
    
        
     
    
        
    
 
    
    
    
        Strategy has been updated.
    
    
        
    
    
        
    
    
        Size:  
    
        Color: