Ledger Guard Prop Rule Enforcer MT5
- Utilities
-
Abdullah Uygar Tuna
IT professional focused on algorithmic trading, quantitative analysis and practical MetaTrader 5 tools. I publish what I test, including what does not work. - Version: 1.0
- Activations: 10
Ledger Guard enforces the risk rules of a prop firm challenge or funded account on your whole MT5 account. You enter the rules once: daily loss limit, maximum loss (static or trailing), profit target, and optional extras. Ledger Guard then watches equity on every tick and acts before the official limit is reached. It closes positions, deletes pending orders and locks the account against new trades until the rule allows trading again.
Ledger Guard never opens trades. It only closes, deletes and blocks. It works with manual trading and with any Expert Advisor on the same account.
What it does
Daily loss guard. The day reference can be balance, equity, or the higher of the two at your server day rollover. The limit can be a percent of the initial balance or of the day reference. If you attach it in the middle of a day, the day start balance is rebuilt from the deal history (deposits and withdrawals are excluded).
Maximum loss guard. Three models: static from the initial balance, trailing from the highest equity, or trailing from the highest end of day value. The trailing floor can stop at the initial balance.
Safety buffer. Ledger Guard acts at a line before the official limit (default 90 percent of the limit) and warns earlier (default 70 percent). You choose the buffer.
Breach actions. Alert only, close all and lock, or close losing positions worst first while keeping winners (it closes everything if the official line is touched).
New trades are blocked while locked. Any new position in scope is closed as soon as it appears, pending orders are deleted, and volume added to a netting position is taken back off.
Profit target lock and daily profit lock. Alert, block new trades, or close all and lock.
Weekend flatten. Close all or block new trades at a Friday cut-off time (server time).
News gate. Uses the economic calendar built into MetaTrader 5, with no web requests. Choose currencies (or the chart symbol), importance, and minutes before and after. Block new trades or close all before the window. If the calendar is not loaded, the panel says "not evaluated". It never shows "clear" without data.
Consistency helper. Shows how much profit today is allowed under a "best day may not exceed X percent" rule, either of total profit or of the profit target. Optional close and lock when today reaches the allowed amount.
Panic button. CLOSE ALL and LOCK DAY on the panel, with a two click confirmation.
Restart safe. Initial balance, peaks, day references and locks are saved to a file and restored after a terminal or VPS restart. A lock from the same day stays active.
Rule presets
Presets only fill in the rule values. Buffer, actions and scope stay yours. Rule shapes change from firm to firm and over time, so always check your firm's current rules and use Custom if they differ.
Classic two step: 5 percent daily, 10 percent static maximum loss.
Daily from the higher of balance and equity: 5 percent daily, 10 percent static.
One step trailing: 3 percent daily, 6 percent trailing equity (stops at the initial balance).
End of day trailing: 4 percent daily, 5 percent trailing from the highest day end (stops at the initial balance).
Custom: any values.
The panel
The panel shows daily loss room with the action line, maximum drawdown room and floor, today's result, progress to the profit target, the next news event and countdown, consistency room, the weekend countdown, and open, closed and blocked counts. The status pill shows ARMED, WARNING, LOCKED or ALGO OFF. A red banner shows the lock reason and when it ends. The panel scales with screen DPI and can be minimised.
Scope
Limits are always measured on the whole account equity, because that is what a firm measures. Scope only decides what Ledger Guard may close: all positions, listed magic numbers (with or without manual trades), or the chart symbol only.
Important limits, please read
MetaTrader 5 has no way to stop an order before it is sent. Ledger Guard cannot stop the click itself. A new trade opened while locked is closed immediately after it fills, usually on the next tick, so it can cost spread and a small amount of slippage.
Closing takes time. Price gaps, weekend gaps, fast news moves, slippage and rejected requests can push the result past your buffer and even past the official limit. A larger buffer gives more room. No tool can guarantee that a limit is never breached.
Ledger Guard must be running to act. Keep the terminal (or VPS) on, Algo Trading enabled, and the tool attached to one chart. If Algo Trading is off, the panel shows ALGO OFF and nothing can be closed.
Set the day rollover time in your broker's server time, matching your firm's day reset. Set the initial balance if the account had earlier deposits or trades.
Your firm calculates its own numbers on its own server. Ledger Guard rebuilds them from your account data, and small differences are possible (for example equity at the start of the day when the tool was not running).
Run one copy per account. A second copy on the same account stays idle and says so.
Other details
Native MQL5 only. No DLL, no web requests, no account binding. Pop-up, push and sound alerts. A CSV event log in MQL5\Files\LedgerGuard records every action. Other Expert Advisors can read the global variable LGUARD.ACCOUNT.LOCKED (where ACCOUNT is your account number) before they send orders.
Hedging and netting accounts are supported. Works on forex, metals, indices and other symbols your broker offers.
Demo in the Strategy Tester: the panel appears only in visual mode, and Ledger Guard acts only when there are trades. In the tester the economic calendar is not available, so the news row says so.
Ledger Guard is an independent tool. It is not made by, endorsed by, or connected to any prop firm. It is a risk control aid and does not promise any trading result. Questions are welcome in the comments.
