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: