Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

Metatrader 5 Expert Advisor | Trade Guardian - stop loss watchdog and drawdown limiter that re-arms | MQL5 …

Discover expert developed MetaTrader tools that can complement professional solutions.

Trade Guardian is a defensive Expert Advisor. It never opens a trade. It supervises the positions you already have and steps in when a risk rule is broken.

It does three things, and each one can be switched off on its own. Closing positions is disabled by default, so you can attach the EA to a live chart and let it only warn until you trust it.

1) Missing stop loss. On every timer tick the EA walks the open positions and finds the ones with no stop loss. With InpEnforceStopLoss it attaches one at InpATR_Mult times the ATR (period InpATR_Period) of the chart timeframe, on the correct side of the entry, and never closer to the price than InpMinStopPoints points or the broker minimum stop level. Stops are only placed on the chart symbol, because the ATR handle belongs to the chart.

Protect profits effectively with the smart Trailing Stop Expert Advisor. Advanced trailing options for MT4/MT5. See it in action.

2) Daily loss limit. InpMaxDailyLossPct is measured against the balance recorded at the opening of the trading day, so the limit follows the account instead of drifting away from a fixed starting figure. The reference is refreshed automatically when a new day begins.

3) Total drawdown limit that re-arms. InpMaxTotalDDPct is measured from the equity peak. A peak-referenced limit has a well known failure mode: once it fires, equity can never climb back to a frozen peak, so the guard stays latched forever and the account is dead. InpCooldownHours solves it. After the given number of hours the peak is rebased to the current equity, the guard re-arms and normal work continues. The rebase is written to the log, so you can see exactly when it happened.

Scope. InpCurrentSymbolOnly restricts the guard to the chart symbol, InpMagicFilter restricts it to one magic number (-1 guards every position). When a limit is hit, InpCloseOnBreach decides whether the guarded positions are closed or only reported, InpAlertOnBreach raises a terminal alert, and InpPanel draws a small status panel on the chart with the current daily loss, the drawdown from the peak and the state of the guard.

The picture below shows the two limits: the daily one measured from the day's opening balance, the total one measured from the equity peak, and the cooldown after which the peak is rebased and the guard re-arms.

Image for Trade Guardian - stop loss watchdog and drawdown limiter that re-arms

Build better strategies with RobotFX professional tools – check them out.

76947

Best MetaTrader Indicators + Profitable Expert Advisors