NR4 and NR7 Candlestick patterns

Hi looking to replicate the Narrow range patterns (NR4 and NR7) come from Tony Crabbel’s boo - Day Trading with Short Term Price Patterns.


He’s focused on two different narrow range timeframes: four days and seven days. An NR4 pattern would be the narrowest range in four days, while an NR7 would be the narrowest range in seven days. I’m currently not sure how to do this.


I started off using the var1 = CANDLESTICKPATTERN(SCANALL=False, SCANTYPE=[Bullish Harami,Bearish Harami]) - which is an inside bar I believe. How do I assess its range looking back 4 ad 7 days.






The following script will identify a bar that has the lowest range within the last 4 days:

//Find Range
V1 = HIGH() - LOW();
//Find Lowest Bar Range over last 4 days
//Is current bar the lowest range in the last 4 days
NR4 = V1 <= V2;

You can use the above script to build the 7 day version as well by adjusting the V2 line to 7 bars.