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

Taught to TradeSystems over signals.

Explainers / Range Filter

Range Filter, explained from the source

"Range Filter Buy and Sell 5min" (the guikroth version of DonovanWall's Range Filter) is one of the most-boosted trend scripts on TradingView, and VuManChu Swing Free and Twin Range Filter are built on the same idea. It draws a line that steps along with price, two target bands, coloured candles and Buy/Sell labels. This page explains, from the published source, what each of those is. The short version: the line is a ratchet that ignores any move smaller than one "range", and a label appears only after price has come back at least two ranges from its last extreme close.

The range: an average bar move, smoothed and multiplied

The script first measures how much price usually moves per bar: the average of the absolute bar-to-bar change of the source (close by default) over the Sampling Period (100). It then smooths that average again over twice the period minus one (199 bars) and multiplies it by the Range Multiplier (3). Call the result r. With the defaults, r is about three times a typical bar's move, and because of the double smoothing it changes slowly.

The line: a ratchet that ignores small moves

The filter line follows one rule each bar:

So the line never moves on a small wiggle. In our simulation it stayed perfectly flat on about three bars in four. When it does move, it trails price at a distance of exactly r. The two "target" bands are simply the line plus r and the line minus r: they mark the prices a close must pass to move the line at all.

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 Buy label prints on the first bar where the line steps up after it last stepped down, and a Sell label on the reverse. (The two-part conditions in the code, "price above the line and rising, or above the line and falling", reduce to "price above the line, the line's last step was up, and the close changed".)

That makes the turn point easy to compute. After a rise, the line sits r below the highest close. It can only step down when a close falls more than r below the line, which means at least 2 r below the highest close (measured with today's r; the range drifts slowly). The label is a trailing stop of two ranges on closes, with a label instead of an exit. In the simulation, the move from the last extreme close to the label was about 2 r or more in nine cases out of ten (median 2.2 r; slightly less only when the range itself had shrunk in the meantime), and the label came a median of about 10 bars after that extreme.

Does it repaint?

On closed bars, no: the line, the colours and the labels use only the current and past closes, so a finished bar does not change. On the bar that is still forming, the close is the live price, so a label can appear mid-bar and vanish before the close. An alert set to "once per bar" can fire on a label that is not on the chart afterwards; use "once per bar close" if you only want closed-bar labels. More on this in what repainting is, or test a script with the repaint checker.

"5min" settings vs the original

The guikroth version's defaults (Sampling Period 100, Multiplier 3.0) are labelled in the code as settings "for 5min chart, BTCUSDC", with a note to change them for other coins. They are not tuned for anything else, and the script contains no test of them. DonovanWall's original uses a much shorter period (14), lighter smoothing (27) and a 2.618 multiplier, and adds options: ATR, standard deviation, points, pips or % of price for the range; wicks instead of closes; a second filter type that moves in whole steps of r; and averaging of the filter's changes.

In the simulation the two defaults behaved alike: a label every 35 bars (guikroth) vs every 28 bars (original), with 3-6% undone within 5 bars. The bigger difference is speed of adapting: the 199-bar smoothing means the guikroth range takes a long time to catch up after volatility changes, so the same r can be too tight after a quiet spell turns busy, and too wide after a busy spell calms down.

Settings, honestly

The code also includes a commented-out strategy block with a fixed 400-pip target and 100-pip stop. Those numbers are an example in a comment, not tested values.

Where it fails

Also explained: Supertrend · Chandelier Exit · UT Bot Alerts · Repainting

Educational only. Not financial advice. Nothing here is a recommendation to buy or sell anything. Range Filter is by DonovanWall, and the Buy and Sell 5min version is by guikroth, 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, Twin 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.