kNN Trend Classifier (RSI, CCI, W%R, ADX, EMA)

At its core, the indicator utilizes six key features: RSI (14), RSI (9), CCI, Williams %R, ADX, and 9-period EMA. Each of these measures different dimensions of momentum, trend strength, and market positioning. These values are normalized to ensure they are fairly compared across different market conditions. For every bar close, the script stores a historical snapshot of these features and uses a k-Nearest Neighbor (kNN) technique to classify the current trend as bullish or bearish. The kNN algorithm works by calculating the Euclidean distance between the present market state and all stored historical states, then referencing the majority label among the closest neighbors to decide on the market regime.
The script also provides powerful customization. Users can adjust the number of neighbors (k) to make signals more reactive or more stable; increase the training window for a deeper historical perspective; and fine-tune the lookback window for feature normalization. Two optional filters—based on volume percentile and ATR volatility—help to screen out signals in low-liquidity or low-volatility periods, reducing false positives and improving reliability.
To modify the behavior, traders should experiment with the inputs: lower k for faster signal changes, raise k or the training window for smoother signals, and adjust normalization length for different levels of trend sensitivity. Activating the volume and volatility filters is highly recommended during choppy markets. Altogether, this script gives users a robust framework to catch bullish or bearish trends with a blend of proven technical analysis and adaptive pattern recognition.
Skrip hanya-undangan
Hanya pengguna yang disetujui oleh penulis yang dapat mengakses skrip ini. Anda harus meminta dan mendapatkan izin untuk menggunakannya. Izin ini biasanya diberikan setelah pembayaran. Untuk detail lebih lanjut, ikuti petunjuk penulis di bawah ini atau hubungi jaydesaigu secara langsung.
TradingView TIDAK menyarankan untuk membayar atau menggunakan skrip kecuali anda benar-benar percaya kepada pembuatnya dan memahami cara kerjanya. Anda juga dapat menemukan alternatif sumber terbuka yang gratis di skrip komunitas kami.
Instruksi penulis
Pernyataan Penyangkalan
Skrip hanya-undangan
Hanya pengguna yang disetujui oleh penulis yang dapat mengakses skrip ini. Anda harus meminta dan mendapatkan izin untuk menggunakannya. Izin ini biasanya diberikan setelah pembayaran. Untuk detail lebih lanjut, ikuti petunjuk penulis di bawah ini atau hubungi jaydesaigu secara langsung.
TradingView TIDAK menyarankan untuk membayar atau menggunakan skrip kecuali anda benar-benar percaya kepada pembuatnya dan memahami cara kerjanya. Anda juga dapat menemukan alternatif sumber terbuka yang gratis di skrip komunitas kami.