Gold Smart Trend Predictor
- Indicadores
- Denis Novoselov
- Versão: 1.0
- Ativações: 5
A multi-factor trend indicator for XAUUSD on the H1 timeframe. The script combines a moving-average stack, an ADX gate, a stochastic momentum check, and a higher-timeframe alignment filter into a single decision rule. When all components agree, the indicator marks a regime as bullish or bearish. When they disagree, the indicator stays neutral and recommends no action.
The goal is to give the trader a clear binary readout (signal or no signal) on a forecast horizon of about 10 hours, together with a measured stop-loss and take-profit level scaled by current volatility. The script does not place trades. It is an analytical aid for discretionary or semi-automated trading.
Overview
The engine computes the following on every closed bar:
· A trend stack consisting of a fast/slow EMA cross, an ADX threshold check, and a 7-EMA ribbon ordering test
· A stochastic K vs D agreement check on the same timeframe
· A long-term EMA alignment used as a daily-timeframe proxy on the H1 chart
A bullish regime starts only when all three components agree on the up direction on a closed bar. A bearish regime starts only when all three agree on the down direction. Any partial agreement keeps the indicator in a neutral state.
Each regime start is reported as a single signal and is not changed retroactively (anti-repaint design - all values are read from closed bars only, never from the forming bar).
How it works
Trend stack The fast EMA and slow EMA define the primary trend direction. The ADX value gates the signal so the script does not trigger in low-volatility periods. The 7-EMA ribbon (Fibonacci periods 8, 13, 21, 34, 55, 89, 144) must be ordered consistently for at least 6 of 7 adjacent pairs to confirm trend strength.
Stochastic agreement The fast stochastic %K must be above the %D line for a bullish regime, and below %D for a bearish regime. This adds a momentum requirement on top of the trend structure.
Higher-timeframe alignment A long EMA on the H1 chart (period 504, equivalent to a daily EMA21) is compared to a longer EMA (period 1320, equivalent to a daily EMA55). For a bullish regime, the fast must be above the slow, and the close must be above the fast. The bearish case is mirrored. This prevents counter-trend signals against the higher-timeframe direction.
Combined decision A regime is set to bullish (+1), bearish (-1), or neutral (0) on each closed bar. A regime start is detected when the state changes from non-bullish to bullish or non-bearish to bearish. Each regime start is the input to the alerting and journaling modules.
On-chart output
Forecast visualization On a regime start, the script draws 10 phantom candles to the right of the last real bar, oriented in the signal direction, plus a dashed envelope (conformal channel) that widens as q*sqrt(h). The channel is always shown, even in the neutral state, to indicate the volatility range. Phantom candles are shown only when an active signal exists.
History arrows For the configured lookback window (default 30 days), each historical regime start is marked with a small up or down arrow under or above the entry bar. This lets the trader review past signals at a glance.
Risk lines When a signal is active, three horizontal lines are drawn: an entry reference line at the current price, a stop-loss line, and a take-profit line. Both stop and target are scaled by ATR (default coefficients are 4.771 and 5.787 - giving a 1:1.21 reward-to-risk ratio).
Cockpit dashboard A panel in the bottom-right corner shows the current state, ATR, recommended stop and target prices in account currency, recommended lot size for a chosen risk percent, the reward-to-risk ratio, and live performance statistics computed on the trader's own data over the lookback window. Live statistics include the number of trades the indicator has tracked, the win rate among decided trades, and the profit factor proxy. If fewer than 5 trades have been recorded so far, the dashboard displays a "need more data" notice instead of a number.
Alerts
Three alerting channels are available:
· MetaTrader popup window (Alert)
· Sound file playback
· Telegram message via WebRequest
The Telegram channel requires the trader to whitelist api.telegram.org in Tools - Options - Expert Advisors and to provide a bot token and chat id in the inputs. The script verifies the token at startup and shows a status message on the chart if the configuration is incomplete.
Each regime start produces at most one alert per bar, regardless of how many ticks are processed.
Backtest reference
The default ATR coefficients and the trend-stack thresholds were calibrated on XAUUSD H1 historical data from January 2020 through April 2026.
Backtest results (TEST out-of-sample window, 2025 - April 2026):
· Win rate: 65.0% on 590 setups
· Profit factor: 2.06
· Average setups per year: about 278
Backtest results across the full 6.3-year window:
· Win rate: 55.6% (1762 setups)
· Profit factor: 1.36
· Maximum drawdown: 14.97%
These numbers are backtest results, not live trading results. The strategy works best in trending market regimes and tends to under-perform during prolonged sideways consolidation. Past performance does not guarantee future results.
Inputs
Forecast Visualization
· InpForecastBars - number of phantom bars projected forward (default 10)
· InpShowPhantom - toggle phantom candles
· InpShowChannel - toggle conformal channel
· InpShowDashboard - toggle the cockpit panel
· InpShowJournal - toggle the live statistics journal
· InpShowHistoryArrows - toggle history arrows
· InpHistoryDays - lookback window in days for arrows and live stats (default 30)
Risk Management
· InpShowRiskLines - toggle SL/TP/Entry horizontal lines
· InpRiskPct - account risk percent used in lot-size suggestion (default 1.0)
· InpShowPositionSize - toggle the lot-size row in the dashboard
Alerts
· InpAlertSound, InpAlertPopup, InpAlertTelegram - per-channel toggles
· InpTelegramToken, InpTelegramChatId - Telegram credentials
· InpAlertSoundFile - sound file in the terminal Sounds folder
Engine Parameters The engine parameters (EMA periods, ADX threshold, ribbon threshold, ATR coefficients, stochastic settings) are exposed for transparency and reproducibility, but the default values are calibrated and changing them invalidates the backtest reference. Only modify these if running an independent test.
Visual Style Bull color, bear color, neutral color, dashboard background, dashboard text color, dashboard font size.
Requirements
· Symbol: XAUUSD or any gold contract (the script prints a warning if used on another instrument)
· Timeframe: H1 (the script prints a warning if used on a different timeframe)
· Bars: at least 1500 bars of history are required at startup for the long EMA to warm up
· Telegram alerts (optional): WebRequest must be enabled and api.telegram.org must be whitelisted in the terminal options
Disclaimer
This indicator is provided for informational and educational purposes. It does not constitute investment advice, a recommendation, or a solicitation to trade. Trading carries significant risk and may not be suitable for all investors. Past performance, including backtest performance shown in this description, does not guarantee future results. The user is solely responsible for any trading decisions made while using this indicator.