Loading…

Monthly Risk Budget Allocator

A monthly risk budget is easy to state - "I will not lose more than 6% of my account this month" - and hard to translate into what that means for today's trade. This EA does the translation on every tick: it sums realised loss from the start of the server month plus today's floating loss, subtracts that from the budget, divides what is left by the calendar days remaining in the month, and shows the lot size that daily share buys at whatever stop distance the trader plans to use. The split is even across calendar days, not trading days. That is a deliberate simplification: a trading-day split would need to guess which future days are trading days, and getting that wrong would either overstate or understate the real daily allowance. An even calendar split never needs to guess, and the trader still sees the exact remaining budget and days count on the panel to judge for themselves. The budget itself is measured against the balance recorded at the start of the server month, not the live balance - the same reasoning as a daily loss guard. A percent budget compared against a shrinking live balance would tighten itself mid-month in a way that has nothing to do with the trader's original 6% decision. The suggested lot size comes from tick value and tick size, never a hardcoded pip value or contract size, so it stays correct on metals, indices and JPY crosses as well as plain forex pairs. If the daily allowance times the "use percent" input is smaller than the broker's minimum lot at the configured stop distance, the panel says so plainly rather than silently suggesting a lot size that overrisks the remaining budget. When the optional hard stop is enabled and the month's entire budget is spent, the EA closes every position matching its magic and symbol filters and marks the rest of the month as blocked. Exactly as with a daily guard, it cannot reach into another program's OrderSend call to refuse a trade in advance - the block is a chart comment and journal statement that new trades are not safe to place, backed by repeated flattening of anything that appears anyway. Notes and limitations The daily allowance is a planning number, not a live order-blocking mechanism - it does not and cannot stop another EA or a manual click from placing an oversized trade. Only the hard-stop flatten, when enabled, takes an enforcement action, and only once the whole month's budget is gone, not progressively through the month. Running this on a demo first to confirm the budget maths matches your own expectations is worthwhile before relying on it live. Server month rollover follows the trade server's clock, which may not match the calendar month your funding programme or personal accounting uses if your broker's server timezone differs from your own.

Expert advisor · MT5 · v1.0 · Free

About Monthly Risk Budget Allocator

Monthly Risk Budget Allocator is an expert advisor (trading robot) for MetaTrader 5. It can size trades from your balance and risk percent. It has 10 settings, such as Budget type, Budget money and Budget percent. MQL source code included.

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

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

Settings

SettingDefaultWhat it does
Budget typeBUDGET_PERCENTBudget type
Budget money500.0Monthly loss budget, account currency (BUDGET_MONEY)
Budget percent6.0Monthly loss budget, percent of start-of-month balance (BUDGET_PERCENT)
Daily allowance use percent50.0Percent of today's allowance to actually risk (buffer against a bad day)
Stop loss pips20.0Stop distance used for the suggested lot size
Magic filter-1Magic number filter for loss tracking and force-close (-1 = every magic)
Current symbol onlyfalseRestrict tracking and closing to this chart's symbol
Enforce hard stoptrueFlatten and block once the whole month's budget is spent
Max retries5Attempts per close 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: Risk & Lot Size · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria