Volatility Budget Allocator
An EA that gives every symbol the same fixed lot size lets the noisiest instrument in the list dominate the account's actual risk - a 0.10 lot position on a symbol with twice the ATR of another carries roughly twice the money risk, even though the lot sizes look equal on the chart. This EA instead computes, for every symbol in InpSymbolsList, how much account money one lot's ATR-based stop distance represents, and weights each symbol's slice of InpTargetDailyRiskPercent inversely to that figure - a volatile symbol gets a smaller lot count so its contribution to the total budget lands close to the same money figure as every other symbol's. Direction per symbol comes from a plain fast/slow EMA cross (InpFastMaPeriod / InpSlowMaPeriod) - deliberately simple, because this project is about the allocation math, not signal generation, and a complicated entry signal would only obscure whether the budget split is actually working. Every InpRebalanceBars bars the EA recomputes each symbol's current ATR, rebuilds the budget split from today's volatility rather than the volatility at entry, and brings each symbol's position in line with its current direction signal - closing and reopening if the signal has flipped since the last pass. Notes and limitations - The inverse-volatility weighting equalises each symbol's RISK contribution, not its expected return - a low-volatility symbol with no real edge still gets a full-size slice of the budget. - Rebalancing only happens every InpRebalanceBars bars; between passes, positions are left exactly as sized at the last rebalance even if volatility moves sharply in between. - A symbol dropped from the ranking (ATR unavailable, e.g. too little history) is simply skipped that pass - its existing position, if any, is left untouched rather than force-closed. - Direction is a plain EMA cross with no trend-strength filter, so it can flip on marginal crosses in a ranging market, triggering a close/reopen at the next rebalance.
Expert advisor · MT5 · v1.0 · Free
About Volatility Budget Allocator
Volatility Budget Allocator is an expert advisor (trading robot) for MetaTrader 5 based on Moving Average and ATR. It can size trades from your balance and risk percent. It has 11 settings, such as Symbols list, Target daily risk percent and Atr period. MQL source code included.
Files in the download: VolatilityBudgetAllocator.ex5, VolatilityBudgetAllocator.mq5, VolatilityBudgetAllocator.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Symbols list | EURUSD,GBPUSD,USDJPY,AUDUSD,USDCAD | Comma-separated symbols to allocate across |
| Target daily risk percent | 2.0 | Total portfolio risk budget, percent of equity, split across all symbols |
| Atr period | 14 | ATR period used to estimate each symbol's volatility and stop distance |
| Stop atr multiple | 2.0 | Stop distance from entry, in ATR multiples |
| Fast ma period | 20 | Fast moving average period (direction filter) |
| Slow ma period | 60 | Slow moving average period (direction filter) |
| Rebalance bars | 24 | Bars between full re-allocation/resizing passes |
| Magic number | 20260904 | Magic number for orders opened by this EA |
| Slippage pips | 3 | Slippage tolerance, in pips |
| Max retries | 5 | Attempts per trade action before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: ATR · Risk & Lot Size · Moving Average · MT5 Expert Advisor · MQL5 Source Code