Pine Library · 198 open-source scripts

Free Pine Script Libraries

Open-source Pine Script libraries: collections of functions that other indicators and strategies import, so you do not write the same code twice.

Pine scripts198
Code shown here159open licence
Updated in a year73
No repaint flag189

About Libraries Scripts

A library draws nothing on its own. It exports functions, such as a moving average variant, a table helper or a date tool, that your own scripts load with an import statement.

To import a library in TradingView it has to be published there, so the GitHub copy is mainly for reading and learning how the functions work. Check the licence before you reuse the code in your own scripts.

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

Before You Use One

Libraries: All

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

Math

by BlackPhoenixSlo
7 stars

This Pine Script v5 library provides helpers for approximating price and reducing noise. The exported DFT3 function computes a three-point discrete Fourier transform from the current close and the two previous closes, using a direction parameter that scales th

Library v5
Updated 2 years ago · None stated GitHub repository of Math

OrderEncoder

by algoboy-kevin
4 stars

This utility library formats automated trading alert messages into structured JSON strings for external execution. It provides functions to construct text payloads for opening limit orders, cancelling existing limit orders, and closing all active positions wit

Library v5
Updated 2 years ago · None stated GitHub repository of OrderEncoder

Color

by Electrified-Trading
2 stars

Color is a Pine Script utility library designed for advanced color manipulation and comparison within scripts. It provides helper methods to compare two color instances across RGB and transparency channels, calculate relative color luminosity, and determine hi

Library v6
Updated 1 year ago · MPL-2.0 GitHub repository of Color

Skipp Calibration

by skipp-dev
1 stars

This library provides functions for rolling statistical computations and probability calibration in trading applications. It maintains rolling buffers with running sum recalculation to efficiently handle large datasets. Additional tools compute 3-way posterior

Library v6
Updated 3 days ago · None stated GitHub repository of Skipp Calibration

SFA Core v2

by genesisgrubio39
1 stars

A Pine library that exports one core function returning many values for use by other scripts. It computes ATR, optional session and displacement filters, a signed volume pressure measure with z-score, a session-resetting cumulative volume proxy, and linear reg

Library v6
Updated 10 months ago · None stated GitHub repository of SFA Core v2

CodonATRStop

by codon-pro
1 stars

This library exports a function that returns a dynamic trailing stop price based on Average True Range. For longs it subtracts an ATR multiple from the close and ratchets the level upward, resetting the stop when price closes below the previous level. For shor

Library v6 Volatility & bands
Updated 10 months ago · MIT GitHub repository of CodonATRStop

TAIndicators

by MarcosACH
1 stars

TAIndicators is a Pine Script library providing helper functions for technical analysis calculations. It features flexible moving average functions supporting SMA, EMA, SMMA, WMA, and VWMA options, along with secondary smoothing methods and Bollinger Band calc

Library v6
Updated 1 year ago · None stated GitHub repository of TAIndicators

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

KernelFunctions

by artificial-intelligence-edge
75 stars

KernelFunctions is a Pine Script v5 library that exports kernel weight functions for Nadaraya-Watson style estimation. It calculates a Rational Quadratic kernel, a Gaussian kernel based on a radial basis function, and a periodic kernel that models repeating be

Library v5
Updated 3 days ago · MIT GitHub repository of KernelFunctions

Bands

by heyphat
26 stars

This library exports a Band type and functions that build a simple-moving-average basis with upper and lower envelopes from standard deviation. It classifies a source as above, below, or inside those envelopes, measures band width, and scales an imported z-sco

Library v6 Volatility & bandsMoving averages
Updated 2 months ago · AGPL-3.0 GitHub repository of Bands

HLevel

by stupenkov
14 stars

HLevel is a Pine Script v5 utility library designed to manage horizontal price levels for cryptocurrency charts. It defines custom types for pivots and levels, along with methods to initialize, add, track, and expire price levels based on pivot high and pivot

