Indicator · Pine Script v6 · On the chart

Acceleration Bands (ACCBANDS)

by mihakralj

This indicator plots Price Headley's Acceleration Bands on the price chart.

View on GitHub

GitHub stars99on the repository
Pine versionv6current
Lines of code68
Settings2inputs
LicenceApache-2.0
Last update4 weeks ago27 Sep 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

68 lines of Pine Script v6 from lib/channels/accbands/accbands.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

accbands.pine
// Licensed under the Apache License, Version 2.0
// © mihakralj
//@version=6
indicator("Acceleration Bands (ACCBANDS)", "ACCBANDS", overlay=true)

//@function Calculates Acceleration Bands using Price Headley's original formula
//@param high Series of high prices
//@param low Series of low prices
//@param close Series of close prices
//@param period Lookback period for the moving average
//@param factor Multiplier for normalized width (default 4.0 per Headley)
//@returns tuple with [middle, upper, lower] band values
//@optimized Uses circular buffers with O(1) complexity per bar
accbands(series float high, series float low, series float close, simple int period, simple float factor = 4.0) =>
    if period <= 0 or factor <= 0.0
        runtime.error("Period and factor must be greater than 0")
    var int p = math.max(1, period)
    var int head = 0
    var int count = 0
    var array<float> bufferAdjHigh = array.new_float(p, na)
    var array<float> bufferAdjLow = array.new_float(p, na)
    var array<float> bufferClose = array.new_float(p, na)
    var float sumAdjHigh = 0.0
    var float sumAdjLow = 0.0
    var float sumClose = 0.0
    float oldestAdjHigh = array.get(bufferAdjHigh, head)
    float oldestAdjLow = array.get(bufferAdjLow, head)
    float oldestClose = array.get(bufferClose, head)
    if not na(oldestAdjHigh)
        sumAdjHigh -= oldestAdjHigh
        sumAdjLow -= oldestAdjLow
        sumClose -= oldestClose
        count -= 1
    float currentHigh = nz(high)
    float currentLow = nz(low)
    float currentClose = nz(close)
    // Headley's per-bar normalized width
    float denom = currentHigh + currentLow
    float w = denom != 0.0 ? (currentHigh - currentLow) / denom : 0.0
    float adjHigh = currentHigh * (1.0 + factor * w)
    float adjLow = currentLow * (1.0 - factor * w)
    sumAdjHigh += adjHigh
    sumAdjLow += adjLow
    sumClose += currentClose
    count += 1
    array.set(bufferAdjHigh, head, adjHigh)
    array.set(bufferAdjLow, head, adjLow)
    array.set(bufferClose, head, currentClose)
    head := (head + 1) % p
    float smaAdjHigh = nz(sumAdjHigh / count)
    float smaAdjLow = nz(sumAdjLow / count)
    float smaClose = nz(sumClose / count)
    [smaClose, smaAdjHigh, smaAdjLow]

// ---------- Main loop ----------

// Inputs
i_period = input.int(20, "Period", minval=1)
i_factor = input.float(4.0, "Factor", minval=0.001)

// Calculation
[middle, upper, lower] = accbands(high, low, close, i_period, i_factor)

// Plot
plot(middle, "Middle", color=color.yellow, linewidth=2)
p1 = plot(upper, "Upper", color=color.yellow, linewidth=2)
p2 = plot(lower, "Lower", color=color.yellow, linewidth=2)
fill(p1, p2, color=color.new(color.blue, 90), title="Band Fill")

Overview

Acceleration Bands (ACCBANDS) builds a middle line as a simple moving average of close, plus upper and lower bands from simple moving averages of highs and lows widened by a factor times the bar's high-low range divided by their sum. The period and factor inputs change the lookback and band width. It draws the three lines and a translucent fill between the outer bands. It does not generate trade signals or exits.

Details

Published by

mihakralj on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Volatility & bands, Moving averages

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

algorithmic-tradingcsharpdotnetpinescriptpythonquantitative-financesimdta-libtechnical-analysistechnical-indicators

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Periodint20i_period
Factorfloat4.0i_factor
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.

Similar Pine Scripts

Hampel Filter

by everget
948 stars

The Hampel Filter indicator identifies and filters out price outliers to smooth price data directly on the main chart. It calculates the rolling median and Median Absolute Deviation (MAD) of the chosen source series over a specified length. When a data point e

Indicator v4 Moving averagesVolatility & bands
Updated 10 days ago · GPL-3.0 GitHub repository of Hampel Filter

This overlay indicator plots a Supertrend from an ATR length and factor, four exponential moving averages, and a selectable VWAP or TWAP taken from a chosen timeframe on the price chart. It also shows MACD and stochastic with adjustable lengths, smoothing, ver

Indicator v5 Oscillators & momentumMoving averages
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup: Vijay Thakare Option Buying Scalping Setup

This indicator plots trade entry and exit signals on the price chart by combining Bollinger Bands with optional filter conditions. It calculates standard Bollinger Bands along with RSI, Aroon, and moving average filters. Reversal signals trigger when price bre

Indicator v4 Volatility & bandsOscillators & momentum
Updated 2 months ago · None stated GitHub repository of Bollinger Bands Winner IND [Alorse]
318 stars

This indicator plots four customizable moving averages directly on the main price chart using default lengths of 3, 8, 21, and 50 periods. It fills the space between adjacent averages in green or maroon depending on trend alignment. Additionally, it computes B

Indicator v5 Moving averagesTrend
Updated 2 months ago · MIT GitHub repository of Multiple Moving Averages

NVDA Trend Ribbon

by longsurf-ai
277 stars

This indicator plots three exponential moving averages and ATR volatility envelopes on the price chart. It compares the fast and slow EMAs to shade a trend ribbon and marks confirmed upward and downward crossovers with triangle labels. Settings change the thre

Indicator v6 TrendMoving averages
Updated yesterday · MIT GitHub repository of NVDA Trend Ribbon

Algo AVT

by ricardosantos79
261 stars

This indicator calculates an outlier-filtered moving average based on statistical filtering concepts. It stores close prices in a rolling array over a user-defined length, calculates the mean and standard deviation, and excludes values falling within a specifi

Indicator v4 Moving averagesVolatility & bands
Updated 4 years ago · None stated GitHub repository of Algo AVT

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers