Pine Library · 145 open-source scripts

Free AI and Machine Learning Pine Scripts

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

About AI / machine learning Scripts

Pine Script runs on the chart's bars, so "AI" scripts here use compact methods, such as k-nearest neighbours, kernel regression or simple neural networks, coded directly in Pine.

A model that fits past data well can still fail on new data. Look for scripts that train only on past bars and test them on a period they never saw.

25 of these 145 scripts are marked Repaints, or read higher-timeframe data with lookahead on.

Before You Use One

AI / machine learning: Indicators, Strategies and Libraries

261 stars

AIActivationFunctionsBipolarSigmoid is a Pine Script library that provides mathematical implementations of the bipolar sigmoid activation function and its derivatives for machine learning algorithms. It calculates bipolar sigmoid values bounded between -1 and

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

Machine Learning: Lorentzian Classification

by artificial-intelligence-edge
75 stars

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

Indicator v6 AI / machine learningOscillators & momentum
Updated 3 days ago · MIT GitHub repository of Machine Learning: Lorentzian Classification

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

Indicator v6 TrendVolatility & bands
Updated 4 months ago · MIT GitHub repository of ML SuperTrend (Ultimate) - Auto-Optimized AI with LSTM
6 stars

This overlay indicator scores a bull, bear, or neutral game state from an auditable decision-forest probability rather than a fitted machine-learning model or live API. It compares the smoothed probability with bull and bear thresholds, then shifts it when a s

Indicator v6 Screeners & dashboardsAI / machine learning Repaints
Updated 7 days ago · None stated GitHub repository of Regime Game Probability Forest
4 stars

This overlay strategy combines a Supertrend with a k-nearest-neighbors filter. It smooths price and the Supertrend with weighted moving averages, then uses neighbor count and lookback length to form an AI trend signal. Traders can allow long, short, or both di

Strategy v5 TrendVolatility & bands
Updated 2 years ago · None stated GitHub repository of AI Volume Supertrend Strategy

Medallion Cipher

by ricksimpsontrading
3 stars

Medallion Cipher is a separate-pane indicator that combines a four-state hidden Markov model (bull, bear, range, and crisis) with weighted confluence signals. It can include mean reversion, trend, session timing, pattern matching, Hurst exponent, Shannon entro

Indicator v6 AI / machine learningMean reversion
Updated 9 days ago · None stated GitHub repository of Medallion Cipher

AI Debug Helper

by monch1962
3 stars

AI Debug Helper is a Pine Script indicator that provides AI-powered debugging suggestions for PineScript code. It loads a simulated database of common error patterns such as series index out of bounds, division by zero, Na propagation, infinite loops, and best

Indicator v5 AI / machine learningScreeners & dashboards
Updated 7 months ago · None stated GitHub repository of AI Debug Helper

This indicator detects pivot highs and lows, evaluates how often levels are respected by price, and uses an internal logistic regression model to estimate the probability that a level will hold. Qualifying support and resistance lines are projected onto the pr

Indicator v6 Support & resistanceAI / machine learning
Updated yesterday · None stated GitHub repository of Support and Resistance Logistic Regression | Flux Charts

This indicator plots an optimal RSI in a separate pane and uses a k-nearest neighbour machine learning routine to adjust lookback and RSI count. It can mark RSI crossings, draw adaptive Bollinger bands around the RSI, and show tables of current settings. Users

Indicator v5 Oscillators & momentumVolatility & bands
Updated 2 years ago · None stated GitHub repository of Machine Learning: Optimal RSI [YinYangAlgorithms]

This indicator tests a simple neural network for recognizing 2-bit numbers in Pine Script. It converts linear 1D arrays into 2D matrix structures for weights, biases, and activations using custom array functions. The network trains over a user-defined number o

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

The ANN MACD Future Forecast is an experimental indicator serving as a true deep learning sample on TradingView. It calculates Bollinger Bands and Squeeze Momentum using custom functions for SMA, EMA, standard deviation, highest and lowest values. The script p

