Inside Day and NR4 Indicator for ThinkorSwim with Strategy

BenTen

BenTen

Administrative
Staff
VIP
An inside day occurs when the stock trades within the range of the previous day high and low. Combining with Narrow Range 4 or known as NR4 will provide a high probability of trading the breakout or breakdown of the inside day bar.

Identify Inside Day:
  • When the bar is within the high and low of its previous day.

Identify NR4:
  • Made up of 4 bars
  • Most recent candlestick will have a range that is smaller than the 3 previous bars.
Below is the indicator that applies the rules on how to identify Inside Day and NR4. This way you can easily figure out when we have an Inside Day with "narrow-range-4-bars".

So instead of just looking for inside day candlestick, we're now looking for an inside day with a range that is smaller than the 3 previous bars.

thinkScript Code

Rich (BB code):
def lowVol = (VolatilityStdDev(6) / VolatilityStdDev(100)) < 0.5;
def insideDay = high < high[1] and low > low[1];
def range = high - low;
def NR4 = range < Lowest(range[1], 3);
plot signal = lowVol and insideDay and NR4;
plot signal2 = lowVol and insideDay and NR4;
     signal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
     signal.SetDefaultColor(Color.MAGENTA);
     signal.SetLineWeight(1);
signal2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
     signal2.SetDefaultColor(Color.MAGENTA);
     signal2.SetLineWeight(1);

Inside Day + NR4 Scanner

Rich (BB code):
def lowVol = (VolatilityStdDev(6) / VolatilityStdDev(100)) < 0.5;
def insideDay = high < high[1] and low > low[1];
def range = high - low;
def NR4 = range < Lowest(range[1], 3);
def s = lowVol and insideDay and NR4;
plot signal = s within 1 bars;
Now that you have the indicator and scanner on your ThinkorSwim, here is the guide on how to trade this particular inside day candlestick that includes the NR4 rules.

Inside Day and Narrow Range 4 Strategy

After you add the indicator, it will plot arrows pointing at any inside days. Here is an example.



The above screenshot is $BABA 6m 1D timeframe with 2 inside days.

The strategy for trading this is fairly simple. You plot the high and low of the Inside Day bar. Something like this:



You can initiate a long position if the candlestick breaks above the high of the Inside Day bar or short the stock if the candlestick breaks below the low of the Inside Day bar.

  • For long, stop loss would be the low of the Inside Day bar.
  • For short, stop loss would be the high of the Inside Day bar.
That is how I would personally trade Inside Day + NR4.

A few more examples:











Good luck with trading :)

Credits:
 
Last edited:
C

Chenthy73

New member
You would use it mainly on the daily chart? Thanks

 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
@Chenthy73 Daily and Hourly would be my go to for this indicator.

 
Last edited:
S

Steve2286

New member
2019 Donor
Ben - I've never run a scan before - where does the code get pasted ?

tks

 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
@Steve2286 Go to the Scan page, add new Study filter, remove the existing one and then paste the code into the thinkScript section.

 
Last edited:
A

Antares66

New member
Hello, i tried to write an intraday scanner. The scanner works but the results are not correct.
At first i`m looking for a strong move within the last 5 days, then for an inside day.
What did i wrong?

def change=(close-close[5])/close[5]*100;
def Inside= if (high<High[1] and low >low[1]) then 1 else 0;
def bs= if change > 20 and inside>0 then 1 else 0;
plot buy= bs;
 
T

tomsk

Well-known member
VIP
@Antares66 I looked through your scan code, looks like you're looking for a 20% move in the past 5 days. This is probably overly optimistic though not impossible especially if the underlying stock had some news propelling it to highs.

If you meant a 2% move in 5 days you'll get results. As a matter of fact I just ran the code on the scanner and found 7 results on a scan of the S&P 500 (daily). Bottom line, your code looks find, just check if you really meant a 20% move.
 

Top