Description
KNN Machine Learning Momentum Stop lagging. Start predicting. Institutional-grade K-Nearest Neighbors analytics.
Default parameters optimized for XAUUSD. Works on any timeframe β choose based on your trading style. Higher timeframes deliver cleaner, higher-probability signals. Lower timeframes generate more signals with slightly more noise. See the Timeframe Guide below.
π₯ Also Available: XAGUSD Automated Bot Version Love the logic? Take it further. A dedicated bot version of this indicator β fine-tuned specifically for XAGUSD (Silver) β is available on the marketplace. It runs fully automated, executing trades on your behalf with no manual input required. Priced low relative to the ROI it's built to deliver.
π KNN XAGUSD Bot β View on cTrader Market
β± Timeframe Guide
TimeframeSignal VolumeNotes
M5
Very High
More noise β requires stricter discipline and filtering to avoid overtrading.
M8
High (DEFAULT)
The optimized baseline. Best balance between signal frequency and accuracy for XAUUSD.
M15
Medium
Cleaner, higher-quality signals with fewer entries per session.
M30 / H1
Low
Highest accuracy β best suited for swing-style setups with more patience required.
Default parameters were backtested on M8. If you switch timeframes, consider adjusting ATR Period and SL/TP multipliers accordingly.
βοΈ Default Parameters
Learning Window (350) β Number of historical candles the KNN engine scans for pattern matches.
Prediction Threshold (0.5) β Minimum confidence score required before a signal is generated.
ATR Period (6) β Period used to calculate Average True Range for SL/TP sizing.
Stop Loss Multiplier (3.4) β SL distance = ATR Γ 3.4. Wider to give Gold's volatility room to breathe.
Take Profit Multiplier (1.6) β TP distance = ATR Γ 1.6. Tighter to lock in profits quickly and maintain a high win rate.
Trend Filter EMA (20) β Period of the EMA used as the trend filter β the Blue Line on your chart.
π€ Predictive KNN Engine Compresses RSI and MA deviation into a historical matching algorithm. On every candle, it scans the last 350 bars and finds the 5 most similar past moments to forecast direction.
π Strict EMA Trend Filter Suppresses low-probability counter-trend setups automatically. Only signals aligning with the broader trend are marked high-probability.
π¦ Dynamic ATR Target Zones Projects transparent colored boxes for your Take Profit and Stop Loss zones, adapting in real-time to current market volatility via ATR.
π§Ή UI Memory Manager Keeps your chart clean by automatically removing old zones. Only the 5 most recent setups are displayed at any time.
π² Telegram Push Alerts Built-in webhook integration sends instant trade alerts with exact Entry, TP, and SL prices directly to your phone.
π Reading the Signals
π’ Bright Green Arrow β High-Probability BUY KNN predicts price will rise AND price is above the EMA. Full trend alignment. These are the premium setups to trade.
π΄ Bright Red Arrow β High-Probability SELL KNN predicts price will fall AND price is below the EMA. Full trend alignment. Enter at the close of the signal candle.
βͺ Gray Arrow β Counter-Trend (DO NOT TRADE) Momentum shift detected, but against the broader trend. Printed for awareness only β significantly lower probability.
βΆοΈ Execution Guide
- Wait for a Bright Green or Bright Red Arrow β ignore gray signals entirely.
- Wait for the signal candle to fully close before entering.
- Set SL and TP at the outer horizontal edge of each box β the edge furthest from your entry price.
β FAQ
Why does an arrow appear? Every candle, the algorithm snapshots current RSI and MA momentum, scans the last 350 bars for the 5 most mathematically similar moments, and forecasts direction based on where price went from those moments.
What makes an arrow Bright vs. Gray? Bright arrows = AI signal and EMA trend in full agreement β highest probability. Gray arrows = momentum detected but counter-trend β flagged as too risky to trade.
Which timeframe should I use? M8 is the optimized default. Higher timeframes (M15, M30, H1) give fewer but cleaner signals. M5 gives more signals but demands sharper filtering discipline.
Where exactly do I place SL and TP? At the outer horizontal edge of each colored box β the edge furthest from your entry price.
Can I use this on assets other than Gold? Yes β applicable to any asset on cTrader. However, parameters were backtested specifically for XAUUSD. Other instruments will benefit from a parameter tuning period.
β οΈ Risk Disclaimer Trading foreign exchange, commodities, and CFDs on margin carries a high level of risk and may not be suitable for all investors. This indicator is a quantitative analysis tool for educational and informational purposes only β it does not constitute financial advice. Past performance is not indicative of future results. Always test on a demo account before risking live capital.
Summary
Key functionalities include dynamic Average True Range (ATR)-based stop loss and take profit target zones that adapt to market volatility, and a UI memory manager that keeps charts clear by displaying only the five most recent setups. Signals are visually represented by arrows: bright green for high-probability buy, bright red for high-probability sell, and gray for counter-trend momentum (not recommended for trading). The indicator supports multiple timeframes, with M8 as the default optimized setting balancing signal frequency and accuracy.
Additionally, it integrates Telegram push alerts via webhook, delivering real-time trade signals with precise entry, stop loss, and take profit levels. Users are advised to wait for signal candle closure before entering trades and to place stops and targets at the edges of the ATR target zones. Parameters such as learning window, prediction threshold, ATR period, and multipliers for stop loss and take profit are configurable to suit different trading styles.