1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.
Source Code
212 lines of Pine Script v4 from scripts/102-ML-LVQ-based-Strategy-(v2).pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.
Machine Learning: LVQ-based Strategy determines winning prototype vectors using Euclidean distance and continuously updates weights across specified training epochs. Buy and sell signals are generated directly on the price chart with optional volatility or volume filters. Key inputs control the learning rate, epochs, lookback window, and date ranges. Signals repaint on live bars.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Dataset
source
close
ds
Lookback Window |1..2160|
int
14
p
Learning Rate |0.0001..0.1|
float
0.1
lrate
Epochs
int
5
epochs
Filter Signals by
string
Volatility
ftype
Reverse Signals?
bool
false
reverse
Training Start Year
int
2020
startYear
Training Start Month
int
1
startMonth
Training Start Day
int
1
startDay
Training Stop Year
int
2021
stopYear
Training Stop Month
int
1
stopMonth
Training Stop Day
int
1
stopDay
Show all 14 settings
Setting
Type
Default
Variable
Lot Size
float
0.01
lot_size
Show Information?
bool
true
Show Information?
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 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.
An overlay indicator that applies a k-nearest-neighbors machine learning classifier using Lorentzian distance to predict price movement. It evaluates historical market features, such as RSI, WaveTrend, CCI, and ADX, to identify similar price-time patterns and
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
This overlay indicator plots a SuperTrend-style band on the price chart using ATR length, a selectable source, and a base factor. Optional settings enable an adaptive factor driven by rate of change, a volatility filter, K-means clustering, and an LSTM layer w
The Machine Learning Momentum Index uses a k-Nearest Neighbors classification algorithm to evaluate momentum and trend direction directly on the price chart. It records historical parameter pairs derived from weighted moving averages and smoothed RSI values, t