Sunday, May 18, 2008

ThinkScript : NR7 (Narrow Range of 7) & IB (Inside Bar) code

In one of the comments the other day, I was asked about how I have NR7 and IB indicators on my ThinkOrSwim charts. I actually just took the time to code them a few months back. It's not the most efficient code, and I haven't figured out a better way to display them, but here they are:

NR7

def range = AbsValue(high - low);

def diff = (range < range[1] and range < range[2] and range < range[3] and range < range[4] and range < range[5] and range < range[6]);

plot disp = high + (1/5);

disp.setDefaultColor(Color.White);

disp.assignValueColor(if diff > 0 then Color.White else Color.BLACK);

IB

def insidebar = (high < high[1] and high[1] < high[2] and low > low[1] and low[1] > low[2]);

plot disp = high + (3/8);

disp.setDefaultColor(Color.BLACK);

disp.assignValueColor(if insidebar > 0 then Color.MAGENTA else Color.BLACK);

In order to add these to your list of studies, you must get to edit studies and create a new study. Then copy & paste the code of your choice in.

I have set these up to display white (NR7) and magenta (IB) dots over the bars that meet the criteria of the indicators. When adding the study to a chart, I would change the settings to display a dotted type of style as opposed to a line type of style.

Two other sources for ThinkScript code:

4 comments:

Hey, thanks for that. I'm new to Think or Swim, and I'll be diving into thinkscript more and more. i can't believe how little info there is out there!

I figured out how to plot only the NR7 signals without resorting to color trickery using the 'double.nan' constant:

def range = AbsValue(high - low);

def nr7 = (range <= range[1] and range <= range[2] and range <= range[3] and range <= range[4] and range <= range[5] and range <= range[6]);

plot plotnr7 = if nr7==1 then high + range * 0.3 else double.nan;

plotnr7.SetDefaultColor(Color.White);
plotnr7.setstyle(curve.points);
plotnr7.setlineWeight(3);

Thanks prospectus. I'll definitely check it out.

Trader MD would you be able to write a little script for a fellow trader?

Post a Comment

Newer Post Older Post Home