Narrow Range Day NR7 Indicator for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP
Warehouse
This indicator identifies stocks with the narrowest high to low range for the past 7 days (NR7). Range contraction leads to range expansion.

Similar to the NR4 and Double Inside Day strategy, you can play the breakout when the stock move above the high of the narrow range day or short it when the stock breakdown from the low of the narrow range day.



thinkScript Code

Code:
# AI_Prospectus_NRx_Paintbar_with_NRx_2
#
# NR-X Paintbar
# By Prospectus
#
# AlphaInvestor - 11/19/2016 - Added NRX-2 (a la Bulkowski) if there are two NRX bars in a row
#
# Input the number of bars to check (default 7):
#
input x=7;
#
def range = high-low;
def na=double.nan;
#
# Define how you want the value plotted.
# I chose 30% of bar range above the bar high.
# Change plotter to whatever you want to customize it.
#
def plotter=high+range*0.3;
#
# Define an NR-X: narrowest in the last X bars (including itself):
#
def isnrX = if lowest(range,x-1)==range then 1 else 0;
#
# Define the plot:
# (Will paint if NR-X, no paint if not)
#
plot nrX = if isnrX then plotter else na;
#
# Formatting:
#
nrX.SetDefaultColor(Color.white);
nrX.setstyle(curve.points);
nrX.setlineWeight(1);

def plotter2=high+range*0.6;
plot nrX2 = if isnrx and isnrx[1] then plotter2 else na;
nrX2.SetDefaultColor(Color.yellow);
nrX2.setstyle(curve.points);
nrX2.setlineWeight(3);

# End Study

Shareable Link

 

Top