Voir comment télécharger gratuitement des robots de trading
Retrouvez-nous sur Facebook !
Rejoignez notre page de fans
Un script intéressant ?
Poster un lien vers celui-ci -
laisser les autres l'évaluer
Vous avez aimé le script ? Essayez-le dans le terminal MetaTrader 5
Experts

Daily Loss Guard - daily loss and total drawdown limits for funded / prop-firm accounts - expert pour MetaTrader 5

Jefry Francisco Rodriguez Campos
Jefry Francisco Rodriguez Campos
MQL4/MQL5 developer - Expert Advisors, indicators and strategy validation
I build clean, well-tested Expert Advisors and indicators for MetaTrader 4 and 5, with a focus on rule-based strategies and solid risk management.
What I can do for you:
Vues:
141
Note:
(1)
Publié:
MQL5 Freelance Besoin d'un robot ou d'un indicateur basé sur ce code ? Commandez-le sur Freelance Aller sur Freelance

What it does

Daily Loss Guard is a risk-protection utility. It does not trade: it supervises the whole account (all EAs and manual trades) and reacts when one of two loss limits is reached.

Daily Loss Guard panel

Limit How it is measured
Daily loss Start-of-day base minus current equity. The base is the balance or the equity at the start of the trading day (your choice). Limit in % of the base or in money.
Total drawdown Static: reference balance minus current equity (reference = the value you enter, or the balance when the EA first started). Trailing: highest equity reached minus current equity. Limit in % or in money.

Equity includes floating profit and swap, so a position that is deep in the red counts before it is closed.

When a limit is touched

  1. Every open position is closed and every pending order is deleted (only those matching the optional filter).
  2. The account is locked until the next trading day (the day-reset time is configurable). While locked, any new position or order is closed or deleted again, immediately after the trade event and also on every timer tick.
  3. If a close fails (requote, no connection, market closed), it is retried several times in the same pass and then on every following tick until nothing is left.
  4. On the next trading day the lock is released and the daily base is taken again. The total-drawdown limit is checked again at once: if the account is still beyond it, the guard locks again.

Early warning

At a configurable percentage of a limit (80% by default) the EA writes to the Experts log, shows an Alert and, optionally, sends a push notification. The same alerts are sent when a limit is hit, and when AutoTrading is switched off (the guard cannot close trades without it).

Panel

A small panel on the chart shows the status (ACTIVE / WARNING / BLOCKED until ...), today's profit or loss, the daily limit with the margin left, and the total drawdown with the margin left. Light or dark theme, any corner. The panel never shows the account number, name or broker.

Inputs

  • Daily loss: enable, percent or amount, value, base (balance or equity at the start of the day).
  • Total drawdown: enable, percent or amount, value, static or trailing, static reference balance.
  • Trading day: reset hour and minute in broker server time.
  • Early warning: percentage, Alert, push.
  • Filter: magic numbers and symbols (comma separated, empty = everything).
  • Closing: attempts per pass, pause between attempts, maximum slippage.
  • Panel: show, corner, offsets, font size, dark theme.
  • State: "forget the saved state at start".
  • Strategy Tester demo: random trades to try the guard (ignored outside the tester).

Notes

  • The limits always use the equity of the whole account. The filter only decides which positions and orders are closed and blocked; if you filter, other trades keep running and keep counting in the equity.
  • The symbol filter compares exact symbol names, as they appear in the Market Watch (including any broker suffix).
  • If the EA is started in the middle of a day it rebuilds the balance at the start of the day from the deals of that day. With the equity base this is an estimate (floating profit at the start of the day cannot be known), and the panel marks it as "est." until the next day.
  • Deposits and withdrawals are not trading results: they are not counted when the start-of-day balance is rebuilt.
  • State (day base, lock, highest equity, reference balance, warning flags) is saved in global variables of the terminal, per account. Terminal global variables are deleted by the terminal after four weeks without access.
  • The guard needs AutoTrading enabled and the market open to be able to close trades. It cannot act while the terminal is closed or disconnected; check the rules of your prop firm, which may measure the limits differently (server time, balance or equity, trailing or static).
  • It is a protection tool, not a guarantee: gaps, slippage and a closed market can make the final loss larger than the limit.
  • Not financial advice; it reports and reacts to numbers, it does not predict anything.

