Hedge Effectiveness Report
A hedge is supposed to earn back part of what the primary position loses. Whether it actually does is rarely checked after the fact - the hedge just becomes a standing habit, quietly costing spread and swap on every trade without anyone measuring whether the insurance is paying for itself. Order history gives one profit-and-loss number per closed trade, not the tick-by-tick equity curve while it was open, so a true minute-by-minute "did the hedge cancel this exact swing" measurement is not something MQL4 can pull from history alone. This report uses the honest proxy that is available: it finds every stretch of time where a primary trade and a hedge trade were open at the same time, and pro-rates each trade's own closed P/L by the fraction of its total lifetime that overlap covers. Two overlapping trades on opposite sides of P/L - the primary losing while the hedge gains, or the other way round - count toward genuine offset. Two overlapping trades that both lost money in the same stretch count as double cost, because that is exactly what happened: two legs paying for the same adverse move instead of one leg absorbing it. The report totals both figures plus the combined net P/L of the two symbols together, and states a rough offset percentage - the share of the primary's total losses that the hedge is estimated to have covered across all overlapping stretches in the lookback window. Notes and limitations - The offset and double-cost figures are pro-rated approximations built from each trade's own total closed P/L and its overlap duration with the other leg, not a genuine reconstruction of intraday price paths. Treat the percentages as directional evidence, not an exact accounting. - Only closed trades within the lookback window are counted. A position still open when the script runs is not included on either leg. - Requires broker history to actually cover the requested lookback; some brokers cap how far back MODE_HISTORY reaches, in which case the report quietly covers a shorter window than requested. - Symbol and magic filters must be set correctly for a meaningful result - the script does not attempt to guess which trades belong to which strategy. - A hedge that never overlaps the primary in time (e.g. always opened after the primary has already closed) will show zero overlap and zero measured offset, even if it has its own independent P/L.
Script · MT5 · v1.0 · Free
About Hedge Effectiveness Report
Hedge Effectiveness Report is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 5 settings, such as Primary symbol, Primary magic and Hedge symbol. MQL source code included.
Files in the download: HedgeEffectivenessReport.ex5, HedgeEffectivenessReport.mq5, HedgeEffectivenessReport.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Primary symbol | Primary symbol (blank = current chart symbol) | |
| Primary magic | -1 | Primary magic filter (-1 = any) |
| Hedge symbol | Hedge symbol (must be set) | |
| Hedge magic | -1 | Hedge magic filter (-1 = any) |
| Lookback days | 90 | How far back through history to scan |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Hedging · Alerts · MT5 Script · MQL5 Source Code