Scan for pullbacks from new highs

Hi,

I am trying to build a script to use as a scan. Unfortunately, I am stuck.

I want to find stocks that:

  1. made a 252 day closing high in the last 10 days
  2. has closed below that new high by more than 25% but less than 38.2%.

Here is what I have. I know that my Variable 1 does return stocks that closed at a 252 day high in the last 10 days. I cannot figure out how to find stocks that have now closed 25% to 38.2% below that high returned in Variable 1.

thank you,
Louis.

//Calculate new 252 day closing high in the last 10 bars. 
V1 = CLOSE() >= HIGHESTHIGH(Close(), BARS=252, EQUAL=True, INCBAR=True) and TIMESINCESIGNAL(V1) <= 10; 

//Define 25% below V1 and 38.2% below V1. 
V2 = (V1 * -0.25); 
V3 = -(V1 * -0.382); 

//Show when conditions are true. 
Close() <= V2 and >= V3;

Hi,

Here is how i would script the criteria you listed:

//Find new 252 Day Highs
V1 = High() CrossesAbove HIGHESTHIGH(BARS=252) ;
//Find New Highs within the last 10 days
V2 = TIMESINCESIGNAL(V1) <= 10; 
//Find High Value at last trigger 
V3 = PRICEATSIGNAL(V1, PRICE=High); 
//Find Pullback Range 
V4 = V3 * 0.75; 
V5 = V3 * 0.618; 
//Results 
CLOSE() >= V5 and CLOSE() <= V4 and V2 == 1

Here is how it looks on a chart:

Ex1

Black Line = Highest High (252 days) and Pink Arrows = Criteria Pass