Loading…

Squeeze Duration Counter

A squeeze indicator that only shows on/off tells you compression is happening, not whether it is unusual. This indicator adds duration: it flags a squeeze using the standard test (Bollinger Band width narrower than Keltner Channel width), counts how many consecutive bars the CURRENT squeeze has run, and compares that live count against the average length of the most recently COMPLETED squeezes on this exact symbol and timeframe - so a trader can see whether the present compression is already running longer than this market's own recent history, which is often when an expansion becomes more likely. Squeeze duration is inherently sequential state - a given bar's run length depends on every prior bar's squeeze/no-squeeze status - so, rather than track an incremental counter that could drift the moment a partial recalculation skips bars, the whole visible history is walked chronologically and rebuilt from scratch on every calculation call. The historical-average sample set is a fixed-size rolling record of the most recently completed squeezes AS OF each bar, so the comparison line is always causal: no squeeze that finishes later can leak into an earlier bar's reading. Notes and limitations - Non-repainting: the squeeze test and run count only use each bar's own completed values, walked forward chronologically. - The historical average has no value at all (line stays blank) until at least one squeeze has fully completed on the loaded history - on a freshly attached chart with limited history this can take a while. - Full-history recomputation on every calculation call is deliberate for correctness given the sequential dependency; on charts with very long loaded history and rapid ticks this trades some CPU for guaranteed- correct duration counts, rather than risking a drifted counter. - This flags compression and its duration only - it does not predict direction of the eventual breakout.

Indicator · MT5 · v1.0 · Free

About Squeeze Duration Counter

Squeeze Duration Counter is an indicator for MetaTrader 5 based on Moving Average, Bollinger Bands and ATR. It has 5 settings, such as Bb period, Bb deviation and Kc period. MQL source code included.

Files in the download: SqueezeDurationCounter.ex5, SqueezeDurationCounter.mq5, SqueezeDurationCounter.txt.

Settings

SettingDefaultWhat it does
Bb period20Bollinger Band period
Bb deviation2.0Bollinger Band standard-deviation multiple
Kc period20Keltner Channel EMA/ATR period
Kc multiple1.5Keltner Channel ATR multiple
History samples20How many recently completed squeezes feed the historical average

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Indicators.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the indicator from the Navigator onto a chart and adjust the settings.

Download the PDF guide

Tags: Bollinger Bands · Channels & Envelopes · Moving Average · ATR · MT5 Indicator · MQL5 Source Code

MetaTrader 4 & 5 indicators · PolyMaria