You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Check out the new article: Hierarchical Risk Parity: A Robust Portfolio Allocator and Expert Advisor.
We implement a Hierarchical Risk Parity allocator in MQL5 as a single class, validate each stage against an independent Python reference, and package it in a rebalancing Expert Advisor. The pipeline covers returns, covariance/correlation, clustering, quasi-diagonalization, and recursive bisection, and contrasts HRP with Markowitz on stressed data. You finish with a verified allocator and an EA ready for basket-level testing.
Hierarchical Risk Parity, introduced by Marcos Lopez de Prado in 2016, takes a different route to the same destination. It never inverts the covariance matrix, so it never sets off the instability in the first place. Instead of treating all the instruments as one pool to optimize over, it first uncovers the structure already sitting in the data: which instruments behave alike, and how they group into families. It arranges them into a tree by similarity, then pours capital down that tree, splitting at each branch in proportion to risk.
This article implements the method as a single MQL5 class, CHRPAllocator, and explains it step by step. Each stage is verified against an independent Python reference. Real-data examples show why HRP avoids the leverage blow-up seen in Markowitz. The allocator is also packaged into a rebalancing Expert Advisor for any basket. HRP is a risk allocator, not a return forecaster, and the article keeps that distinction honest throughout.
It helps to see the finished product before taking it apart. The object the class produces is nothing exotic: a list of weights, one per instrument, all positive and adding up to one hundred percent of your capital. Hand the allocator 250 hourly bars for a five-instrument basket and it returns something you could act on right away.
Author: Hammad Dilber