Indicator v4 AI / machine learningVolatility & bands
Updated 7 years ago · MIT GitHub repository of ANN MACD Future Forecast (SPY 1D)

ML Smart Adaptive Indicator

by GeekRabbit007
1 stars

An overlay that displays signals produced by an outside machine-learning server, delivered through a data repository read with request.seed. It treats the seeded close value as the direction, volume as confidence, and other fields as strength, anomaly score an

Indicator v6 AI / machine learning
Updated 2 days ago · None stated GitHub repository of ML Smart Adaptive Indicator

TopBot 2024 Adaptive

by drewstake
1 stars

Prints manual long and short signal labels on the price chart using an adaptive scoring method trained on recent settled trade paths, with a warmup count before it starts. It uses the previous closed candles, enters at the current open, and applies a minimum d

Indicator v6 AI / machine learningScalping
Updated 3 days ago · None stated GitHub repository of TopBot 2024 Adaptive
1 stars

A signal overlay that merges two entry sources: an Andean oscillator with clustered Money Flow Index levels, and a UT Bot ATR trailing stop. Signals pass through optional filters: a FRAMA trend channel, a choppiness index, an ATR percentage range, a higher-tim

Indicator v6 TrendOscillators & momentum
Updated 7 weeks ago · None stated GitHub repository of MUFCA AtomDC v3.1 Elite

Markov-HMM Regime v5

by flaviodesalvo54-del
1 stars

Markov-HMM Regime v5 classifies each bar as Bull, Bear or Sideways using a hidden Markov model whose parameters were trained offline in Python and pasted into the script. It runs the forward algorithm on price and volume features and loads a parameter set matc

Indicator v5 TrendAI / machine learning
Updated 4 months ago · MIT GitHub repository of Markov-HMM Regime v5

DST HMM v9 Mobile

by Javas128282
1 stars

DST HMM v9 Mobile is a variant of a gold-focused hidden Markov model regime indicator, adjusted for mobile screens. It classifies the market into Sideways, Bull and Bear states using Baum-Welch retraining on a rolling window, draws a Kalman filter line with co

Indicator v6 AI / machine learningTrend
Updated 5 months ago · None stated GitHub repository of DST HMM v9 Mobile
1 stars

A machine-learning style indicator that classifies each bar using a decision matrix built from two chosen independent variables, such as Stochastic, RSI, Z-Score, MFI, volume or a moving-average distance. The target to predict can be red or green candle, bulli

Indicator v6 AI / machine learningOscillators & momentum
Updated 6 months ago · MIT GitHub repository of Simple Decision Matrix Classification

This indicator scores seven approaches on every bar: RSI, volume, VWAP, EMA trend, MACD, Bollinger Bands and a volume-delta module. Each score is weighted by a rolling record of that approach's recent agreement with price, and the weighted total must pass an a

Indicator v6 AI / machine learningOscillators & momentum
Updated 6 months ago · None stated GitHub repository of SignalForge v5 Volume Intelligence
1 stars

A chart-overlay trailing stop that adapts to market conditions. It uses Kaufman's adaptive moving average to measure how efficiently price is moving, scales an ATR-based stop distance accordingly, and optionally adds a k-nearest-neighbours pattern layer that n

Indicator v6 TrendVolatility & bands
Updated 9 months ago · None stated GitHub repository of Adaptive ML Trailing Stop

Neural Network Buy and Sell Signals

by solskjaeralesithio
1 stars

This indicator combines a neural network signal grading engine with moving average and trading session filters directly on the price chart. It plots buy and sell signal labels based on momentum, volatility, and trend conditions evaluated across selectable cand

Indicator v6 AI / machine learningMoving averages

Kotegawa Pump Tracker

by davccavalcante
1 stars

Kotegawa Pump Tracker is an overlay indicator aimed at volatile crypto markets. It combines an adaptive SuperTrend with a clustering step that sorts recent volatility into high, medium and low levels over an analysis window, and it also uses RSI. According to

