Loading…

Volatility Forecast Gap Meter

A volatility forecast built by exponentially weighting past returns (the RiskMetrics EWMA approach, decay factor lambda) is smooth by design - it reacts to new information gradually rather than jumping with every bar. That smoothness is also its weakness: it can lag badly behind a sudden change in actual market behaviour. This indicator plots the gap between that forecast and what volatility actually realised over a plain trailing window, so the lag becomes visible instead of implicit. The forecast is built recursively: each bar's forecast variance is lambda times the previous forecast variance plus (1-lambda) times the latest squared return, the same recursion used in RiskMetrics-style risk models. The realised figure is a plain sample standard deviation of returns over InpRealisedWindow bars, computed independently at each bar with no smoothing. The plotted histogram is forecast minus realised, in the same scaled units for both. A positive gap means the forecast has been sitting above what actually happened - the market has been calmer than the decayed memory of past volatility still implies, and a forecast-based stop distance or position size computed right now is probably wider or smaller than the recent market actually needs. A negative gap means realised moves are currently outrunning the forecast - the classic setup where a stop or size calculated from the forecast turns out too tight, because the forecast has not yet caught up with a fresh burst of activity. Notes and limitations - The EWMA forecast is a recursive series with, in principle, unlimited memory back to the start of the recursion. Rebuilding it from the true start of history on every tick would be needlessly expensive on a long chart, so this indicator re-seeds the chain from a plain sample variance 300 bars behind whatever range needs recalculating and walks forward from there. At the default lambda of 0.94, a return's weight in the recursion is already below 0.1% of the newest return's weight after roughly 115 bars, so this reproduces the true infinite recursion to well beyond floating point precision - it is not a visible approximation in practice. - Both series are expressed as a scaled standard deviation of simple returns, not annualised - compare the trend and the sign of the gap on one symbol over time, not absolute levels across symbols. - Needs roughly InpRealisedWindow + 300 bars of history before it starts plotting, to give the EWMA re-seed a settled starting point. - A close of zero or a missing prior close (not expected on real MetaTrader history, cheap to guard against) is skipped in both the forecast return and the realised-window calculation rather than producing an invalid reading.

Indicator · MT4 · v1.0 · Free

About Volatility Forecast Gap Meter

Volatility Forecast Gap Meter is an indicator for MetaTrader 4. It has 3 settings, such as Lambda, Realised window and Scale. MQL source code included.

Files in the download: VolForecastGapMeter.mq4, VolForecastGapMeter.txt.

Settings

SettingDefaultWhat it does
Lambda0.94EWMA decay factor for the forecast (RiskMetrics default 0.94)
Realised window20Bars of returns averaged into the realised volatility figure
Scale10000Multiplier so both series print in a readable range

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 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: Trailing Stop & Break-even · MT4 Indicator · MQL4 Source Code

MetaTrader 4 & 5 indicators · PolyMaria