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
216 lines of Pine Script v4 from scripts/101-ML-Logistic-Regression-(v3).pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.
Machine Learning: Logistic Regression processes normalized price features through a sigmoid activation function to classify market direction and generate directional signals directly on the price chart. Users can configure the training lookback window, normalization period, learning rate, training iterations, and optional volatility or volume filters. According to the author, signals on this indicator repaint.
Logistic regression binary classification model
Gradient descent weight optimization
Volatility and volume signal filtering
Multi-timeframe resolution support
Configurable normalization and learning rate parameters
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Price Type
string
Close
ptype
Resolution
timeframe
reso
Lookback Window Size |2..n| (2)
int
3
lookback
Normalization Lookback |2..240| (120)
int
2
nlbk
Learning Rate |0.0001..0.01|
float
0.0009
lrate
Training Iterations |50..n|
int
1000
iterations
Filter Signals by
string
Volatility
ftype
Min ATR Lag for the Filter |1..n|
int
1
minatr
Max ATR Lag for the Filter |1..n|
int
10
maxatr
Volume Lag for the Filter |1..n|
int
55
vol
Show Loss & Prediction Curves?
bool
false
curves
Optional Calculation?
bool
true
easteregg
Show all 17 settings
Setting
Type
Default
Variable
Use Price Data for Signal Generation?
bool
true
useprice
Holding Period |1..n|
int
1
holding_p
===Information===
bool
true
show_info
Lot Size
float
0.01
lot_size
Use OHL3=false, Open=true in calculation
bool
true
useopen
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