Loading…

Volatility Signature Plot Exporter

A single realised-volatility number depends heavily on how often you sample the price series to compute it - and that dependence is itself informative. The volatility signature plot (in the tradition of Andersen, Bandi and Russell's intraday volatility work) computes realised variance of log-returns at a range of sampling intervals over the same fixed window and looks at the shape of the resulting curve. On real intraday data, that curve typically rises sharply at very short intervals - bid-ask bounce and other microstructure noise inflate variance at high sampling frequency - then flattens toward a plateau as the interval lengthens and the noise averages out. Where the curve flattens is a practical guide to how finely a strategy can actually sample this instrument before it is measuring noise rather than genuine price variation. This script builds that curve directly. It pulls a fixed window of M1 closes, then for each requested sampling interval (in minutes) computes non-overlapping log-returns at that interval and sums their squares into a realised variance figure, alongside the implied volatility over the window and a rough annualised percentage. Every interval is computed from the same underlying M1 series pulled once, so the comparison across intervals is apples-to-apples rather than each interval quietly using a different slice of history. MQL4 has no convenient built-in way to draw a log-log chart, so the result is written as a plain sampling_minutes / realised_variance / vol table to CSV - the point of a signature plot is the shape across many intervals at once, which is far better served by an external plotting tool than by anything this script could draw on the chart itself. Notes and limitations - Always uses M1 as the base series regardless of the chart it is attached to, since the shortest available bar size is what makes the short-interval end of the signature curve meaningful at all. - An interval that leaves fewer than 2 non-overlapping samples in the window is skipped with an explicit log line rather than reported as a misleadingly precise zero. - The annualised volatility figure is a rough scaling of the window's realised volatility assuming a stationary process across the year; it is intended for cross-interval comparison within this run, not as a standalone forecast. - Symbol history depth varies by broker; a request for more InpLookbackBars than the terminal actually holds is capped automatically, with the actual window size reported in the log.

Script · MT4 · v1.0 · Free

About Volatility Signature Plot Exporter

Volatility Signature Plot Exporter is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 3 settings, such as Sampling minutes, Lookback bars and Export csv. MQL source code included.

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

Settings

SettingDefaultWhat it does
Sampling minutes1,2,3,5,10,15,20,30,60Comma-separated sampling intervals, in minutes
Lookback bars4000M1 bars forming the fixed analysis window
Export csvtrueWrite the signature table to CSV

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 → Scripts.
  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 script onto a chart to run it once.

Download the PDF guide

Tags: Alerts · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria