Range Filter Buy and Sell for MT4 – faithful port of DonovanWall / guikroth with signal statistics

Indicators MetaTrader 4 Free

Range Filter on XAUUSD M15

A line-by-line port of “Range Filter Buy and Sell 5min”:

  • original Range Filter by DonovanWall
  • simplified version by guikroth
  • Pine v5 update by tvenn

It is published open source on TradingView at tradingview.com/script/J8GzFGfD/. All credit goes to those authors.

The logic is exactly the original’s:

  • Smoothed range = EMA(EMA(|close − close[1]|, period), 2 × period − 1) × multiplier. Each EMA is seeded with an SMA, the same as ta.ema .
  • Range filter: the line stays put until price moves beyond it by more than the smoothed range, then follows at that distance.
  • Upward / downward counters, then long and short conditions. A Buy or Sell is printed once per change of side, using the original CondIni logic.
  • High / low target bands at filter ± range. Bar colors as in the original.

Inputs (original defaults): Sampling Period 100, Range Multiplier 3.0.

Added for MT4:

  • Signal statistics panel. It buys at the bar after a Buy, sells after a Sell, and closes and reverses at the opposite signal. It shows:
    • trades, win rate, net points / pips / USD after spread + commission
    • profit factor, longest losing streak, max drawdown
    • the open trade and the cost per trade
  • Daily session filter in your own time zone, with session shading and an optional close at session end. It is off by default (the panel counts the whole day); set Use_Session = true and your hours to use it.
  • Trade marks with tooltips.
  • Alerts on new signals.

Buffers for EAs ( iCustom ): 5 = Buy, 6 = Sell, 11 = filter value.

The panel describes past signals so you can judge them yourself. It is not a backtest and not a promise of results.

Range Filter on XAUUSD H1