Library v5
Updated 3 years ago · None stated GitHub repository of HLevel

Quant

by hirawatt
11 stars

Quant is a Pine Script utility library providing custom functions for quantitative analysis. It includes an exported function to calculate the percentage change between consecutive values of any float series. Additionally, it offers a function to calculate mar

Library v5
Updated 2 years ago · MIT GitHub repository of Quant

ZigZag

by rubystar0512
5 stars

This library calculates ZigZag pivots and draws connecting lines on the price chart. It changes direction when price moves beyond a percentage deviation after a set pivot depth, then stores each pivot with optional labels for reversal price, cumulative volume,

Library v5 Support & resistance
Updated 2 years ago · None stated GitHub repository of ZigZag

EMA Lib

by augustoerni
3 stars

EMA Lib is a Pine Script v5 library that provides a custom exponential moving average calculation function. The library exports a single function that takes a period length parameter and computes an exponential moving average on close prices. To initialize the

Library v5
Updated 2 years ago · None stated GitHub repository of EMA Lib

GapDetect

by Electrified-Trading
2 stars

This library determines opening gap severity by calculating the standard deviation of overnight gaps. It exports functions for today's gap value as open minus previous close, gap percent change, and normal daily standard deviation of the gap using a rolling wi

Library v6 Volatility & bandsSessions & time
Updated 1 year ago · MPL-2.0 GitHub repository of GapDetect

Skipp Labels

by skipp-dev
1 stars

Skipp Labels is a Pine Script v6 helper library designed to assist with label creation and memory management on price charts. It exports functions for string safety and buffer control. The safe label text function truncates long strings to a maximum of 120 cha

Library v6
Updated 3 days ago · None stated GitHub repository of Skipp Labels

Library Template

by maxenko
1 stars

A Pine v6 library template showing how to structure exported code. It defines a Pivot type holding bar index, price and direction, a higher timeframe request helper that reads the previous closed bar, a method that returns a confirmed swing pivot only after th

Library v6
Updated 3 months ago · MIT GitHub repository of Library Template

CommonSignals

by Yavuz365
1 stars

CommonSignals is a Pine Script utility library providing standardized signal generation functions for technical analysis scripts. It normalizes trade directions across diverse indicators into consistent integer values: 1 for buy, 0 for neutral, and -1 for sell

Library v5
Updated 9 months ago · MIT GitHub repository of CommonSignals

SFA FlowLiquidity v1

by genesisgrubio39
1 stars

The SFA FlowLiquidity library computes structural flow and liquidity events from price data. It detects sweep ups and downs with associated scores, identifies liquidity levels, and applies session and regime filters. Persistent arrays track liquidity prices, b

Library v6 SMC / ICT / price actionSupport & resistance
Updated 10 months ago · None stated GitHub repository of SFA FlowLiquidity v1

CodonRiskManager

by codon-pro
1 stars

This library calculates position size for trading strategies based on a percentage of equity to risk and the distance to the stop loss price. The function takes risk percentage, entry price, and stop loss price as inputs and returns the quantity of contracts o

Library v6
Updated 10 months ago · MIT GitHub repository of CodonRiskManager

CandleAnalysis

by MarcosACH
1 stars

CandleAnalysis is a Pine Script library providing exportable helper functions for detailed candlestick analysis in custom scripts. It evaluates whether a specified bar is bullish, bearish, or break-even, and computes metrics including body size, top wick size,

Library v5 Candlestick patterns
Updated 1 year ago · None stated GitHub repository of CandleAnalysis

ThangeVault

by govindthange
1 stars

A small Pine v5 library of helper functions for the author's Woodwind Playbook script. One function writes a text tag on the chart just above the recent ten-bar high, using a label. Another builds a number format string that limits displayed price precision to

Library v5
Updated 3 years ago · Custom licence GitHub repository of ThangeVault

MPB

by sourdiesel1202
1 stars

