PROTECTED SOURCE SCRIPT

Machine Learning: kNN sentiment Anomaly detector [Ox_kali]

Updated
Introduction:
This script represents a methodical integration of advanced machine learning techniques into financial market analysis. Utilizing the k-Nearest Neighbors (kNN) algorithm, a supervised learning method, the script systematically processes historical price data to detect anomalies in investor sentiment. By analyzing divergences between normalized investor satisfaction and actual asset prices, it offers a data-driven approach to identifying potential market inflection points.

Key Points:
  • Integration of the kNN machine learning algorithm to spotlight trading anomalies.
  • Incorporation of user-defined parameters, granting enhanced flexibility tailored to diverse trading strategies.
  • Deployment of normalization techniques, rendering a consistent perspective on average investor satisfaction.


Trading Application:
At its core, the script holds the capability to generate buy and sell signals derived from the detected anomalies, with a particular emphasis on those originating from divergences. Visual markers, represented by green and red backgrounds, provide an objective visualization of potential points of interest for traders.

Important Note:
This algorithm is an experimental embodiment of the kNN machine learning method. The parameters have not been fully optimized, and given the algorithm’s intricate nature and the high values set for kNN parameters, users might experience a slight delay during loading. On a personal note, it appears that this algorithm can detect shifts in trends on higher time frames, with the green and red color cues serving as key indicators. It also demonstrates promising performance on shorter time frames

Feedback Welcome:
Any feedback or suggestions on parameter settings are appreciated. Feel free to share your experiences in the comments.

Please note that the Machine Learning: kNN Investor sentiment Anomaly detector [Ox_kali] is provided for educational purposes only and is not meant to constitute financial advice. This indicator is not a guarantee of future market performance and should be used in conjunction with proper risk management. Always ensure that you have a thorough understanding of the indicator’s methodology and its limitations before making any investment decisions. Additionally, past performance is not indicative of future results.
Release Notes
Release Note:
- Parameter Update for Script:

[u]Number of nearest neighbors (n2)[/u]:
- Previous Value: 126
- New Default Value: 90
- Note: While the ideal value for this parameter seems to be 126, the loading time and the ability for it to display on TradingView may vary depending on the server load allowance. Additionally, the base script, even before the implementation of kNN, already takes time to load, further limiting the number of nearest neighbors. I will be working on an optimization soon. In the meantime, adjusting these parameters can lead to faster display times or even meet the expected load times on TradingView.
knnmachinelearningmultitimeframesentimentTrend Analysis

Protected script

This script is published closed-source and you may privately use it freely.

Want to use this script on a chart?

Disclaimer