Creating Pullback scan criteria

Hi Guys

I’m trying to create a scan identifying a year high, which I know how to do, but which then subsequently identifies the 20 day low occurring after the Year High, but which must occur within the following 50 days after the Year High occurs. I know identifying the 20 day low would be a similar scripting method as identifying the year high, but it is time since or offset period where I am getting confused, could someone help please. I want to make sure the 20 day low occurs after the Year High but within a 50 day period, which will eliminate prolonged congestion periods.

 

Hi Tonia,

You can use the TIMESINCESIGNAL() function (see examples here and here).

It’s always good practice to break things down in to the separate components as a Show Bar - so you can verify that the script formulas are doing what you want them to do. In this example the green Show Bars are the new 52 week high closes (Y1), and the red ones are the new 20 day lows(L20). The green shaded areas are when the lows occur within 50 bars of the new highs, created using a Show View tool with the following formula (and true/false in the watchlist column).

//Is it a new 52 week high?
Y1 = CLOSE()>HIGHESTHIGH(CLOSE(), BACKTYPE=Weeks, BARS=52);
//Is it a new 20 day low?
L20 = CLOSE()<LOWESTLOW(CLOSE(), BACKTYPE=Bars, BARS=20);
//is the low within 50 days of the high?
L20 and TIMESINCESIGNAL(Y1)<50

Capture

Thank you Darren, I really appreciate your help