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 library, select all of the template text and paste. Press Save and give it a name.
4Publish or import itA library draws nothing. Publish it from the editor, then import its functions in your own scripts.
Source Code
35 lines of Pine Script v6 from examples/pine-libs/alice/bands/1.pine, published under AGPL-3.0. Keep the author's credit and licence lines when you reuse it.
1.pine
//@version=6
library("Bands")
// A library may import OTHER libraries (resolved from the same on-disk tree).
import alice/mathx/1 as mx
// An exported user-defined type (UDT).
export type Band
float basis = 0.0
float upper = 0.0
float lower = 0.0
// An exported enum.
export enum Side
Above
Below
Inside
// An exported method — callable via receiver dispatch: `b.width()`.
export method width(Band self) =>
self.upper - self.lower
// An exported function returning a UDT instance.
export compute(float src, int len, float mult) =>
basis = ta.sma(src, len)
dev = mult * ta.stdev(src, len)
Band.new(basis, basis + dev, basis - dev)
// Takes an imported-UDT parameter and returns an enum member.
export classify(float src, Band bnd) =>
src > bnd.upper ? Side.Above : src < bnd.lower ? Side.Below : Side.Inside
// Uses the TRANSITIVELY-imported MathX library.
export zWidth(float src, int len, float mult) =>
math.abs(mx.zscore(src, len)) * mult
Overview
Bands classifies a source as above, below, or inside those envelopes, measures band width, and scales an imported z-score by a multiplier. Callers supply source, length, and multiplier. It draws nothing and has no inputs of its own.
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 Pine Script v5 library provides an exported function to calculate moving averages directly over float arrays. Users can supply a sample array, set the smoothing length, choose whether to omit initial values prior to reaching the lookback window, and speci
This library exports one function, custom_ma, which returns a 14-period exponential moving average of a supplied source series. It declares no inputs, so the length stays fixed at 14 and the caller chooses the series. It plots nothing and does not generate ent
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
Calculates and plots moving averages on selected VIX volatility terms (VIX9D, VIX, VIX3M, or VIX6M) in a separate pane. The script computes user-defined short and long moving averages using EMA or SMA. It shades the background red when the short-term moving av
MACD-V is a volatility-normalized momentum indicator based on research by Alex Spiroglou. It calculates the standard MACD histogram and normalizes it by dividing by the Average True Range (ATR). Plotted in a separate pane as a colored histogram, it includes us
MultiIndicator combines multiple technical indicators into a single separate pane to save chart space. It calculates and displays market regime detection based on ordinary least squares regression, a Holt exponential smoothing crossover, normalized RSI, ADX, a