Narrow Range Day NR7 Indicator for ThinkorSwim

BenTen

Administrative
Staff member
Staff
VIP
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.

yGVMdQp.png


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

https://tos.mx/6So0Xv
 

BenTen

Administrative
Staff member
Staff
VIP
@Sammy800 I found this:

Code:
# NR7 Paintbar
# By Prospectus @ https://readtheprospectus.wordpress.com
#
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 NR7–narrowest in the last 7 bars (including itself):
#
def isnr7 = (range <= range[1] and range <= range[2] and range <= range[3] and range <= range[4] and range <= range[5] and range <= range[6]);
#
# Define the plot:
# (Will paint if NR7, no paint if not)
#
plot nr7 = if isnr7 then plotter else na;
#
# Formatting:
#
nr7.SetDefaultColor(Color.yellow);
nr7.setstyle(curve.points);
nr7.setlineWeight(3);
 

Similar threads

Top