TradeSentinel
- Uzmanlar
-
Channaphat Yamuangmorn
Hello! I am an experienced Algorithmic Trader and MQL5 Developer based in Thailand. I specialize in designing and developing robust Expert Advisors (EAs) and automated trading systems for MetaTrader 5. - Sürüm: 6.11
- Etkinleştirmeler: 5
Here is the technical description of the Trade Sentinel EA for the MQL5 Market listing.
Trade Sentinel is an automated trading system designed for MetaTrader 5, combining a trend-following momentum strategy with a dynamic grid recovery system and built-in capital protection features.
The expert advisor utilizes three core mechanisms to manage positions:
-
Entry Filter and Trend Determination The system uses an Exponential Moving Average filter on the one-minute chart to identify the institutional trend direction. Buy orders are executed only when the previous bar closes above the EMA 200 line, while sell orders are restricted to environments where the price is below this moving average. To minimize market exposure during typical periods of high volatility, the advisor features a structural cooldown mechanism that pauses new cycle generation until the start of the next hourly candle once all current market positions have successfully cleared.
-
Volatility-Based Grid Recovery When a position moves into drawdown, the advisor initiates a grid recovery sequence. Instead of employing rigid, static point gaps, the system evaluates real-time market volatility through the Average True Range indicator. The distance between recovery orders expands or contracts automatically based on ATR readings. This methodology helps prevent the rapid accumulation of excessive lot sizes during sudden, strong market impulses.
-
Dynamic Profit Allocation and Capital Protection The advisor incorporates a tiered profit retention system designed to secure gains and manage drawdown. If an initial position moves directly into profit, the gains are allocated entirely to the account balance. However, if a grid recovery cycle is activated, a configured percentage of closed position profits is moved into an internal tracking variable. This reserved capital is dynamically used to target and liquidate the individual order carrying the highest negative floating loss within the cycle, reducing margin requirements without requiring a complete market reversal. Additionally, the software features an automated daily profit target calculated from the initial equity of the day, as well as an account-wide maximum drawdown circuit breaker.
Here is the technical explanation of the 10 percent drawdown alert mechanism.
The drawdown alert system operates through three primary stages within the code:
-
Parameter Configuration The system relies on an input variable named DD_Warning_Level_Pct, which is configured to 10.0 by default. This establishes the baseline threshold for the alert.
-
Real-Time Calculation and Logic Every time the market moves and a new tick is received, the OnTick function calculates the current account drawdown. It subtracts the current equity from the balance, divides by the balance, and multiplies by 100 to get a percentage.
The system then checks if this calculated drawdown is greater than or equal to the 10 percent threshold. To prevent the expert advisor from spamming alerts every millisecond the condition is met, a boolean tracking variable named ddWarningSent is utilized. When the drawdown hits 10 percent for the first time, the system triggers the alert and immediately changes this variable to true. This locks the alert mechanism. The system will only reset this lock back to false when the drawdown recovers and drops below a safe threshold, which is coded as 80 percent of the warning level.
-
Execution via WebRequest Once the logic condition is satisfied, the EA calls a custom function named SendTG. This function constructs a JSON payload containing your specific Chat ID and the warning message. It then uses the native WebRequest function in MQL5 to send an HTTP POST request directly to the Telegram Bot API URL using your Bot Token. This process pushes the notification immediately to your Telegram application.
