AI Trend Navigator (KNN)
Category: trend
An adaptive trend indicator that uses the K-Nearest Neighbors (KNN) algorithm to determine a moving average and trend direction based on historical price pattern similarity.
Formula
\text{Distance}_i = |Value_i - Target_{current}| \\ \text{knnMA} = \frac{1}{K} \sum \text{Values of } K \text{ points with smallest Distance} \\ \text{Trend} = \text{Sign}(\text{Count}(\text{Pos Samples}) - \text{Count}(\text{Neg Samples})) \text{ within local N-nearest neighbors}
Inputs
- PriceValue (default: hl2)
- maLen (default: 5)
- TargetValue (default: Price Action)
- maLen_ (default: 5)
- numberOfClosestValues (default: 3)
- smoothingPeriod (default: 50)
- bgcolor (default: false)
See signal primitives, usage in published strategies and more on WOBR StrategyVerse.