Indicator v6 Volatility & bandsTrend
Updated 1 year ago · None stated GitHub repository of Kotegawa Pump Tracker
1 stars

A strategy that applies a k-nearest-neighbours classifier to RSI, ROC, CCI or volume features to estimate the next move, then trades long and or short with an optional moving average filter and volatility filter. Each position uses an ATR-multiple stop loss, a

Strategy v5 AI / machine learningTrend Repaints
Updated 2 years ago · None stated GitHub repository of kNN-Based Trend Following

AIActivationFunctionsSigmoid

by ricardosantos79
261 stars

AIActivationFunctionsSigmoid is a utility library for Pine Script v5 that provides mathematical calculations for the sigmoid activation function, commonly used in artificial intelligence and machine learning algorithms. The library exports functions to evaluat

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

TopBot Adaptive

by drewstake
1 stars

Prints manual long and short signal labels on the price chart using an adaptive method trained on recent settled trade paths. It works on standard time-based charts and scales stop limits with chart bar length. Positions exit only at the stop or target, stay o

Indicator v6 AI / machine learning
Updated 3 days ago · None stated GitHub repository of TopBot Adaptive
1 stars

A signal overlay that merges Andean oscillator with clustered Money Flow Index entries and UT Bot ATR trailing stop entries. Signals can be filtered by a FRAMA trend channel, a choppiness index, an ATR percentage range and, new in this version, an optional Hur

Indicator v6 TrendOscillators & momentum
Updated 7 weeks ago · None stated GitHub repository of MUFCA AtomDC v4.0 Elite

DST HMM v9 XAUUSD

by Javas128282
1 stars

DST HMM v9 XAUUSD classifies the market into hidden regimes such as Sideways, Bull and Bear using a hidden Markov model retrained on a rolling window with Baum-Welch iterations. It adds a Kalman filter line with confidence bands and an optional multi-bar Kalma

Indicator v6 AI / machine learningTrend
Updated 5 months ago · None stated GitHub repository of DST HMM v9 XAUUSD

MC-Predict HullMA v2

by ebarkinkaras-lang
1 stars

A price-chart overlay that plots a Hull moving average with a set of EMAs, SuperTrend and Bollinger Bands, and scores the market by weighting trend, momentum, volatility, volume, support and resistance, and a k-nearest-neighbours estimate. The nearest-neighbou

Indicator v5 AI / machine learningTrend
Updated 5 months ago · None stated GitHub repository of MC-Predict HullMA v2
1 stars

An indicator that combines several normalised oscillators, namely RSI, CCI, Fisher, DMI, Z-Score and a moving-average ratio, into one composite, then groups values into clusters over a rolling lookback. Lower and upper percentile settings mark extreme zones, a

Indicator v6 AI / machine learningOscillators & momentum
Updated 6 months ago · MIT GitHub repository of Simplified Percentile Clustering

AIActivationFunctionsThreshold

by ricardosantos79
261 stars

This Pine Script v5 library implements a threshold activation function for neural-network style calculations. The exported function returns 1.0 when the input is greater than or equal to zero and 0.0 otherwise. Two derivative exports, derivate and derivate2, a

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

Machine Learning: Lorentzian Classification

by artificial-intelligence-edge
75 stars

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

Indicator v5 AI / machine learningOscillators & momentum
Updated 3 days ago · MIT GitHub repository of Machine Learning: Lorentzian Classification
9 stars

Volume SuperTrend AI (Expo) combines SuperTrend trend filtering with a k-nearest neighbors machine learning classification algorithm. It computes a SuperTrend using customizable moving average types, including simple, exponential, weighted, smoothed, or volume

Indicator v5 TrendAI / machine learning
Updated 3 years ago · None stated GitHub repository of Volume SuperTrend AI (Expo)

This strategy fits a binary logistic regression classification model bar by bar on the price chart to generate long trading signals. It computes model weights via iterative gradient descent based on user-defined learning rates, lookback windows, and normalizat

Strategy v5 AI / machine learningTrend Repaints
Updated 2 weeks ago · MIT GitHub repository of Xsodus Logistic Long Regression Strategy

