Trend Following EN
- Индикаторы
-
Marian Beceanu
Atlas Enterprise Matrix:
https://www.mql5.com/en/market/product/183575?source=Site+Profile+Seller - Версия: 3.20
- Активации: 10
Complete description Trend Following
A mechanical trend following indicator, inspired by the style of John W. Henry (one of the pioneers of managed futures / CTA trading), built for MetaTrader 5. It combines a Donchian channel for identifying trend direction with an ATR-based trailing stop, filtered through ADX and higher-timeframe confirmation, all displayed through a complete, configurable visual dashboard.
Features:
- Donchian + ATR Trailing Stop trend system — trend direction is determined by breakouts of the Donchian channel (highest high / lowest low over N bars), while an ATR-based trailing stop protects the position and follows the price as the trend progresses.
- ADX signal quality filter — signals are validated only when trend strength (ADX) crosses a configurable minimum threshold, filtering out signals from sideways/directionless markets.
- Higher Timeframe confirmation — a signal is considered valid only if the trend on a larger timeframe (determined automatically, e.g. M15→H1, H1→H4, H4→D1, etc.) confirms the same direction, using two exponential moving averages (fast/slow).
- Automatically calculated Stop Loss & Take Profit — SL comes from the existing ATR trailing stop, while TP is projected using an independent ATR multiplier, in the direction of the current trend.
- Automatic Risk:Reward with configurable minimum threshold — the panel shows in real time the R:R ratio resulting from the calculations (TP distance / SL distance) compared against the minimum acceptable ratio set by the user, colored green/orange depending on compliance.
- On-chart dashboard with automatic scaling — a single input (font size) proportionally resizes the entire panel (title, signal, text, spacing), plus automatic scaling based on screen DPI — equally readable on a laptop, a 4K monitor, or a high-DPI screen.
- Real semi-transparent background (alpha blending) — the panel is drawn on an ARGB canvas, not simulated with a flat color, so the chart remains visible underneath the panel.
- Multi-channel alerts — pop-up Alert(), sound, and push notification to your phone on every new signal (BUY/SELL), without repeating alerts for the same bar/signal.
- Live performance statistics — average calculation time (microseconds) displayed in the panel, useful for checking resource impact.
- Optimized for performance — incremental updates of the auxiliary series (ATR/ADX) and throttling of panel text (only redraws what has changed), for minimal CPU usage even on charts with long history.
- Full parameter validation on startup — the indicator refuses to run with invalid settings and explains the error in the log (Experts log).
2. Explanation of each input
=== Trend Following System ===
- InpDonchianPeriod (default 20) — the number of bars used for the Donchian channel. When the closing price breaks the highest high / lowest low of the last N bars, the trend changes.
- InpATRPeriod (default 14) — the ATR period used to calculate the trailing stop distance.
- InpATRMult (default 3.0) — how many times ATR the stop is placed away from price. A higher value = a wider stop (fewer premature exits, but more risk per trade).
=== Signal Quality Filter ===
- InpADXPeriod (default 14) — the ADX period, used to measure the strength of the current trend.
- InpADXThreshold (default 20.0) — the minimum ADX level below which signals are ignored (market considered to lack a clear trend).
- InpUseHigherTF (default true) — enables/disables higher-timeframe confirmation.
- InpHTF_FastMA (default 50) — the fast moving average period, calculated on the higher timeframe.
- InpHTF_SlowMA (default 200) — the slow moving average period, on the higher timeframe. If the fast one is above the slow one → up trend confirmed, otherwise → down trend confirmed.
=== Stop Loss / Take Profit ===
- InpTPMult (default 6.0) — the ATR multiplier for the Take Profit distance from price (projected in the direction of the trend). With SL at 3×ATR and TP at 6×ATR, the theoretical R:R is 1:2.
- InpMinRR (default 2.0) — the minimum Risk:Reward ratio you want to consider acceptable. It's compared in the panel against the actual R:R, calculated from the real SL/TP distances.
=== Visuals & Alerts ===
- InpShowDashboard (default true) — shows/hides the panel on the chart.
- InpCorner (default CORNER_LEFT_UPPER) — the chart corner the panel is anchored to.
- InpPanelX / InpPanelY (default 12 / 20) — the panel's distance from the edges of the chosen corner (pixels, before scaling).
- InpEnableAlert (default true) — enables the Alert() pop-up on a new signal.
- InpEnableSound (default true) — plays a sound on a new signal.
- InpEnablePush (default false) — sends a push notification to your phone (requires MetaQuotes ID configured in the terminal).
- InpShowPerfStats (default true) — displays the average calculation time and current font size in the panel (useful for debugging/performance).
=== Text Size & Dashboard Scaling ===
- InpFontSize (default 9, between 6-24) — the panel's text size; the entire panel geometry (width, height, spacing) scales automatically and proportionally with this input, plus screen DPI.
3. Trading methods with this indicator
a) Classic trend following (breakout + trailing)
Enter when the BUY/SELL arrow appears (Donchian breakout confirmed by ADX and the higher timeframe), place your SL at the trailing stop level shown in the panel, and let the position run — manually moving the SL as the ATR Trailing Stop line advances. Exit when the line changes color (opposite signal) or price dictates otherwise.
b) Entry with R:R confirmation (more conservative)
Wait for the BUY/SELL signal, but only open the position if the R:R row in the panel is green (actual R:R ≥ InpMinRR). If it's orange, skip the signal or adjust InpTPMult/InpATRMult until the ratio becomes favorable. Useful for automatically filtering out signals with a poor risk/reward profile.
c) Fixed SL/TP at entry (set-and-forget)
At the moment of the signal, note the Stop Loss and Take Profit values from the panel and place the order with both levels fixed (not trailing). Simple, suitable for those who don't want to actively monitor the position.
d) Additional filtering with trend strength (ADX)
Only take signals where the "Trend strength (ADX)" row shows STRONG, ignoring WEAK/MODERATE, to catch only the highest-momentum moves — reduces the number of trades, but (potentially) increases the success rate per trade.
e) Strict multi-timeframe confirmation
Enable InpUseHigherTF and only trade when the "Higher-TF confirmation" row shows YES — filters out signals going against the larger trend, reducing false positives on short ranges.
f) Scalping/pyramiding on trend continuation
On smaller timeframes, add additional positions each time the trend remains active and ADX is rising, using the new trailing stop level as a common SL for all positions — a more advanced technique, with higher risk.
4. Disclaimer / Notes
- This indicator is a technical analysis tool, not a guarantee of profit. The signals generated (Donchian + ATR + ADX + HTF confirmation) reflect a mechanical trend-following methodology, but past performance (backtested or live) does not guarantee future results.
- Financial markets involve real risk of capital loss. No combination of parameters eliminates risk; use your own risk management (position sizing, capital at risk per trade) regardless of the InpMinRR/InpTPMult values.
- The SL/TP shown in the panel are calculated, not automatically placed — this file is an indicator, not an Expert Advisor; it does not open, modify, or close orders. The user must place trades and SL/TP levels manually (or through a separate EA).
- Demo account testing and backtesting in the Strategy Tester are recommended before live use, on the desired symbol/timeframe, to validate the default settings in your market context.
- Higher-timeframe confirmation requires sufficient historical data on that TF; on symbols/brokers with limited history, some signals may be temporarily unavailable (WARNING in the log).
- Push alerts require correctly configuring the MetaQuotes ID in the terminal; sounds require the alert2.wav file to be available in the terminal (included by default in MT5).
