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 · MT4 · v1.0 · Free
About Monthly Risk Budget Allocator
Monthly Risk Budget Allocator is a script for MetaTrader 4. It has 10 settings, such as Budget type, Budget money and Budget percent. MQL source code included.
Files in the download: MonthlyRiskBudgetAllocator.ex4, MonthlyRiskBudgetAllocator.mq4, MonthlyRiskBudgetAllocator.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Budget type | BUDGET_PERCENT | Budget type |
| Budget money | 500.0 | Monthly loss budget, account currency (BUDGET_MONEY) |
| Budget percent | 6.0 | Monthly loss budget, percent of start-of-month balance (BUDGET_PERCENT) |
| Daily allowance use percent | 50.0 | Percent of today's allowance to actually risk (buffer against a bad day) |
| Stop loss pips | 20.0 | Stop distance used for the suggested lot size |
| Magic filter | -1 | Magic number filter for loss tracking and force-close (-1 = every magic) |
| Current symbol only | false | Restrict tracking and closing to this chart's symbol |
| Enforce hard stop | true | Flatten and block once the whole month's budget is spent |
| Max retries | 5 | Attempts per close 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 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: Risk & Lot Size · MT4 Expert Advisor · MQL4 Source Code