Discussing the article: "Building a Correlation-Aware Portfolio Risk Monitor in MQL5"

Check out the new article: Building a Correlation-Aware Portfolio Risk Monitor in MQL5.

The article quantifies correlation and portfolio risk in MetaTrader 5: from time-aligned returns to a covariance matrix, true portfolio variance against the independent-sum assumption, and position-level risk attribution. A MetaTrader 5 service runs in the background, shows the metrics on a small chart panel, and pushes alerts when risk thresholds are crossed. Source code is provided for an example script, a reusable risk engine class, and the service.

First, a quick note: I won't rehash the obvious. I'll focus on what correlation means for your actual risk. You already know correlation exists. If you've been trading for more than a week, you know that EUR/USD and GBP/USD tend to drift the same way, that when the dollar moves, it drags half your watchlist with it, and that gold and the indices sometimes hold hands and sometimes don't. That's not news. Most people in this game understand, at least intuitively, that their positions have relationships. But here's the question I actually want to sit on, because this is the part almost nobody can answer: Do you know by how much?

Like, sure, you feel that two of your trades are related. You know the news that hits one hits the other. Fine. But do you know the number? Is that relationship inflating your real risk by 20% or by 90%? Because those are wildly different situations, and they look identical on your Trade tab. "These two move together" is an intuition. It's not a number you can size against. And risk is a number. So, if your feel about correlation never turns into an actual value, you're managing your book on a hunch. And it gets worse the more you trade, interestingly. With two positions, okay, maybe you can hold the relationship in your head. Add a third position, then a fourth and a fifth. At that point, risk is driven by every pairwise interaction. Each correlation either adds risk or offsets it. Nobody eyeballs that. I don't mind how experienced you are; you cannot look at five open trades and feel the combined number. It's not a thing the human head does.

So that's what this is about. I'm not here to tell you correlation exists. You know that; it's been known forever; it's not a discovery. What I want to expose is the gap between knowing your trades are related and knowing, as an actual number, how that specific mix of relationships is building up your risk right now. Because that gap is where accounts get hurt. You think you're diversified because you added variety. But variety isn't the same as independence, and the only way to know the difference is to measure it. The goal is simple: turn the hunch into a number. Then you can tell whether five trades are five independent bets or one bet repeated five times. I'll build it from the ground up. The math is real, but I'll keep it plain, and any symbol that shows up, I'll tell you what it means before I use it. You don't need a finance degree for this. I have one, and honestly the part that matters here fits on one page.


Author: Eugenio Gustavo Guilarte Homayden

A great article and a very useful one. The author put so much effort and thought into this 🙏. 

I would also like to suggest something that you can expand on: a portfolio manager that evaluates each asset added to the portfolio and decide if they are correlated, then the manager can also look at all the backtested result from those assets and evaluate if their past trades were correlated or not. I have seen a few that does this but they just don't manage to evaluate mean-reversion strategies well (or should I say its not targeted for that kind of strategy), because mean-reversion strategies have those occasion "fat-tails" that are usually held for few days to maybe months, or even during good days, those small consistent wins usually make the portfolio evaluator "look good" when that might not be the case.

The manager should be able to know each asset's maximum adverse excursion, if they ever happened around the same time, and how their combined risk affects the account etc...

Great article mate from a quick browse most people don't outline the subject this plainly or well and do so with practical terms and conditions or the code is off as it's reproduced poorly.