Hello Eugene,
Can you confirm if this is the right way to implement a strategy that buys at the open when price has fallen x% from the Highest highs made in the last 90 days?	
CODE:
Please log in to see this code.
OR should I be calling BuyAtOpen instead of BuyAtMarket?
    
 
    
        
    
    
        
    
    
        Size:  
    
        Color:  
    
    
 
    
        
     
    
        
    
 
    
    
    
        BuyAtMarket is the right signal to buy at the open.   Here's the "Cadillac" version with an arbitrary 5-day exit.  It includes a slider to adjust the percent and plotting the trigger level. 
CODE:
Please log in to see this code.
Your calculation and equation was correct too, but the condition does not make sure that the price is falling from above -x to below it, like the CrossUnder signal does.  In other words, if price was already below the 90-day high at the beginning of the chart, you'd buy it immediately, then sell it, and buy it, and sell it, etc. without ever crossing that threshold. 
    
 
    
        
    
    
        
    
    
        Size:  
    
        Color:  
    
    
 
    
        
     
    
        
    
 
    
    
    
        Many Thanks, Cone. Your version is much better:-) 
I'm considering long positions only. Basically, I'd like to modify this to buying 2 positions for each dip below the highest high (one for example at -2% dip and another at -4% dip). If it makes new  high above highest high, the position counter should get reset to 0, and add to the position if there is another  -2% and/or a -4% dip below the new highest high. I just want to keep scaling up like this until price closes below  -6% from the highest high, when all positions are exited.  Please guide me as to how can I code the logic.
    
    
        
    
    
        
    
    
        Size:  
    
        Color:  
    
    
 
    
        
     
    
        
    
 
    
    
    
    
        
    
    
        
    
    
        Size:  
    
        Color:  
    
    
 
    
        
     
    
        
    
 
    
    
    
        Thanks, Eugene. Example sort of helped, but I'm not quite sure about how can to track active positions with reference to a particular highest high. Note there will be only a max of 2 per highest high (one for dip below -2% and other for -4% dip). Unlike the example strategy, the strategy i'm trying to create  does not have a predefined max # of open positions. it would be some percent of account size.
Trying to figure out if i should be using hashtable or custom dataseries to track active positions per a particular highest high. Please advise
    
    
        
    
    
        
    
    
        Size:  
    
        Color:  
    
    
 
    
        
     
    
        
    
 
    
    
    
        Give this a shot.  You can still use the single slider to control the first level.  The second level is 2x the first level, and the exit is 3x.  I think this matches your spec.  (fwiw, you'll probably have better luck with this strategy entering after larger "drops")
CODE:
Please log in to see this code.
     
    
        
    
    
        
    
    
        Size:  
    
        Color:  
    
    
 
    
        
     
    
        
    
 
    
    
    
        You're a genius.:-) This should do it. Will let you know if i have anymore questions.
Thanks
    
    
        
    
    
        
    
    
        Size:  
    
        Color: