Acceleration Bands (ACCBANDS)
Summary
Acceleration Bands: three overlap lines around price. The middle band is an SMA of the close; the upper/lower bands are SMAs of the high/low scaled by an intraday-range factor.
Chart
Chart metadata i
Outputs
outRealUpperBand:upper_limitoutRealMiddleBand:lineoutRealLowerBand:lower_limit
Formula
factor = 4*(H-L)/(H+L) upperRaw = H*(1+factor), lowerRaw = L*(1-factor) Upper = SMA(upperRaw, N), Middle = SMA(Close, N), Lower = SMA(lowerRaw, N)
Inputs
inHigh— High price of each barinLow— Low price of each barinClose— Close price of each bar
Outputs
outRealUpperBand— SMA of the range-scaled high bandoutRealMiddleBand— SMA of the closeoutRealLowerBand— SMA of the range-scaled low band
Parameters
| Parameter | Type | Default | Accepted values | Description |
|---|---|---|---|---|
optInTimePeriod | integer | 20 | 2–100000 | SMA smoothing period for all three bands |
Properties
Numerical Stability: Start-Independent
| ✅ Overlap Input i |
| ☐ Independent Y-Axis |
| ☐ Candlestick |
| ☐ Display Shift |
| ☐ Can Output NaN or ±Inf |
| ☐ Identity at Period 1 |
| ☐ Uses Transcendental |
| ☐ Input Must Be Positive |
Example
C
#include <stdio.h>
#include <ta_libc.h>
int n = 252;
double high[252]; /* your data, oldest first */
double low[252]; /* your data, oldest first */
double close[252]; /* your data, oldest first */
double upperBand[252], middleBand[252], lowerBand[252];
int outBegIdx, outNBElement;
TA_Initialize();
TA_ACCBANDS( 0, n - 1, high, low, close, 20,
&outBegIdx, &outNBElement, upperBand, middleBand, lowerBand );
printf( "%d values from bar %d; last upperBand = %f\n", outNBElement, outBegIdx, upperBand[outNBElement - 1] );Rust
use ta_lib::Core;
let high = vec![0.0; 252]; // your data, oldest first
let low = vec![0.0; 252]; // your data, oldest first
let close = vec![0.0; 252]; // your data, oldest first
let mut upper_band = vec![0.0; 252];
let mut middle_band = vec![0.0; 252];
let mut lower_band = vec![0.0; 252];
let core = Core::new();
let range = core.accbands(0, high.len() - 1, &high, &low, &close, 20,
&mut upper_band, &mut middle_band, &mut lower_band)?;
println!("{} values from bar {}; last upper_band = {}", range.count, range.beg_idx, upper_band[range.count - 1]);Java
import io.github.talib.Core;
import io.github.talib.OutRange;
double[] high = new double[252]; // your data, oldest first
double[] low = new double[252]; // your data, oldest first
double[] close = new double[252]; // your data, oldest first
double[] upperBand = new double[252];
double[] middleBand = new double[252];
double[] lowerBand = new double[252];
Core core = Core.DEFAULT;
OutRange r = core.accbands(0, high.length - 1, high, low, close, 20,
upperBand, middleBand, lowerBand);
System.out.println(r.count() + " values from bar " + r.begIdx() + "; last upperBand = " + upperBand[r.count() - 1]);C#
using System;
using TALib;
var high = new double[252]; // your data, oldest first
var low = new double[252]; // your data, oldest first
var close = new double[252]; // your data, oldest first
var upperBand = new double[252];
var middleBand = new double[252];
var lowerBand = new double[252];
var core = Core.Default;
OutRange r = core.Accbands(0, high.Length - 1, high, low, close, 20,
upperBand, middleBand, lowerBand);
Console.WriteLine($"{r.Count} values from bar {r.BegIdx}; last upperBand = {upperBand[r.Count - 1]}");TypeScript
import { accbands } from 'ta-lib';
const high = new Float64Array(252); // your data, oldest first
const low = new Float64Array(252); // your data, oldest first
const close = new Float64Array(252); // your data, oldest first
const {
begIdx,
outUpperBand,
outMiddleBand,
outLowerBand,
} = accbands({ high, low, close }, { timePeriod: 20 });
console.log(outUpperBand.length + ' values from bar ' + begIdx + '; last outUpperBand = ' + outUpperBand[outUpperBand.length - 1]);Implementation
Added in 0.5.0.
TA-Lib Definition: accbands.c · accbands.yaml
| Native | File |
|---|---|
| C | ta_ACCBANDS.c |
| Rust | accbands.rs |
| Java | Core_ACCBANDS.java |
| C# | Core_ACCBANDS.cs |
| TypeScript | accbands.ts |
Python: talib.ACCBANDS, see ta-lib-python.
TA-Lib is also available for R and more using a wrapper.
Aliases
Acceleration Bands