Trade Guardian: Advanced Stop Loss and Drawdown Management for MT4/MT5
Info
The Trade Guardian: Advanced Stop Loss and Drawdown Management for MT4/MT5 is a Expert Advisor for MetaTrader 5 that trade guardian is a defensive expert advisor designed to enhance your trading security. It actively monitors your existing positions and intervenes when predefined risk rules are breached.
Usage
This tool is typically used for automated trading on major forex pairs and gold.
Platform
This Expert Advisor works exclusively on MetaTrader 5 (both build 600+ and newer versions).
Setup
Place the downloaded file in MQL5/Experts folder via File ? Open Data Folder in MetaTrader 5.
How to Install and Use Trade Guardian: Advanced Stop Loss and Drawdown Management for MT4/MT5
1. Installation: Open the "File" menu, select "Open Data Folder," navigate to MQL/Experts, paste your file, and restart the terminal.
2. Activation: Drag the EA from the Navigator onto a chart, ensure "Allow live trading" is checked in the Common tab, and verify the AutoTrading button is green.
3. Optimization: Right-click your chart, choose "Expert List," click "Properties" to adjust inputs, and save your preferred setup as a set file for future use.
4. Maintenance: Regularly check the "Experts" tab in the terminal window to monitor trade logs and potential execution errors.
Frequently Asked Questions
Q: Why is my EA not opening trades? A: Check the "AutoTrading" button, ensure "Allow live trading" is enabled, and verify your broker allows automated trading on your account type.
Q: Can I run multiple EAs on one chart? A: No, each chart can only host one active EA; however, you can open multiple charts for different currency pairs to run several EAs.
Q: What does the "smiley face" icon mean? A: A smiley face in the top-right corner of the chart indicates the EA is successfully running; a frowny face means it is disabled.
What this tool does
Trade Guardian is a defensive Expert Advisor designed to enhance your trading security.
Typical Use Case
This Expert Advisor excels in automated trading and technical analysis on MetaTrader 5.
Compatible Platform & Setup
This Expert Advisor works on MetaTrader 5. Place the file in the MQL5/Experts folder and restart the terminal.
Description & Settings
Related: Partial Close Multi TP Manager for MetaTrader 5 - another powerful expert for MetaTrader 5 traders.
Trade Guardian is a defensive Expert Advisor designed to enhance your trading security.Also recommended: Strategy Tester Report Parser for Deals and Trades - similar expert with strong performance on MetaTrader 5.
It actively monitors your existing positions and intervenes when predefined risk rules are breached. It does not open trades itself.
The EA offers three core functionalities, each independently controllable:
1. Missing Stop Loss Enforcement:
The EA scans open positions for missing stop losses. Using `InpEnforceStopLoss`, it automatically sets a stop loss based on the `InpATR_Mult` multiplier of the chart's Average True Range (ATR) with `InpATR_Period` lookback period. The stop loss is placed on the correct side of the entry price and adheres to `InpMinStopPoints` or the broker's minimum stop level.
2. Daily Loss Limit:
`InpMaxDailyLossPct` sets a daily loss limit calculated as a percentage of the account balance at the beginning of the trading day. This dynamic limit adjusts to account fluctuations, refreshing automatically at the start of each new day.
3. Re-arming Total Drawdown Limit:
`InpMaxTotalDDPct` monitors drawdown from the equity peak. To address the common issue where a drawdown limit permanently disables protection, `InpCooldownHours` introduces a re-arming mechanism. After the specified cooldown period, the equity peak is reset to the current equity, the protection guard is re-armed, and normal operation resumes. Re-arming events are logged for transparency.
Configuration Options:
- `InpCurrentSymbolOnly`: Restricts monitoring to the current chart's symbol.
- `InpMagicFilter`: Filters positions by magic number (-1 monitors all positions).
- `InpCloseOnBreach`: Determines whether to close positions or just issue alerts when a limit is hit.
- `InpAlertOnBreach`: Activates terminal alerts upon limit breach.
- `InpPanel`: Displays a status panel on the chart showing current daily loss, drawdown from peak, and guard status.
The interface clearly illustrates the daily loss limit, measured against the day's opening balance, and the total drawdown limit, measured from the equity peak. It also shows the cooldown period that allows the peak to be reset and the guard to re-arm.
This tool is designed for traders seeking robust risk management and protection against excessive losses in their MetaTrader 4 and MetaTrader 5 accounts.
You may also like: Programmatically Attach Expert Advisors with Custom Inputs to MetaTrader 5 Charts - excellent alternative for expert users on MetaTrader 5.
Source Code
#property copyright "RobotFX"
#property link "https://robotfx.org"
#property version "1.00"
#property description "This code is educational. Feel free to use, modify and upgrade as you wish. Visit ROBOTFX.ORG for professional trading tools"
#include <Trade\Trade.mqh>
CTrade trade;
input group "=== Scope ==="
input bool InpCurrentSymbolOnly = false;
input long InpMagicFilter = -1;
input group "=== Missing stop loss ==="
.......
⚠ Limitations & Risk Warning
- This tool is provided for educational and testing purposes only.
- Past performance does not guarantee future results.
- Trading involves substantial risk of loss. Use on a demo account first.
- Results may vary depending on market conditions, broker, and settings.
- We recommend thorough backtesting and forward testing before using with real funds.