A Pine library that exports a scoring function for price against two simple moving averages, with periods of 9 and 20. Depending on the candle colour and where the close sits relative to each average, it adds or subtracts weighted values and returns the total

Library v5
Updated 3 years ago · None stated GitHub repository of MPB

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

Chart Patterns

by deepentropy
13 stars

Chart Patterns is a Pine Script v6 library designed to scan for and render technical chart patterns directly on the price chart. It defines custom user-defined types to configure scanning parameters, such as Zigzag pivot offsets, error ratios, flat ratios, and

Library v6 Repaints
Updated 6 months ago · MIT GitHub repository of Chart Patterns

Standard Lib

by vitahoang
5 stars

Standard Lib is a utility Pine Script library designed to assist developers with chart debugging and dynamic text display. It exports a print function that creates and updates a single text label on the price chart. The label automatically positions itself at

Library v5
Updated 3 years ago · None stated GitHub repository of Standard Lib

Commonlib

by InNoobWeTrust
4 stars

Commonlib is a Pine Script v6 library of bar-geometry helpers that draws nothing by itself. It measures the longer wick as a share of the high-low range, signed when the lower wick is longer, and the candle body as a signed share of that range. It combines tho

Library v6
Updated yesterday · None stated GitHub repository of Commonlib

VolTargeting

by Robot-Wealth
4 stars

VolTargeting is a Pine Script v5 library of functions for volatility-based position sizing. ewmaVol estimates exponentially weighted annualised volatility from squared simple returns and scales it by the square root of 365 days for crypto or 252 days otherwise

Library v5 Volatility & bands
Updated 2 years ago · None stated GitHub repository of VolTargeting

LabelManagement

by Electrified-Trading
2 stars

This library manages TradingView chart labels through configuration templates, change-aware updaters, and a named registry. It lets callers set position, text, colors, style, size, and tooltips with a fluent interface, then apply only properties that differ fr

Library v6
Updated 1 year ago · MPL-2.0 GitHub repository of LabelManagement

Skipp Math

by skipp-dev
1 stars

Skipp Math is a utility library for Pine Script v6 containing constants and functions for probability calculations, statistical analysis, and data normalization. It provides clamping utilities, logit and sigmoid transformations, range position computation, 95%

Library v6
Updated 3 days ago · None stated GitHub repository of Skipp Math

SFA Impulse Origin v1

by genesisgrubio39
1 stars

This library from the SFA framework detects structural flow points using break of structure (BOS) and change of character (CHOCH) events. It calculates impulse origins by comparing close prices against ATR-based high and low extremes, filtered by volume percen

Library v6 SMC / ICT / price actionTrend
Updated 10 months ago · None stated GitHub repository of SFA Impulse Origin v1

CodonTimeFilter

by codon-pro
1 stars

This Pine Script v6 utility library provides a reusable function to filter backtest date ranges. It evaluates whether the current bar timestamp falls between a specified start time and end time, returning a boolean value. Although configured as an overlay on t

Library v6
Updated 10 months ago · MIT GitHub repository of CodonTimeFilter

MarketAnalysis

by MarcosACH
1 stars

MarketAnalysis is a helper library for Pine Script developers that provides modular functions to compute Fibonacci price levels. It offers calculations for both bullish and bearish Fibonacci retracements using low and high price points. Additionally, it calcul

Library v5
Updated 1 year ago · None stated GitHub repository of MarketAnalysis

TrendChecker

by RobACurtis
1 stars

A Pine library that exports three functions, bullish, bearish and getTrend, which judge market direction on the current symbol and timeframe. Each call takes three switches to include a Stochastic RSI cross, a MACD line versus signal check and a comparison of

Library v5 TrendOscillators & momentum
Updated 2 years ago · None stated GitHub repository of TrendChecker

WoodwindVault

by govindthange
1 stars

A Pine v5 library that supplies auxiliary calculation functions for the author's Woodwind Playbook script. The visible part includes a function that works out the gains after a position is scaled down, taking entry, exit, quantity, remaining quantity and direc

