April 22, 2026

Toby Crabel NR4 Strategy Automation Guide

The Narrow Range theory is a way of quantifying how markets can move from a consolidation period (the range) to a trending period. Let's automate it in Profectus AI.

Toby Crabel NR4 Strategy Automated

Markets alternate between periods of consolidation and periods of clear trends. Toby Crabel is a strict believer of this theory. In 1989, Toby Crabel published a book on another very well-known market theory and strategy, “The Opening Range Breakout”. We will discuss this theory in a later post. Right now, we’re focusing on Crabel’s theories around market contractions and expansions.

Crabel’s premise was that markets continually rotate from rest to movement and back again. In simple terms, this means that markets shift between trend and consolidation in a flowing motion. Toby Crabel was looking for ways to capture the shift from consolidation to a trend to hop on a starting trend as early as possible. This is where the Narrow Range strategy comes into play. Its name is often shortened to NR4 and/or NR7, depending on the number of days to take into consideration for defining the range. 

Disclaimer: Templates are for educational purposes only!

👉 Get the Toby Crabel NR4 Automation Template → Toby Crabel NR4 Profectus Template

This template is designed to run on the Daily Timeframe.

The Narrow Range theory explained

The Narrow Range theory is a way of quantifying how markets can move from a consolidation period (the range) to a trending period. It’s based on the logic that a narrow range can indicate a balance between buyers and sellers, which is evidence of rest. Once the price breaks out of this resting phase, price movements can become a trend leading to a clear short-term move in one direction. The trade is an attempt to catch this short-term trend as soon as the price breaks out of the range. Crabel specifically wanted to define this shift without using indicators since it resembles how Bollinger Bands compress and expand. The problem with the indicators, such as Bollinger Bands, is that they are lagging in nature. 

The theory was designed to capture bullish breakout moves in equity markets where the general bias is to the upside over the long-run. We have adjusted the strategy slightly to also benefit from short-term downward trends, and this has also proven to work surprisingly well on a range of markets, including equities. 

What NR4 means

NR4 implies we’re looking for the narrowest range over the past 4 days or candles. Specifically, the range of the most recent day or candle needs to be the smallest of the 3 days or candles before that. For simplicity, let’s stick to days for the period because the template is also built for the Daily timeframe.
There is another popular variation called NR7, which is essentially the same strategy, but instead of looking at 4 days in total, the setup looks at finding the smallest range day over 7 days in total. 

So, when we’re referring to the NR4 setup, the total size of the most recent daily candle is the smallest of the 3 candles before that. If this is not the case, there is no NR4 setup. 

This is what the NR4 setup looks like on a chart.

Toby Crabel NR7 trading strategy
Toby Crabel NR4 strategy example

The NR4 strategy rules

Let’s write down the rules of this trading system step-by-step.

  1. Find an inside bar. An inside bar means that the high of the candle is below the high of the candle before it, and the low of the candle is above the low of the candle before it. 
  2. Check the Narrow Range. The inside bar is the candle to be checked against the 3 candles before that. The range of this inside bar needs to be smaller than the ranges of the 3 candles before it. The range is calculated as:

    Candle high - Candle low
  1. Wait for a cross of the high or low. Once the NR4 candle is identified, we wait for the price to cross the high or the low of this candle. If the low is crossed, the system takes a sell position. If the high is cross, the system takes a buy position. 
  2. Reset the count and repeat.

Now, let’s build this system in Profectus AI. This is what it looks like on the Profectus AI Builder Canvas.

Toby Crabel NR4 Expert Advisor in Profectus AI
Toby Crabel NR4 strategy in Profectus AI blocks

How to build the NR4 Trading Algorithm

Let’s start building this strategy. We divide it into 3 sections.

  1. Finding the NR4. In this section, we want to find the NR4 candle. That is the inside bar, with the smallest range of the past 3 candles before it. To find the inside bar, we use 2 trade rule blocks to specify that the high of the candle is below the high of the candle before it, and the low of the candle is above the low of the candle before it. 

    To make sure it’s the narrowest range candle, we need a small and simple loop. The trade rule block to define the narrow range is simply:

    Candle total size for Candle ID 1 is smaller than Candle total size for Candle ID x

    Candle ID x is the candle before. So, we compare the total candle size of the inside bar candle with 3 candles before that to make sure it’s the smallest of the 3. The loop adds 1 candle to eventually find the 3 in a row. The last Trade rule block makes sure that the loop stops once a total of 4 candles have been considered to complete the NR4 pattern. If we want to change this to an NR7 pattern, we simply put the lookback to 7 candles instead of 4.

  2. Trade the NR4. If the NR4 pattern is confirmed, the Greenlight variable is set to OK. This means that the system can start looking for trades. The first check if there are no open trades yet. If that’s the case, the system looks for a cross of the high or the low of the inside bar to take a buy or sell trade. After a trade is taken, the trade counter is set to 1 so no more trades on that day can be taken in that direction.

  3. Reset the Trade Counter. At the end of each trading day the system resets all variables back to their default settings so the entire process from start to finish can be run the next day again.

Deploying the Strategy as an MQ5 Bot on MetaTrader 5

Once automated, the Toby Crabel NR4 strategy can be deployed as:

  • An MQ5 trading bot

  • Running 24/5 on MetaTrader 5

  • Executing trades exactly as designed once you add buy/sell blocks and rules

Why MT5?

  • Built-in algorithmic execution

  • Broker compatibility

  • Robust order handling

  • Industry-standard platform for automated trading

This allows you to move from manual chart analysis to mechanical automated trading.

Can You Automate Other Trading Legend strategies?

Yes. You can already find our legendary Rychard Wyckoff strategy here as well. We can automate any legendary strategy if it’s mechanical.

If a strategy has:

  • Clear rules

  • Defined conditions

  • Objective execution logic

It can be automated.

Get Access to the Toby Crabel NR4 Automation Template

Want to see how this Toby Crabel NR4 strategy works when fully automated?

Access an enhanced automation template used to turn this trading concept into a deployable MQ5 trading bot inside Profectus. This template has a trade execution module included, so you can start testing it right away!


Disclaimer: Templates are for educational purposes only!

👉 Get the Toby Crabel NR4 Automation Template → Toby Crabel NR4 Profectus Template

This template is designed to run on the Daily Timeframe.