Daily and Max Loss Limit Guard MT4
- Utilities
-
Kazuma Uezono
MQL5 / MQL4 / Pine Script v6 developer and active trader.
Seller on the MQL5 Market (indicators for MT4/MT5).
Services:
- TradingView Pine Script to MT5/MT4 conversion (bar-by-bar matching, with tester report)
- MT4 to MT5 migration - Version: 1.2
- Activations: 5
Daily and Max Loss Limit Guard MT4 is an Expert Advisor for MetaTrader 4 that keeps an eye on the account equity and enforces the loss limits you choose. When the daily loss limit, the maximum loss floor or the optional daily profit target is reached, it removes pending orders, closes the open orders it is responsible for, and keeps closing any new order until the stop ends. On the chart, the panel uses the short name "Equity DD Guard".
What it is not: it does not open trades on your real or demo account, it does not give buy or sell signals, and it is not a trading system. It acts only after a limit has been reached, so it cannot stop losses from happening, and the final loss can go past the limit.
Below, "lock" means this stop state. It has nothing to do with hedging locks.
MT4 SPECIFICS (PLEASE READ FIRST)
- Closing speed: MT4 sends one order at a time and waits for the answer. In our tests each close or delete took about 0.3 s, so 30 orders need roughly 9 to 10 seconds. Prices can move during that time.
- Automatic initial capital reads the trade history that the terminal has loaded. Set the Account History tab to All History, or type the initial capital yourself. Otherwise the maximum loss is shown as NOT ARMED and closes nothing.
- While the EA is attached it switches off "Chart on foreground" for its chart so that the panel stays readable, and switches it back on when you remove the EA.
- Panel lines longer than about 62 bytes are cut and end with "~" (an MT4 text limit). Japanese text is cut earlier because each character uses 2 bytes.
- Turn on the AutoTrading button in the toolbar and tick "Allow live trading" in the EA settings. Without them the EA cannot close anything; the panel then shows the reason.
- All 34 inputs are in one list (MT4 has no input groups).
LIMITS AND TARGET
Daily:
- Loss limit and profit target, each off, an amount in the account currency, or a percent.
- The result and the percent are measured from the day-start balance (default), the day-start equity, or whichever is higher.
- Today's result = account equity now (closed trades + floating P/L of every open order) - day-start reference. Today's deposits and withdrawals are left out.
- The day can change on server time, UTC, New York or Central Europe time (with daylight saving time), Japan time or a fixed UTC offset, at any hour and minute.
- A daily stop lasts until the next day begins. If money was deposited today (for example on a new account), the daily percent uses the balance after that deposit.
Maximum:
- An amount or a percent of the initial capital, with a floor that is static, trails the highest closed balance, or trails the highest equity seen while the EA runs.
- The initial capital is typed in, or calculated as deposits minus withdrawals (optionally from a start date). Credit (bonus) is excluded from the equity.
- If the equity is already under the floor when you attach the EA, nothing is closed; the panel shows NOT ARMED until the equity has been above the floor once.
- This stop stays, also through restarts, until you change the maximum loss inputs.
WHEN A LIMIT IS HIT
- Pending orders are deleted before positions are closed, so none can be filled while the closing is in progress.
- What is closed: all orders of the account, or only chosen magic numbers (0 = manual trades), only chosen symbols, or both.
- During the lock each new order in that scope is closed or deleted when the EA finds it. The EA checks about four times per second.
- You can choose "warning only" instead; then nothing is closed.
- Out of the box: daily loss 4% of the day-start balance, maximum loss 8% static, closing on, whole account. Review these before you use a live account.
EXTRA CHECKS AND ALERTS
- Optional caps for the lot per order, the total lots and the number of open orders. Going over a cap gives a warning (default) or closes the newest orders over the cap.
- Early warning at 80% of a limit (changeable, 0 = off), a popup at a limit (on by default), and push notifications to the MetaTrader mobile app (optional).
- Panel in English or Japanese following the terminal language: status, today's result with limit and target, floor and room left, countdown to the new day, scope, open orders, and the reason if closing is not possible.
LIMITATIONS TO KNOW BEFORE BUYING
- A limit is a trigger, not a guarantee. Gaps (for example after the weekend), fast markets, slippage, requotes or rejected orders, a closed market and the one-by-one closing of MT4 can all push the loss past the limit. In one of our tests with a daily limit of -1,500 JPY, the account stopped at -1,890 JPY.
- The EA works only while MT4 is open and connected and AutoTrading is on. After you log in to another account, check the AutoTrading button again.
- Today's result covers the equity of the whole account: the floating loss of orders carried over from earlier days, other EAs and manual trades count even if they are outside the scope. The scope only chooses what gets closed.
- Editing any daily input (limit, target, reference, time zone, day start) removes the daily lock, and with a looser limit you can trade again on the same day. The EA leaves that choice to you.
- Editing the maximum loss inputs removes that lock and also restarts the trailing peak recorded while the EA ran.
- The trailing floor has no ceiling; it does not stop at the initial capital. Funded-account rules vary, so compare them with these settings yourself.
- If the EA was not running at the start of the day, the day-start equity is estimated from the day-start balance (shown with * on the panel).
- For about 3 seconds after starting, the EA reads the history and does not set a new lock. A lock saved earlier applies immediately.
- Use one copy per account. A second copy on another chart of the same terminal waits on standby. Copies in two different terminals on the same account cannot detect each other.
- The lock is stored in the terminal's global variables. Moving to another terminal, computer or virtual server starts without it.
- Other EAs can still open trades. During a lock each one is closed again, and each costs spread and commission.
- Strategy Tester: manual trading cannot be reproduced there, so the EA runs a demonstration that opens one small order on the chart symbol at intervals. It loses money on purpose so that you can see the stop at the limits; the tester report is therefore not the result of any trading method. After the maximum loss lock it stops opening orders. Nothing is saved to the terminal from the tester, and the demonstration never runs on a real or demo account. In the tester, New York and Central Europe day changes assume that server midnight is 17:00 New York time.
FIRST START
1. Drop the EA on one chart; the symbol does not matter.
2. Set the Account History tab to All History (or type the initial capital), then set the limits, the time zone of the new day and the scope.
3. Turn on AutoTrading, allow live trading, read the note on the panel and press OK. Practise on a demo account first.
PLEASE NOTE
- Neither a profit nor a maximum loss is promised; losses can exceed the limits.
- With a funded-account program, check its own rules (how the daily loss and the drawdown are calculated, when the day changes, whether such tools are allowed). The EA does not decide whether you follow them.
- Support by MQL5 message within 3 business days for installation, settings and bug reports. Questions about what or when to trade cannot be answered.
