Loading…

Beta Weighted Exposure Balancer

0.50 lots of EURUSD and 0.50 lots of XAUUSD are not remotely the same size bet. Gold routinely moves several times the dollar volatility of a major currency pair per lot, and that ratio itself drifts as volatility regimes change - a fixed "gold beta is roughly 3" rule of thumb from a calmer period can be badly wrong in a more volatile one. Sizing everything the same way in lots, or applying a stale hand-picked multiplier, quietly lets one symbol dominate an account's real risk while the position list looks balanced. This EA computes, for every open position, that position's dollar ATR - its Average True Range converted to money using the symbol's own tick value and tick size, scaled by the position's actual lot size - and expresses it as a multiple of what one lot of a chosen reference symbol currently carries in the same terms. That multiple is the risk unit: two positions each showing 1.0 risk unit are genuinely comparable exposures right now, regardless of what symbol they are on or what price scale they quote in. A position over the configured InpMaxRiskUnitsPerPosition cap is trimmed, not closed outright - a partial close brings it proportionally back down to exactly the cap, so the trader stays in the trade at a size that matches everything else instead of being forced flat because the position happened to be sized in the wrong units for the instrument it was on. Notes and limitations - This EA never opens a position and never fully closes one on its own initiative - the only action it takes is a partial close that reduces an oversized position down to exactly the configured cap. - ATR needs InpAtrPeriod bars of history for a symbol before it returns a usable value; a symbol just added to Market Watch may show "waiting" in the panel briefly while that history loads. - Risk units are a volatility-normalised size measure, not a correlation or directional-exposure measure - two positions can each be within the cap and still be pointed the same direction on correlated symbols. Pair this with a correlation-aware tool if that matters to you. - With InpAutoTrim off, this becomes a pure monitor.

Expert advisor · MT5 · v1.0 · Free

About Beta Weighted Exposure Balancer

Beta Weighted Exposure Balancer is an expert advisor (trading robot) for MetaTrader 5 based on ATR. It can size trades from your balance and risk percent. It has 8 settings, such as Reference symbol, Atr period and Max risk units per position. MQL source code included.

Files in the download: BetaWeightedExposureBalancer.ex5, BetaWeightedExposureBalancer.mq5, BetaWeightedExposureBalancer.txt.

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

Settings

SettingDefaultWhat it does
Reference symbolEURUSDReference symbol - one risk unit = one lot of this symbol's current dollar ATR
Atr period14ATR period, applied on this chart's timeframe for every symbol involved
Max risk units per position2.0Cap on reference-equivalent risk units any single position may carry
Magic filter-1Magic number filter, -1 = watch every magic number
Auto trimtrueActively trim a breaching position down to the cap; false = warn only
Slippage pips5Slippage tolerance for the trim close, in pips
Max retries5Attempts per trim 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 5 open File → Open Data Folder, then go to MQL5 → Experts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 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: Gold (XAUUSD) · ATR · Risk & Lot Size · EURUSD · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria