Pine Library · 145 open-source scripts

Free AI and Machine Learning Pine Scripts (page 2)

Open-source Pine scripts that use machine learning ideas, such as nearest-neighbour classification, regression and adaptive filters, inside TradingView.

Pine scripts145
Code shown here72open licence
Updated in a year90
No repaint flag120

AI / machine learning: Indicators, Strategies and Libraries

7 stars

This overlay indicator draws Nadaraya-Watson smoothed Bollinger Bands on the price chart using short, medium, and long periods and deviations. A smoothing factor controls the kernel bandwidth, and an optional setting can allow the estimate to repaint. Users ca

Indicator v5 Volatility & bandsAI / machine learning
Updated 4 months ago · None stated GitHub repository of Bollinger Bands And EMA
7 stars

Lorentzian Classification is a machine learning indicator that applies a k-nearest neighbors algorithm using Lorentzian distance to analyze market patterns. It processes configurable technical indicators, including RSI, WaveTrend, CCI, and ADX, as feature vect

Indicator v6 AI / machine learningOscillators & momentum
Updated 1 year ago · MPL-2.0 GitHub repository of Lorentzian Classification

ML Decision Tree Classifier

by haydarkadioglu
1 stars

The ML Decision Tree Classifier uses rule-based decision tree logic to evaluate trend, momentum, volume, and MACD indicators for market direction classification. It calculates exponential moving averages, relative strength index values, volume relative to a mo

Indicator v5 AI / machine learningTrend
Updated 8 months ago · None stated GitHub repository of ML Decision Tree Classifier
114 stars

This indicator applies a k-Nearest Neighbors machine learning algorithm to predict market direction based on historical indicator patterns. It calculates normalized values from selected technical indicators, such as RSI, ROC, CCI, and volume, across short and

Indicator v5 AI / machine learningOscillators & momentum Repaints
Updated 1 year ago · None stated GitHub repository of Machine Learning: kNN-based Strategy

ML KNN Predictor V2 Enhanced

by haydarkadioglu
1 stars

Calculates machine learning price predictions using a weighted K-Nearest Neighbors algorithm. It evaluates price position, trend, RSI, volatility, Fair Value Gaps, Support and Resistance levels, and volume to identify similar historical pattern matches. The in

Indicator v5 AI / machine learningSMC / ICT / price action
Updated 8 months ago · None stated GitHub repository of ML KNN Predictor V2 Enhanced

This indicator trains a single-neuron artificial neural network (perceptron) on each bar to classify price movement and plot an adaptive moving average on the main chart. It evaluates historical sample data to iteratively adjust weights using a step activation

Indicator v5 AI / machine learningMoving averages
Updated 1 year ago · None stated GitHub repository of Machine Learning: Perceptron-Based Strategy
104 stars

This overlay strategy combines a machine-learning distance model with a MACD oscillator to open trades on the price chart. It compares recent history using cosine similarity or Euclidean and Lorentzian distance, then filters direction with selectable moving-av

Strategy v5 AI / machine learningOscillators & momentum
Updated 3 years ago · MIT GitHub repository of MLCEL and MACD Strategy

Debug Test Generator

by monch1962
3 stars

This indicator collects test data for debugging Pine Script scripts. It gathers input values, output values, conditions, function calls, and edge cases into arrays. Users enable test generation and select types of tests to produce, including unit tests, integr

Indicator v5 Screeners & dashboardsAI / machine learning
Updated 7 months ago · None stated GitHub repository of Debug Test Generator
1 stars

Fits a rolling regression of the chart's close several bars ahead on z-scored macro inputs, then plots the fitted value shifted forward so the line leads price on the chart. One feature set uses rates and cross-asset series such as US yields, the dollar index

Indicator v6 AI / machine learning
Updated yesterday · None stated GitHub repository of Nasdaq Macro Lead - Fair Value

Tsh Arrow

by teshmi9z-beep
1 stars

An overlay that draws a SuperTrend-style trend line built from a volume-weighted moving average, selectable from SMA, EMA, WMA, RMA or VWMA types, with a fixed ATR factor. A k-nearest neighbours routine compares recent prices with the smoothed trend line to pr

Indicator v5 TrendAI / machine learning
Updated yesterday · MIT GitHub repository of Tsh Arrow

ML Price Predictor (KNN)

by haydarkadioglu
1 stars

This overlay indicator compares the current bar with historical patterns using a k-nearest neighbors search. It measures RSI, RSI slope, volume relative to a 20-bar average, EMA trend strength, and price position within a range, each scaled by a user weight. F

Indicator v5 AI / machine learningOscillators & momentum
Updated 8 months ago · None stated GitHub repository of ML Price Predictor (KNN)

This indicator uses a two-dimensional k-nearest-neighbours model on scaled oscillator values to classify the current bar as buy, sell, or hold from similar historical states. Users select RSI, ROC, CCI, momentum, or all of them, and set the neighbour count, fa

Indicator v4 AI / machine learningOscillators & momentum
Updated 1 year ago · None stated GitHub repository of Machine Learning: kNN-based Strategy (update)

This indicator implements an artificial neural network using a single-layer perceptron model trained from scratch directly in Pine Script. It processes price features combined with a custom directional movement index across a rolling sample window to generate

Indicator v5 AI / machine learningTrend
Updated 1 year ago · None stated GitHub repository of Machine Learning: Perceptron-Based Strategy 5 (v.2)
2 stars

This script demonstrates array manipulation in Pine Script v4 to create a 2D matrix structure for testing a neural network. It implements a basic neural network to solve the XOR logic problem. The indicator runs a configurable number of training loops using a

Indicator v4 AI / machine learning
Updated 5 years ago · MIT GitHub repository of XOR test Neural Network - JD

This strategy implements a single-layer perceptron machine learning model built from scratch to generate trading signals directly on the price chart. It calculates predictions based on sample size, threshold settings, and optional volatility or volume filters.

Strategy v5 AI / machine learningTrend
Updated 1 year ago · None stated GitHub repository of Machine Learning: Perceptron-Based Strategy [5] (v.3)

Neural Network

by iceberg211
2 stars

Calculates composite scoring across multiple technical indicators including EMAs, SuperTrend, Parabolic SAR, Hull Moving Average, RSI, MACD, WaveTrend, Stochastic, Bollinger Bands, and ATR. Trading entries trigger on the price chart when cumulative weighted sc

Strategy v4 TrendOscillators & momentum
Updated 1 year ago · None stated GitHub repository of Neural Network
257 stars

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

Indicator v5 AI / machine learningOscillators & momentum
Updated 6 weeks ago · None stated GitHub repository of Donald - Machine Learning Options
257 stars

Donald - Test Logic Futures is an overlay strategy designed for intraday futures trading. It combines kernel regression functions with exponential moving averages to evaluate price retracements and entry timing. Trades are filtered by session execution windows

Strategy v5 TrendMoving averages Repaints
Updated 6 weeks ago · None stated GitHub repository of Donald - Test Logic Futures

kNN Classifier

by jayadevrana
1 stars

This indicator implements a k-nearest neighbours classification model to forecast price direction several bars ahead. It extracts three normalized technical features: RSI, an EMA spread scaled by ATR, and normalized candle range volatility. Historical samples

Indicator v6 AI / machine learningTrend
Updated 3 days ago · MPL-2.0 GitHub repository of kNN Classifier

Chandelier Flip Radar plots an ATR trailing stop on the price chart and tracks a directional trend state. It holds a ratchet stop until an accepted flip, using close or wick extremums and a body filter so weak breaks do not change direction. Distance to the fl

Indicator v6 TrendVolatility & bands
Updated 2 days ago · MIT GitHub repository of Chandelier Flip Radar [WavesUnchained]

HMM V2 Regime

by rellis3
1 stars

Classifies the market into bull, bear, range and chop regimes with a hidden Markov style model in a separate pane. Three standardised inputs, trend, volatility and ADX, are scored against configurable regime means and variances that can be pasted from an exter

Indicator v5 TrendAI / machine learning
Updated yesterday · None stated GitHub repository of HMM V2 Regime
43 stars

Donald - AI Futures is a price-chart strategy that estimates inner and outer high-low zones and a smoothed close with rational quadratic kernel regression. It builds bullish and bearish momentum signals, optionally compares volume with a volume-weighted moving

Strategy v5 Oscillators & momentumSMC / ICT / price action Repaints
Updated 2 years ago · None stated GitHub repository of Donald - AI Futures

This strategy plots an ATR Chandelier trailing stop on the price chart and tracks a directional trend state. It marks confirmed flips, weak body-rejected flips, and wick traps, and colors bars as price nears warning or danger zones around the flip trigger. Ada

Strategy v6 TrendVolatility & bands
Updated 2 days ago · MIT GitHub repository of Chandelier Flip Radar [WavesUnchained]

Nexus Fusion Engine ML

by vedkanani123
1 stars

An oscillator in a separate pane, adapted from an earlier oscillator under an open license. It smooths price with a selectable method such as DEMA, adds a signal line and marks crosses with dots. Overbought and oversold zones default to 80 and 20. Optional lay

Indicator v6 Oscillators & momentumDivergence
Updated 2 months ago · None stated GitHub repository of Nexus Fusion Engine ML

This indicator applies a k-nearest neighbours (kNN) classification algorithm using Aroon indicator lags and momentum as feature inputs to forecast market direction. It compares current values against historical feature sets to classify bars into buy, hold, or

Indicator v4 AI / machine learningTrend Repaints
Updated 1 year ago · None stated GitHub repository of Machine Learning: kNN-based Strategy (aroon)
1 stars

This multi-model strategy combines kinematic price modeling, Bayesian inference forecasts, volume profile consolidation zones, and automated pattern recognition directly on the price chart. It evaluates market trajectory using weighted kinematic regression, un

Strategy v5 AI / machine learningSupport & resistance
Updated yesterday · None stated GitHub repository of JAT+BSM Pro v13 Extended

This indicator uses a k-Nearest Neighbors (kNN) machine learning algorithm to classify current market conditions based on historical indicator pairs. It evaluates combinations of fast and slow periods of RSI, Rate of Change (ROC), and Commodity Channel Index (

Indicator v4 AI / machine learningTrend Repaints
Updated 1 year ago · None stated GitHub repository of Machine Learning: kNN-Based Strategy (MTF)
1 stars

JAT+BSM Pro v13 Extended is a multi-timeframe trading strategy overlay that combines kinematic regression models, Bayesian inference, and consolidation zone analysis. It processes multi-layer volatility bands, volume profile buckets, and pattern structure targ

Strategy v5 TrendVolatility & bands
Updated yesterday · None stated GitHub repository of JAT+BSM Pro v13 Extended
114 stars

This indicator applies a logistic regression binary classification model trained via gradient descent directly on chart data. On every bar, the model updates weights over a configurable number of training iterations and passes them through a sigmoid function t

Indicator v4 AI / machine learningTrend Repaints
Updated 1 year ago · None stated GitHub repository of Machine Learning: Logistic Regression

Function K-Means Clustering

by ricardosantos79
261 stars

Calculates K-Means clustering on two-dimensional float data arrays directly within Pine Script. The script initializes cluster centers randomly from data points and iteratively assigns points to clusters based on Euclidean distance calculations. User settings

Indicator v5 AI / machine learning
Updated 4 years ago · None stated GitHub repository of Function K-Means Clustering
114 stars

This indicator implements a binary logistic regression classification model retrained on each bar using gradient descent optimization. It processes normalized price features through a sigmoid activation function to classify market direction and generate direct

Indicator v4 AI / machine learningTrend Repaints
Updated 1 year ago · None stated GitHub repository of Machine Learning: Logistic Regression
114 stars

This indicator applies Learning Vector Quantization (LVQ), a supervised neural network competitive learning algorithm, to classify normalized market features. It determines winning prototype vectors using Euclidean distance and continuously updates weights acr

Indicator v4 AI / machine learningTrend Repaints
Updated 1 year ago · None stated GitHub repository of Machine Learning: LVQ-based Strategy

Function: Decision Tree

by ricardosantos79
261 stars

Function: Decision Tree is a technical script that demonstrates probabilistic path selection through a decision tree algorithm using a custom pseudo-random number generator. It initializes weighted node arrays and simulates traversal paths down the tree based

Indicator v5 AI / machine learning
Updated 4 years ago · None stated GitHub repository of Function: Decision Tree

Machine Learning: Perceptron-based Strategy is a Pine Script overlay indicator intended to implement a simple perceptron machine learning model for signal generation. However, the author deleted the underlying script logic from the source file, leaving only th

Indicator v4 AI / machine learning
Updated 1 year ago · None stated GitHub repository of Machine Learning: Perceptron-based Strategy
1 stars

An indicator that builds a feature matrix from price z-score, RSI, ATR ratio and momentum over a lookback window, weights the four features, smooths them with a covariance based decomposition, and classifies a regime. It then draws a forecast line a chosen num

Indicator v5 AI / machine learningVolatility & bands
Updated yesterday · None stated GitHub repository of JINXAI Tensor Forecast

Goertzel Algorithm

by mikeyhu70
1 stars

This indicator applies the Goertzel algorithm, a signal-processing method for measuring a single frequency component, to price in a separate pane. A period length and a measurement block length set the cycle to test, and a training percentage and shift setting

Indicator v5 AI / machine learning
Updated 6 months ago · None stated GitHub repository of Goertzel Algorithm

Goertzel Algorithm V6

by mikeyhu70
1 stars

This indicator applies the Goertzel algorithm to price in a separate pane, measuring one frequency component set by a period length and a measurement block length. A training percentage and shift settings align the fitted wave with recent data, and the wave ex

Indicator v5 AI / machine learning
Updated 6 months ago · None stated GitHub repository of Goertzel Algorithm V6

This indicator combines a dynamic Seasonal Random Index (SRI) with a dynamic Karobein Oscillator and a pattern-similarity search algorithm in a separate pane. It normalizes SRI into seasoned and deseasoned series, shading the area green or red to signal trend

Indicator v4 Oscillators & momentumTrend
Updated 1 year ago · None stated GitHub repository of Similarity Search, Karobein and Seasonal Random Index

This indicator plots an oscillator in a separate pane. It builds several SuperTrend series across a user-defined factor range and step, using ATR as the band width. On each bar it measures the distance between the close and each SuperTrend output, then groups

Indicator v5 TrendVolatility & bands
Updated 2 years ago · GPL-3.0 GitHub repository of AI SuperTrend Clustering Oscillator [LuxAlgo]

AI Trend Navigator

by hasnocool
106 stars

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.

Indicator v5 AI / machine learningTrend
Updated 2 years ago · GPL-3.0 GitHub repository of AI Trend Navigator
46 stars

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

Indicator v5 AI / machine learningTrend
Updated 7 weeks ago · None stated GitHub repository of HMM Enhanced: Regime Probability

FunctionNNetwork

by ricardosantos79
261 stars

This Pine Script v5 library exposes methods for a generalized neural network. It builds random weight arrays, runs a forward pass through stacked layers using an imported layer function, and begins a backward pass that compares output nodes with targets. Calle

Library v5 AI / machine learning
Updated 4 years ago · None stated GitHub repository of FunctionNNetwork

More Pine Script Categories

Browse the whole Pine Library

Third-party code. ForexR lists open-source Pine scripts from GitHub; it did not write, test or endorse them, and their summaries are generated automatically from each script's code and README. Indicators describe the past, and a strategy's backtest can look better than live trading. Check a script on a demo account before you rely on it. CFDs and leveraged forex are complex instruments with a high risk of losing money rapidly.

Learn to Use Pine Scripts

Free, plain-English guides: add a script to TradingView, read what it does, test it and avoid the common traps.

  1. 1Using this librarySearch, filters, licences and what the badges mean.
  2. 2Add a script to TradingViewCopy, paste into the Pine Editor, save and add to chart.
  3. 3Indicators, strategies and librariesWhat each type does and how to tell them apart.
  4. 4Spot a script that repaintsWhy some signals change after the bar closes.
  5. 5Backtest a strategyStrategy Tester settings that keep results honest.
  6. 6Send alerts to MT4 or MT5From a TradingView alert to an order in MetaTrader.
  7. 7What Pine Script isThe language, what it can and cannot do, and where to start.
  8. 8Write your first indicatorA complete script, line by line, in the Pine Editor.
  9. 9Read a script before you trust itA routine for checking inputs, logic and red flags.
  10. 10Edit a script safelyChange colours and lengths, add a filter or an alert.
  11. 11Pine Script alertsalertcondition(), alert(), placeholders and webhooks.
  12. 12Build a crossover strategyAn EMA cross strategy with an ATR stop, ready to test.

Trade Your Charts With a Regulated Broker

Compare regulated brokers on platforms, spreads, minimum deposit and leverage.

Compare brokers