Correlation Adjusted Risk Check
Adding up the risk on five open positions and calling that the portfolio risk assumes the five symbols move independently of each other. They rarely do. Five EUR-related longs are not five independent bets; they are closer to one large bet on EUR wearing five different tickets, each one still paying its own spread. A naive sum overstates risk when correlated positions offset each other and understates it when they stack in the same direction. This script measures the actual historical correlation between every symbol currently in the book, using daily-close returns over a configurable window, and combines it with each position's money-at-stop through a variance-style formula: correlated positions in the same direction add risk faster than the naive sum, and correlated positions in opposite directions partially cancel. The difference between the naive total and the correlation-adjusted total is printed directly, so it is obvious whether the book is more hedged than it looks or more concentrated than it looks. A second mode answers the question that actually matters before a trade is sent: what does this specific planned trade add to the book's risk, given what is already open and how correlated it is. The planned trade is added as a hypothetical row, and the script reports its marginal contribution to the correlation-adjusted total separately from its own standalone risk figure, which are often not the same number at all. The formula is a risk lens, not a value-at-risk model. It treats each position's stop distance as a stand-in for that symbol's volatility, which is a simplification worth being honest about rather than dressing up as more precise than it is. Notes and limitations - Correlation is measured on the instruments' own price returns, not on each account's individual trade outcomes - it describes how the symbols move, not how any particular strategy performs on them. - The correlation-adjusted figure is an approximation that treats stop distance as a proxy for volatility. It is meant to correct the "these are five independent risks" assumption, not to replace a full risk model. - A symbol with too little overlapping history against another (fewer than 10 bars of overlap) is treated as uncorrelated with it rather than guessed at. - Correlation measured over one window can shift materially in the next window, particularly around news events - treat the figure as a current read, not a permanent property of the pair.
Script · MT4 · v1.0 · Free
About Correlation Adjusted Risk Check
Correlation Adjusted Risk Check is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 8 settings, such as Correlation bars, Correlation timeframe and Fallback risk pips. MQL source code included.
Files in the download: CorrelationAdjustedRiskCheck.ex4, CorrelationAdjustedRiskCheck.mq4, CorrelationAdjustedRiskCheck.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Correlation bars | 100 | Bars used to measure correlation |
| Correlation timeframe | PERIOD_D1 | Timeframe used to measure correlation |
| Fallback risk pips | 50.0 | Assumed risk, in pips, for a position with no stop |
| Include planned | false | Include a hypothetical planned trade |
| Planned symbol | Planned trade symbol (blank = this chart's symbol) | |
| Planned is buy | true | Planned trade direction |
| Planned lots | 0.10 | Planned trade volume, in lots |
| Planned stop pips | 30.0 | Planned trade stop distance, in pips |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Alerts · MT4 Script · MQL4 Source Code