Watch how to download trading robots for free
Find us on Twitter!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Indicators

Pullback Depth Statistics: How Deep Do Pullbacks Go Before the Trend Resumes? - indicator for MetaTrader 5

Views:
42
Rating:
(1)
Published:
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

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.

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.


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

Squeeze Duration Statistics: How Long a Low-Volatility Squeeze Lasts and How Far the Range Expands After It Squeeze Duration Statistics: How Long a Low-Volatility Squeeze Lasts and How Far the Range Expands After It

Measures low-volatility squeezes on your own symbol and timeframe. A squeeze is a run of bars in which the range of the last bars is small compared with the ATR. The indicator draws the length of every squeeze, marks the bar that ended it, and a panel shows how long squeezes last, how far the range expanded in the bars after the release, how that compares with any other bar, and which side of the squeeze box the first close went to. It is a statistics tool and gives no trade signals.

Trading Conditions Monitor - Gold, Forex and Synthetics Trading Conditions Monitor - Gold, Forex and Synthetics

Is it a good moment to trade? One panel combines spread, session, rollover, volatility, daily range and high-impact news into a clear GOOD / CAUTION / AVOID status. Works on all symbols, tuned for gold (XAUUSD).

Breakout Follow-Through Statistics: Real Break or Fakeout After a New N-Bar High or Low? Breakout Follow-Through Statistics: Real Break or Fakeout After a New N-Bar High or Low?

Every new N-bar high or low gets tagged, timed, and scored — real breakout or fakeout — so the scorecard tells you what this symbol has actually done at its own extremes, not what you assume it does.

PropFirm Consistency and Drawdown Monitor PropFirm Consistency and Drawdown Monitor

Read-only PropFirm daily drawdown, trailing total drawdown, and single-day consistency cap HUD monitor with four closed-bar iCustom buffers.