TopBot Adaptive (5m)

by drewstake
1 stars

Prints manual long and short signal labels on the price chart using an adaptive method trained on recent settled trade paths, with a warmup count before signals begin. It uses the previous closed candles and enters at the current open, applying a minimum direc

Indicator v6 AI / machine learningScalping
Updated 3 days ago · None stated GitHub repository of TopBot Adaptive (5m)
1 stars

An overlay that marks long and short signals by combining a Money Flow Index with k-means derived overbought and oversold levels, and an Andean oscillator crossing its signal line, both within a confirmation window. Optional trend and ATR percentage filters ca

Indicator v5 Oscillators & momentumAI / machine learning
Updated 7 weeks ago · None stated GitHub repository of AI MFI + Andean ETH 15min

Ensemble ML Predictor

by haydarkadioglu
1 stars

This indicator overlays a weighted ensemble of three models on the price chart. It compares the current bar with historical bars using RSI, volume ratio, price change and range position, then blends that KNN vote with a linear-regression projection and an EMA-

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

Echo Forecast [LuxAlgo]

by christonomous
1 stars

This indicator projects future price trajectory directly on the price chart by searching historical price movements for matching patterns. It compares a recent reference window against historical evaluation segments using correlation to identify the most simil

Indicator v5 AI / machine learningTrend
Updated 11 months ago · None stated GitHub repository of Echo Forecast [LuxAlgo]
1 stars

A separate-pane indicator that computes the Money Flow Index and adapts its overbought, neutral and oversold levels using a clustering routine trained on recent data. Inputs set the MFI length, the number of training bars and the iterations per bar. An adjuste

Indicator v5 Oscillators & momentumVolume
Updated 1 year ago · None stated GitHub repository of AI Adaptive Money Flow Index
114 stars

This indicator estimates the next bar's price with a k-nearest neighbors model built from consecutive price samples. It ranks one-dimensional distances, averages the nearest neighbors, and can adjust that projection. Optional signals hint at the next bar's dir

Indicator v5 AI / machine learning
Updated 1 year ago · None stated GitHub repository of Machine Learning: kNN (New Approach)

MLExtensions

by artificial-intelligence-edge
75 stars

MLExtensions is a Pine Script library providing utility and mathematical helper functions for machine learning indicators, specifically optimized for approximate nearest neighbors classification in Lorentzian space. It includes functions to normalize series de

Library v5 AI / machine learning
Updated 3 days ago · MIT GitHub repository of MLExtensions

MACD NN Weighted Strategy

by skywalker0803r
42 stars

Calculates MACD line and signal line differences, passing current and previous deltas through a two-layer neural network model with ReLU activation functions. User-configurable weights, biases, and threshold values determine output classification signals. The

Strategy v5 AI / machine learningOscillators & momentum
Updated 2 months ago · None stated GitHub repository of MACD NN Weighted Strategy
1 stars

Prints manual long and short signal labels on the price chart using an adaptive method trained on recent settled trade paths. It works on standard time-based charts, scaling stop limits with the chart's bar length, and uses the previous closed candles. Options

Indicator v6 AI / machine learning
Updated 3 days ago · None stated GitHub repository of TopBot Adaptive (Three-Candle)
1 stars

An overlay that signals long and short setups when a Money Flow Index crosses adaptive levels found by k-means clustering and an Andean oscillator crosses its smoothed signal within a short confirmation window. A 200-period EMA trend filter and an ATR percenta

Indicator v5 Oscillators & momentumAI / machine learning
Updated 7 weeks ago · None stated GitHub repository of AI MFI + Andean Floating
114 stars

This indicator classifies the next market direction with a two-feature k-nearest neighbours model. It stores normalized historic indicator values and past directions, then compares the current point to the nearest neighbours using Euclidean or Chebyshev distan

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

More Pine Script Categories

Browse the whole Pine Library

Related on ForexR

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.

Trade Your Charts With a Regulated Broker

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

Compare brokers