Try it in the Strategy Tester

Switch on "Open random trades to try the guard" in the Strategy Tester (any symbol, any timeframe, a small daily limit such as 1%). The EA opens trades with a fixed lot, hits the limit, closes everything, keeps closing the trades the demo keeps opening during the locked day and releases the lock on the next day. It also checks, once, that the saved state can be written and read back. Use only the tester or a demo account to try it.

Testing

Run in the Strategy Tester (EURUSD M15, 19-22 October 2026, demo mode on, 2% daily limit, warning at 70%): the early warning fired at 70% of the limit, the limit was hit and every position and pending order was closed or deleted at once, the trades the demo mode kept opening during the locked day were closed again each time, the lock was released at the start of the next trading day, and the saved state passed the write / read-back check. In one case, with demo positions carried over midnight, the daily loss was already well past the limit at the first check of the new day: the guard locked and closed at once, which shows why the limit is a protection, not a guarantee.

Trade Journal Exporter - closed trades to CSV, one row per position, with MFE/MAE, R multiple and session Trade Journal Exporter - closed trades to CSV, one row per position, with MFE/MAE, R multiple and session

Exports your closed trade history to a CSV file with one row per position (not per deal), ready for Excel, Python or any journal. Each row has ticket, symbol, magic number, comment, side, volume, entry and exit time and price, duration, initial SL and TP when known, gross profit, commission, swap, net result and R multiple. It also calculates MFE and MAE (best and worst price reached while the trade was open, in points and in money) from the M1 bars between entry and exit, plus the entry session (Asia, London, New York) and weekday. Filter by magic number (lists and ranges) and symbol (wildcards), pick the period, the column separator (; or ,) and the decimal mark, and save to MQL5\Files or the common folder. Tested on hedging accounts and in the Strategy Tester (netting logic included; feedback welcome), where the file is written when the test ends. Read-only: it never opens, modifies or closes a trade. No DLLs, no web requests.

Xander Grid RSI Gold Xander Grid RSI Gold

XAUUSD grid EA that opens a basket when RSI leaves oversold or overbought on a closed candle, adds levels with a lot multiplier and closes the basket at a money or points target. Open source code.

Candle Pattern Stats - engulfing, pin bar and inside bar with a rolling historical hit rate Candle Pattern Stats - engulfing, pin bar and inside bar with a rolling historical hit rate

Marks bullish and bearish engulfing, bullish and bearish pin bar and inside bar patterns with arrows, using closed bars only, so nothing repaints. The definitions (wick and body proportions, minimum bar size in ATR) are inputs, with an optional EMA trend filter. For each pattern a small panel shows a rolling historical statistic: the share of the last N resolved cases where price moved X ATR in the pattern direction before moving Y ATR against it, together with the number of cases. X, Y, N and the waiting time are inputs. The numbers describe what happened on your chart history; they do not predict the next trade. Optional alerts on closed bars (popup, push, sound). 20 buffers (signal, hit rate and sample size per pattern) can be read with iCustom(). Uses prev_calculated, deletes its chart objects when removed. Read-only: it never trades. No DLLs, no web requests.

Session High Low Alerts - Asia, London and New York session highs and lows with non-repainting break alerts Session High Low Alerts - Asia, London and New York session highs and lows with non-repainting break alerts

Draws the high and low of the Asia, London and New York sessions as boxes or lines extended to the end of the day, with configurable session hours and a server time zone adjustment. Optional previous day and previous week high/low. When a CLOSED bar breaks the high or low of a session that has already finished, it can raise a popup alert, a push notification and/or a sound, once per level per day. Alerts are evaluated on closed bars only, so they do not repaint. The 10 levels are exposed in indicator buffers, so an Expert Advisor can read them with iCustom(). It recalculates only new bars, works on any timeframe up to H1, and deletes all its chart objects when removed. Read-only: it never opens, modifies or closes a trade. No DLLs, no web requests.