RealizedVol.mqh measures and forecasts volatility from prices. It has five estimators on OHLC bars (close to close, Parkinson, Garman-Klass, Rogers-Satchell and Yang-Zhang), the daily realized variance, bipower variation and realized quarticity from intraday bars (the bipower variation is the part of the variance without jumps), and the HAR model of Corsi (2009), the usual benchmark for forecasting realized volatility, with Newey-West standard errors. No DLL.
#include <RealizedVol\RealizedVol.mqh>
MqlRates d1[], m5[];
CopyRates(_Symbol, PERIOD_D1, 1, 21, d1);
CopyRates(_Symbol, PERIOD_M5, 1, 300 * 288, m5);
double yz = CRangeVolatility::Estimate(d1, 20, 20, RV_YANG_ZHANG); // variance per day over the last 20 days
double vol = 100.0 * MathSqrt(yz * 252); // % a year
datetime days[];
vector rv, bv, rq;
int counts[];
CRealized::Daily(m5, days, rv, bv, rq, counts); // realized and bipower variance per day
CHar har;
if(har.Fit(rv, 5, true)) // HAR on log realized variance, 5 days ahead
{
double week = 100.0 * MathSqrt(har.Forecast() * 252); // volatility expected over the next 5 days
} The script VolatilityForecast.mq5 prints the volatility of a symbol over the last 20 days by the five estimators, its realized volatility from M5 bars (last day and last 22 days), how much of it comes from jumps, and the HAR forecasts for the next day, week and month with their t statistics (picture 1). It can write the daily realized and bipower variances to a CSV file (picture 2).


RealizedVol.mqh goes to MQL5\Include\RealizedVol, VolatilityForecast.mq5 to MQL5\Scripts\RealizedVol.
Stationarity: KPSS, Phillips-Perron, DF-GLS, Zivot-Andrews and variance ratio tests
Five tests to tell a random walk from a mean-reverting series: KPSS, Phillips-Perron, DF-GLS, Zivot-Andrews with the break date, and the variance ratio.
Risk Lot Calculator - lot size from your risk and stop (class for EAs + chart panel)
Drag the stop-loss line and read the lot size that risks exactly your money or percent. The CRiskSizer class does the same in an EA: lot rounded down, minimum lot never forced, max lot, volume limit, stop level and margin checked.
Close All Positions and Pending Orders
Closes all open positions and optionally deletes pending orders with one click. Filter by symbol and magic number.
Session Boxes Asia London New York
Draws Asia, London and New York session boxes on the chart with each session's high and low.