Watch how to download trading robots for free
Find us on Facebook!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Experts

Equity Guard - expert for MetaTrader 5

Views:
39
Published:
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

Equity Guard protects the whole account, not a single strategy. Attach it to any one chart and it watches account equity every second.


When a limit is hit, it:
- closes open positions (optional),
- deletes pending orders (optional),
- keeps the account flat until the next trading day: any position opened while locked (manually or by another EA) is closed again,
- sends a popup alert and/or push notification to MetaTrader mobile.

Limits (each one can be turned off with 0):
- Max daily loss, % of the day-start base. Base can be equity, balance or the higher of the two (the way most prop firms calculate it).
- Max daily loss, money in account currency.
- Daily profit lock, % to stop trading after a good day.
- Max drawdown from equity peak, %. Optionally stays locked until you reset it manually.

Details:
- Day boundary is broker server midnight.
- Day-start base, equity peak and lock state are stored in terminal Global Variables, so they survive EA restart, timeframe change and terminal reboot. Tester runs use separate variables and never touch the live state.
- Filling mode (IOC/FOK/RETURN) is detected per symbol, so closing works on any broker.
- Magic filter: -1 = all trades, 0 = manual trades only, or a specific EA's magic number. Note: limits are always calculated on account equity.
- To unlock manually: set "Reset lock and peak now" to true, press OK, then set it back to false.

Limitations:
- The guard reacts after equity crosses the limit. A price gap or fast market can make the final loss larger than the limit (in testing on gold with a 1.5% limit, the worst lock happened at 2.6% because of a market gap).
- Positions cannot be closed while the market is closed. The guard keeps retrying until the session opens.

- Algo Trading must be enabled in the terminal.


EquityGuard

Break-even and Trailing Stop Manager Break-even and Trailing Stop Manager

Moves the stop loss to break-even (with locked profit) and trails it by a fixed distance or an ATR multiple. Never opens or closes trades, the stop loss only moves forward.

Trade Cost Meter Trade Cost Meter

Shows the real cost of a trade on the current symbol (spread, commission, swap) and which share of your risk (R) it takes on every timeframe from M1 to D1.

Accelerator Oscillator (AC) Accelerator Oscillator (AC)

The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.

MACD Signals MACD Signals

Indicator edition for new platform.