Portfolio Backtest Aggregator
The Strategy Tester reports one symbol at a time. The obvious way to estimate a multi-symbol portfolio's risk is to test the strategy on each symbol separately and add up the max drawdowns from each report. That number is not the portfolio's real drawdown, and it is wrong in a way that can go either direction: five symbols rarely hit their own worst day on the same calendar day, so the sum usually overstates the true combined worst case, but if the symbols actually move together the real combined drawdown can just as easily be worse than the naive sum ever suggested, because losses that would have offset on paper instead stack. The only correct combined drawdown comes from one equity curve built by replaying every trade from every symbol in true chronological order, not from combining each symbol's own independently-computed statistic. This tool takes several CSV trade exports - one per symbol, in a simple Symbol/OpenTime/CloseTime/Lots/Profit shape - merges every trade into one timeline by close time, and walks that single timeline to compute the real combined equity curve, peak, and max drawdown. It reports that next to the naive sum so the size and direction of the gap is visible, then adds two supporting statistics per symbol pair: how many of the merged trades on each pair had genuinely overlapping open windows, and the Pearson correlation of the two symbols' recent price history - the two concrete reasons the naive sum was never going to be reliable. Notes and limitations - Requires each symbol's price history to already be cached locally for the correlation calculation; open a chart on each symbol first if InpCorrelationLookback bars are not yet available and the report shows "n/a (insufficient history)" for a pair. - The time-overlap count is a simple pairwise interval intersection test, not a continuous exposure-weighted figure - it tells you how often positions coexisted, not for how long or at what combined size. - Correlation is computed from live/cached price history at the moment this EA runs, not from history as it stood during the original backtests - for a strategy tested over a long historical period this is an approximation of the relationship, not an exact historical figure. - This tool never trades. It only reads the files you give it and writes the merged report.
Expert advisor · MT4 · v1.0 · Free
About Portfolio Backtest Aggregator
Portfolio Backtest Aggregator is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 6 settings, such as File list, Starting balance and High correlation level. MQL source code included.
Files in the download: PortfolioBacktestAggregator.ex4, PortfolioBacktestAggregator.mq4, PortfolioBacktestAggregator.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| File list | Symbol1_trades.csv,Symbol2_trades.csv | Comma-separated trade export filenames, in MQL4\Files |
| Starting balance | 10000.0 | Starting balance the combined curve is built from |
| High correlation level | 0.70 | Pearson correlation above this is flagged as high |
| Correlation lookback | 100 | Bars used to compute price correlation between each symbol pair |
| Correlation timeframe | PERIOD_D1 | Timeframe the correlation is computed on |
| Output csv file name | PortfolioBacktestAggregator_Merged.csv | Combined curve export, in MQL4\Files |
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: Multi-Currency · Alerts · MT4 Expert Advisor · MQL4 Source Code