Machine Learning: kNN (New Approach) ranks one-dimensional distances, averages the nearest neighbors, and can adjust that projection. Optional signals hint at the next bar's direction, and an add-on can overlay a pivot point or a z-score. Users set the resolution, sample length, neighbor count, display mode, and projection source. It draws on the price chart and has no entry, exit, or stop rules.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Resolution
timeframe
5
TF
# of Data Points [2:n]
int
10
N
# of Nearest Neighbors (K) [1:252]
int
100
K
Adjust Prediction
bool
true
ADJ
Signals
bool
false
SIG
Add-On
string
Z-Score
ADDON
Pivot Point Lag [2:n] if selected
int
5
LAGP
Z-Score Lag [2:n] if selected
int
20
LAGZ
Show Outcomes
string
Both
DISP
Projection Base
source
hlcc4
ODS
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
This indicator implements a K-means clustering algorithm in Pine Script to partition two-dimensional data points into user-defined clusters. It features an internal pseudo-random number generator for centroid initialization and computes Euclidean distances acr
This indicator uses a Lorentzian distance k-nearest neighbors classification algorithm to predict market direction based on up to five technical features, such as RSI, WaveTrend, CCI, and ADX. It compares current feature values against historical bar patterns
This indicator calculates a trend direction and smoothed moving average using a k-nearest neighbours (k-NN) classification algorithm directly on the main price chart. Users can select input price types, target values, neighborhood size, and smoothing periods.
This indicator classifies the current bar by comparing its feature vector with historical bars using Lorentzian distance and a k-nearest-neighbors vote. Configurable features include RSI, WaveTrend, CCI, and ADX. Optional volatility, regime, ADX, and EMA filte
Calculates and plots a forward price prediction directly on the main chart using an on-chart multilayer perceptron neural network. The model processes technical input features including moving average ratios, RSI, normalized ATR, and Bollinger bandwidth throug
This indicator uses a Hidden Markov Model (HMM) framework combined with an adaptive dual moving average engine and Directional Movement Index (DMI) features to identify market regimes (bullish, bearish, or ranging/chop). It calculates regime probabilities on e