Library v5
Updated 3 years ago · Custom licence GitHub repository of WoodwindVault

MPB2_0

by sourdiesel1202
1 stars

A Pine library that exports condition checks for long and short setups, selected by a position type string. The simple moving average check uses a 10-bar average and requires the close, and for longs the low, to sit on one side of it with a matching candle col

Library v5
Updated 3 years ago · None stated GitHub repository of MPB2_0

Utils

by tyler314
1 stars

This Pine Script library provides utility functions for script development and backtest reporting. It includes a function to display debug text labels on the chart, a rounding utility to round floating-point values to a specified number of decimal places, and

Library v5
Updated 4 years ago · None stated GitHub repository of Utils

AnalysisInterpolationLoess

by ricardosantos79
261 stars

This Pine Script v5 library provides a LOESS local weighted smoothing routine for paired x and y sample arrays. It builds a local neighborhood around each sample, applies a tricubic distance weight, and fits a weighted local regression. A separate polynomial w

Library v5
Updated 4 years ago · None stated GitHub repository of AnalysisInterpolationLoess

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

Mylib

by ferranbt
21 stars

This script serves as a minimal utility library written in Pine Script v6. It provides an exported helper function that calculates the sum of two numeric arguments. As a reusable code library, it produces no visual plots, charts, or trading signals, and it con

Library v6
Updated 7 weeks ago · MPL-2.0 GitHub repository of Mylib

Public

by wanjo-tech
6 stars

This Pine Script v5 library walks historical price, volume, time and amount series until a requested number of hours is covered, stopping at 4999 bars. TimeAligned returns the bar count, net and absolute price changes, net and absolute log-price changes, volum

Library v5 Volatility & bandsVolume
Updated 2 years ago · None stated GitHub repository of Public

MovingAverages

by Electrified-Trading
2 stars

This library exports utilities for calculating moving averages rather than drawing them on a chart. It provides a volume-adjusted weighted moving average that combines volume weighting with triangular recent-bar emphasis, and a coefficient moving average that

Library v6 Moving averagesVolume
Updated 1 year ago · MPL-2.0 GitHub repository of MovingAverages

Skipp Scoring

by skipp-dev
1 stars

Skipp Scoring is a Pine Script v6 utility library that provides quantitative scoring functions for technical analysis scripts. It calculates normalized market state scores ranging between -1 and +1, evaluating trend strength, discrete regimes (bullish, bearish

Library v6
Updated 3 days ago · None stated GitHub repository of Skipp Scoring

SFA Price Gap Inefficiency v1

by genesisgrubio39
1 stars

The library detects price gap inefficiencies using structural flow analytics. It identifies new bullish and bearish gaps with their top and bottom levels, tracks mitigation status, and checks flow alignment between price and CVD trends. It applies regime detec

Library v6 SMC / ICT / price actionVolume
Updated 10 months ago · None stated GitHub repository of SFA Price Gap Inefficiency v1

Objects

by MarcosACH
1 stars

Objects is a Pine Script utility library providing dynamic type detection functions for script development and debugging. It exports overloaded getType methods for fundamental Pine Script data types and visual drawing objects, including integers, floats, boole

Library v5
Updated 1 year ago · None stated GitHub repository of Objects

WoodwindYard

by govindthange
1 stars

A Pine v5 library of ancillary functions for the author's Woodwind Playbook script. It includes a function that returns the midpoint between the highest high and lowest low over a period, and another that returns the bar positions and values of the highest hig

Library v5
Updated 3 years ago · Custom licence GitHub repository of WoodwindYard

ArrayExtension

by ricardosantos79
261 stars

ArrayExtension is a Pine Script v5 utility library that provides helper functions for array manipulation. It includes routines to convert multi-dimensional matrix coordinates, such as 2D and 3D index positions, into flattened single-dimension array indices wit

Library v5
Updated 4 years ago · None stated GitHub repository of ArrayExtension

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