Portfolio Correlation Analyzer
Info
The Portfolio Correlation Analyzer is a Script for MetaTrader 5 that the idea is to measure the combined risk of multiple expert advisors (eas) on one account. The number that matters is not how much each EA earns, but how much of their combined risk cancels out.
Usage
This tool is typically used for enhancing chart analysis and decision making.
Platform
This Script works exclusively on MetaTrader 5 (both build 600+ and newer versions).
Setup
Place the downloaded file in MQL5/Scripts folder via File ? Open Data Folder in MetaTrader 5.
How to Install and Use Portfolio Correlation Analyzer
1. Installation: Move your script file into the MQL/Scripts directory and restart the platform.
2. Execution: Drag the script onto a chart; it will perform a one-time action, such as closing all open orders or clearing chart objects.
3. Editing: Use MetaEditor (F4) to modify code, click "Compile," and verify no errors appear in the terminal before running.
4. Removing: Scripts stop automatically, but you can remove them manually by right-clicking the chart and choosing "Remove Script."
Frequently Asked Questions
Q: How are scripts different from EAs? A: Scripts execute a single action and then stop; EAs monitor the market and trade continuously.
Q: Can I assign a hotkey to a script? A: Yes, right-click the script in the Navigator, select "Set Hotkey," and define your preferred keyboard shortcut.
Q: Why did my script stop? A: Scripts are designed to stop immediately after finishing their programmed command; this is normal behavior.
What this tool does
The idea is to measure the combined risk of multiple Expert Advisors (EAs) on one account.
Typical Use Case
This Script excels in automated trading and technical analysis on MetaTrader 5.
Compatible Platform & Setup
This Script works on MetaTrader 5. Place the file in the MQL5/Scripts folder and restart the terminal.
Description & Settings
Related: portfolio scorer: comprehensive multi-ea correlation and coverage analysis - another powerful script for MetaTrader 5 traders.
The idea is to measure the combined risk of multiple Expert Advisors (EAs) on one account. The number that matters is not how much each EA earns, but how much of their combined risk cancels out. This script measures the worst losing stretch of each system on its own and adds those numbers together, then measures the worst losing stretch of the whole account over the same period. The difference between these two numbers is the only honest measure of diversification.Also recommended: vr orders history mt5 lite - similar script with strong performance on MetaTrader 5.
The script reports four things: per system trade count, net result, and maximum drawdown for every magic number that passes the minimum trade filter; compression, which is the sum of all standalone drawdowns against the drawdown of the combined account, and the ratio between them; correlation, which is the full pairwise Pearson correlation matrix on period profit and loss; and Monte Carlo results, which are the same period results reshuffled into a new random order a few thousand times.
The compression ratio is the headline, as it tells you what diversification bought you, in your own currency, on your own trades. The average absolute rho tells you whether the roster is genuinely different or only looks different. The Monte Carlo percentile is the uncomfortable one, as it tells you where your historical drawdown sits inside the cloud of possible outcomes.
The script has several inputs, including bucketing granularity, number of Monte Carlo reshuffles, minimum trades, reference balance, export to CSV, draw panel, mask magics, panel offset, panel maximum size, and Monte Carlo seed. The script also has some notes and limits, such as drawdowns being computed on closed trade results, including both entry and exit deals, and correlation needing enough periods to be reliable.
The script does not place, modify, or close an order, predict anything, produce signals, or connect to any network or external service. It reads your history and reports what is in it. The script is written in pure MQL5, is a single file, and has no external libraries.
You may also like: send a trade position to telegram channel - excellent alternative for script users on MetaTrader 5.
Source Code
#property copyright "RobotFX"
#property version "1.30"
#property description "This code is educational. Feel free to use, modify and upgrade as you wish. Visit ROBOTFX.ORG for professional trading tools"
#property script_show_inputs
#define VAP_FONT "Consolas"
#define VAP_FONT_ALT "Arial"
#define VAP_INK VAColor( 20, 28, 44)
#define VAP_INK_DARK VAColor( 13, 19, 33)
#define VAP_EDGE VAColor( 62, 76, 98)
#define VAP_TEXT VAColor(160, 180, 205)
.......
⚠ Limitations & Risk Warning
- This tool is provided for educational and testing purposes only.
- Past performance does not guarantee future results.
- Trading involves substantial risk of loss. Use on a demo account first.
- Results may vary depending on market conditions, broker, and settings.
- We recommend thorough backtesting and forward testing before using with real funds.