Free: indicator teardowns, a repaint checker and open-source scripts. No buy/sell signals, ever.

Taught to TradeSystems over signals.

Explainers / Twin Range Filter

Twin Range Filter, explained from the source

Twin Range Filter by colinmck is one of the most-boosted trend scripts on TradingView, and KivancOzbilgic's "Twin Range Filter Visualized" draws the same thing as a line. The name suggests two filters working together. The published source shows something simpler: two range measurements are averaged into one number, and that one number drives an ordinary Range Filter. The Long and Short labels come after price has turned about two ranges from its last extreme close.

The two ranges

The script measures how much price usually moves per bar, twice:

It then takes the average of the two. Call that r. Both halves measure the same thing (typical bar size) with long, slow smoothing, so they rise and fall together. In our simulation they were correlated at 0.9975, and their average was matched to within about 1% by a single range of 40 bars times 1.8. The labels from that single range were the same as the twin's on 98% of bars. In practice, "twin" means one range of about 1.8 typical bar moves.

The line: a ratchet that ignores small moves

The filter is the same rule as the Range Filter:

So the line ignores any move smaller than r; in the simulation it stayed flat on about two bars in three. colinmck's version does not plot this line at all, only the labels. The Visualized version plots a stepped line built from the filter plus and minus r.

The labels: a 2 x range turn on closes

The script counts how many times in a row the line has stepped up or down. A Long label prints on the first bar where the line steps up after its last step was down, and Short on the reverse. The two-part conditions in the code reduce to "close above the line, last step up, and the close changed".

After a rise the line sits r below the highest close, so it can only step down after a close more than r below the line: at least about 2 r below the highest close. In the simulation the median move from the extreme close to the label was 2.3 r, and the label came a median of 5 bars after that extreme.

The Visualized version labels BUY and SELL when the close crosses its stepped line instead. In our simulation 99% of those crosses landed within one bar of a colinmck label: the two scripts mark the same turns.

Twin vs the original Range Filter

The difference that matters is the width. The Range Filter scripts use multipliers of 2.618 (DonovanWall's original) or 3.0 (the "Buy and Sell 5min" version); the twin's effective multiplier is about 1.8. A narrower band waits for a smaller turn, so it labels more often and reverses more often:

Simulation, random walklabel everyundone within 5 bars
Twin Range Filter (27/1.6 + 55/2.0)16 bars18%
Range Filter, original (14 / 2.618)28 bars5.5%
Range Filter Buy and Sell 5min (100 / 3.0)35 bars3.2%

Earlier labels and more labels that reverse are the same setting seen from two sides.

Does it repaint?

On closed bars, no: the range, the line and the labels use only current and past closes, so a finished bar does not change. On the bar still forming, the close is the live price, so a label can appear mid-bar and vanish before the close. Set alerts to "once per bar close" if you only want closed-bar labels. More in what repainting is, or test a script with the repaint checker.

Settings, honestly

Where it fails

Also explained: Range Filter · Supertrend · UT Bot Alerts · Repainting

Educational only. Not financial advice. Nothing here is a recommendation to buy or sell anything. Twin Range Filter is by colinmck, and Twin Range Filter Visualized is by KivancOzbilgic, on TradingView; this page explains their published open-source code and is not affiliated with either author.

Also explained: Repaint checker, VWAP, Supertrend, RSI, UT Bot Alerts, Nadaraya-Watson Envelope, Squeeze Momentum, What is repainting on TradingView?, Is TradingView backtesting accurate?, Chandelier Exit, WaveTrend Oscillator, QQE MOD, Pivot highs and lows, Hull Suite, Range Filter, HalfTrend, ZigZag++, SSL Hybrid, CM MacD Ultimate MTF, Volume Profile / Fixed Range, ADX and DI, Support Resistance Channels, Market Structure Break & Order Block, Order Block Finder, Pivot Point SuperTrend, Trendlines with Breaks [LuxAlgo], Divergence for Many Indicators, TradingView script selling terms, Support and Resistance Levels with Break, Liquidity Swings [LuxAlgo], Pine Script errors, Breakout Probability (Expo), Did ChatGPT or Claude write your Pine Sc, Lorentzian Classification, SuperTrend AI (Clustering), Machine Learning Adaptive SuperTrend, Dynamic Swing Anchored VWAP, Support and Resistance Power Channel by , Support and Resistance (High Volume Boxe, Trendline Breakouts With Targets by Char, Breakout Finder by LonesomeTheBlue

Next steps

  • Get a script fixed. Compiles but behaves differently live, or changes after a reload? In a Pine Script Audit, an AI model reads every line and writes a report on what to fix for $49, or also fixes those problems for $149. It cannot prove a script is safe.
  • Check your own script. Paste its source into the free repaint checker. It runs in your browser and flags known patterns.
  • Read our rebuild. Range Filter Audit is free and open source: the same filter with the turn level drawn and open-bar turns marked separately.
Subscribe to the Teardown Letter: $19/moBack to Taught to Trade

No TradingView account yet? This affiliate link gives you a $15 coupon toward a paid plan, and we earn a commission if you buy one. The free plan is enough to follow this page.