Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

Metatrader 5 Indicator | Pullback Depth Statistics: How Deep Do Pullbacks Go Before the Trend Resumes? | So…

Explore the latest free tools from the MQL5 community. Here's a new indicator, expert advisor, or script for MetaTrader.

Pullback Depth Stats

Category: Indicators.

The idea behind it

Everyone has a favorite retracement number — 38.2%, 50%, 61.8% — picked up from somewhere and applied to every chart since. This indicator replaces the guess with a count. It tracks the market's own swing structure: an impulse leg runs from a base to an extreme, then a pullback begins. The indicator watches that pullback's own extreme as it develops and waits for one of two outcomes — price makes a new extreme beyond the leg (the trend resumed, and the pullback's depth gets recorded) or price closes back past the leg's own base (the trend failed outright, tallied separately from the depth buckets). Once enough of these have been seen, the histogram shows where this specific symbol's pullbacks actually tend to bottom out before resuming, instead of assuming a textbook number applies.

Watch in-depth trading tutorials and EA reviews on the RobotFX YouTube channel. Subscribe for free tips.

A short fractal check is used only once, to find the market's first swing high and swing low and seed the very first leg. After that, every further leg transition comes directly from price making a new extreme or breaking the prior base — no repeated fractal scanning, and no re-reading of history after the initial backfill.

How to interpret it

  • The six main bars are retracement-depth buckets (0-23.6%, 23.6-38.2%, 38.2-50%, 50-61.8%, 61.8-78.6%, 78.6-100%), each showing how often a resumed pullback bottomed out in that zone.
  • The orange bar on the right is the "full reversal" count — pullbacks that didn't resume at all and instead broke the leg's own base.
  • The live line reports the direction and depth of whatever pullback is in progress right now, updated as price moves.
  • Up-leg and down-leg pullbacks are pooled into one set of statistics, since most symbols show fairly symmetric pullback behavior and pooling gives a larger, steadier sample.
  • A one-time backfill on attach means the histogram has real shape from the first chart refresh, not an empty one that fills in slowly.

External variables (inputs)

Input Default Purpose
InpWorkTimeframe PERIOD_H1 Timeframe the swing structure and pullback logic run on.
InpSwingBars 3 Bars checked on each side when seeding the very first swing high/low; not used again afterward.
InpLookbackBars 3000 Bars walked once on attach to seed the leg structure and statistics.
InpCorner CORNER_LEFT_UPPER Chart corner the panel is anchored to.
InpCornerX 20 Panel X offset in pixels.
InpCornerY 20 Panel Y offset in pixels.
InpBarWidth 24 Width in pixels of each histogram bar.
InpBarMaxH 70 Maximum height in pixels for the tallest histogram bar.

Recommended use

  • Attach per symbol — pullback depth is a property of that instrument's own volatility and order flow, not something that transfers across symbols.
  • Let the backfill cover a decent stretch of history (a few thousand H1 bars) before reading too much into a thin-sample histogram.
  • A histogram skewed toward shallow buckets suggests a trend that doesn't give deep pullbacks to enter on; a widespread suggests the opposite.
  • A high full-reversal count relative to resumptions is itself informative — it means this symbol's "pullbacks" often aren't pullbacks at all.
  • Pure visualization — it places no orders and holds no position.

Image for Pullback Depth Statistics: How Deep Do Pullbacks Go Before the Trend Resumes?

Fig. 1. Pullback Depth Stats — retracement-depth histogram plus the live in-progress pullback readout (shown in black & white per Code Base image guidelines).

Level up your trading with professional RobotFX expert advisors and indicators. Visit robotfx.org for proven MT4/MT5 tools.

80202

Best MetaTrader Indicators + Profitable Expert Advisors