Loading…

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 · MT4 · v1.0 · Free

About Volatility Budget Allocator

Volatility Budget Allocator is an expert advisor (trading robot) for MetaTrader 4 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.ex4, VolatilityBudgetAllocator.mq4, VolatilityBudgetAllocator.txt.

Trading robots can lose money. Check every setting and test on a demo account before using real funds.

Settings

SettingDefaultWhat it does
Symbols listEURUSD,GBPUSD,USDJPY,AUDUSD,USDCADComma-separated symbols to allocate across
Target daily risk percent2.0Total portfolio risk budget, percent of equity, split across all symbols
Atr period14ATR period used to estimate each symbol's volatility and stop distance
Stop atr multiple2.0Stop distance from entry, in ATR multiples
Fast ma period20Fast moving average period (direction filter)
Slow ma period60Slow moving average period (direction filter)
Rebalance bars24Bars between full re-allocation/resizing passes
Magic number20260904Magic number for orders opened by this EA
Slippage pips3Slippage tolerance, in pips
Max retries5Attempts per trade action before giving up
Retry wait ms500Pause between attempts, milliseconds

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Experts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: ATR · Risk & Lot Size · Moving Average · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria