Central Command

The range deviation indicator: spotting stretched moves on a crypto chart

Where price sits in its recent range, what the red and blue bars mean, and how an agent can trade the exact same colours.

Most of the time price wanders inside a range. Now and then a bar pushes out of it, and traders want to know two things: is this bar unusual, and what usually happens next? The range deviation overlay answers the first question on the chart, in colour. I build Central Command, a trading terminal and agent builder for BloFin, and this is what the overlay measures, how to read it, and how to put it in an agent's rules.

The maths in plain words

Take a window of bars, 100 by default. Set aside the most extreme tenth on each side: with 100 bars, the 10 highest highs and the 10 lowest lows. What's left gives the range:

  • Range high: the 11th-highest high in the window.
  • Range low: the 11th-lowest low.

Trimming the extremes means one spike can't stretch the range on its own. With a smaller window the trim is still at least one bar, so with 10 bars the range high is the second-highest high.

Then each bar gets a colour:

  • Red when its high is above the range high.
  • Blue when its low is below the range low (and it isn't already red).
  • No colour when it stays inside, in the amber band between the two lines.

With the default window, a bar is red when its high is among the ten highest of the last 100 bars, itself included, and blue when its low is among the ten lowest.

There's also a number: where the close sits in the range. 0 is the range low, 100 is the range high, and anything below 0 or above 100 closed outside it.

position = (close - range low) / (range high - range low) x 100

A worked example

On a 1-hour BTC chart, say the 11th-highest high of the last 100 bars is $82,400 and the 11th-lowest low is $78,900. A new bar reaches $82,650 and closes at $82,300.

  • Its high, $82,650, is above $82,400, so it's red.
  • Its close sits at (82,300 - 78,900) / (82,400 - 78,900) x 100 = 97, near the top of the range but back inside it.

A red bar that closes back inside the range is a different picture from one that closes at 110, well above it. The colour tells you the bar stretched. The number tells you whether it held.

On screen or fixed window

The overlay has two modes, and the difference matters if you want an agent to trade it.

On screen was how the overlay first worked. It takes one range from all the bars you can see and measures every visible bar against it. Zoom out and the range changes, and so do the colours. Each bar's colour also depends on bars that came after it, so it describes the chart in front of you, not what was knowable when the bar closed.

Fixed window measures each bar against the window of bars ending at that bar, itself included. It reads only the bar and the ones before it, so once a bar has closed its colour never changes, however far you zoom and however much history is loaded. The window can be anywhere from 4 to 1,000 bars.

Fixed window is the mode agents and backtests read. In that mode the chart also shows a readout beside the overlay's label: the colour and the position of the bar under your crosshair, with the names an agent's rules use. You can hold the chart up against an agent's decision on the same bar and see the same numbers.

How to read it

Red and blue bars mark stretched moves. They aren't buy or sell signals by themselves.

  • In a trend, red bars cluster as price keeps making new highs, and a run of them can last a long time. Selling every red bar in a strong uptrend means standing in front of the move.
  • In a range, a red bar near the top that closes back inside can be the move running out. Waiting for the close to come back below 100 is one way to see that.
  • The first bar is its own event. A bar that turns red or blue after a quiet stretch is a different thing from the fifth red bar in a row, and rules can tell the two apart (below).

Pair it with something that tells you the trend, such as a long moving average, and decide in advance which of the two cases you're trading.

Trading the same colours with an agent

The rule language our agents and backtests use reads the overlay directly, from the same code that draws it on the chart:

RANGE_DEV(100)          where the close sits, 0 to 100
RANGE_DEV_HIGH(100)     the range high
RANGE_DEV_LOW(100)      the range low
RANGE_DEV_STATE(100)    1 red, -1 blue, 0 no colour
RANGE_DEV_RED(100)      1 on a red bar
RANGE_DEV_BLUE(100)     1 on a blue bar

The number in brackets is the window in bars. You don't have to write these yourself. Plain-English rules are compiled into them:

  • "Go long when range deviation turns blue" becomes RANGE_DEV_BLUE(100) AND NOT RANGE_DEV_BLUE(100)[1]: blue on this bar and not on the one before.
  • "Back inside the range after a blue bar" becomes RANGE_DEV_STATE(100) == 0 AND RANGE_DEV_BLUE(100)[1].
  • "Close in the lowest fifth of the range" becomes RANGE_DEV(100) < 20.

Rules read closed candles, so an agent acts on a bar's final colour, never on a bar still forming. Because the chart, the backtest and the live agent run one piece of code, the colour you see in Fixed window mode is the colour the agent traded.

Range deviation FAQ

Does the range deviation indicator repaint?

In On screen mode, yes: colours change as you zoom and pan. In Fixed window mode a closed bar's colour never changes. The newest bar can change until it closes.

What window should I use?

The default is 100 bars. A shorter window reacts to smaller moves and paints more bars. Whatever you choose, use the same number on the chart and in your rules.

Can a bar be red and blue at once?

A bar that breaks both sides counts as red.

Try it

Open the terminal, turn on Range deviation under Smart overlays and switch it to Fixed window, then write a rule around it and backtest it before anything runs. It's free with a BloFin account opened through our link, or there's a 10-day free trial with no card.


Disclosure: I build Central Command, which earns a commission from BloFin on members' trading. This article was drafted with AI assistance. It is not financial advice. Past results do not guarantee future returns, and leveraged trading can lose all of your money.

Start free

Central Command is free with a BloFin account opened through our referral link, for as long as you trade through us. Or take the 10-day free trial: no card, no wallet, nothing renews.

  1. Create an account at https://centralcommand.io/signup.
  2. Choose Free with BloFin and connect BloFin in one click (no BloFin account yet? open one at https://partner.blofin.com/d/centralcommand), or choose the 10-day free trial.
  3. Trade from the terminal at https://centralcommand.io/dataterminal, or describe a strategy in plain English at https://centralcommand.io/agents/new: backtest it, run it on paper, and go live when you choose.

BloFin's normal trading fees still apply. Central Command trades BloFin perpetual futures only.