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:\n", outNBElement, outBegIdx );
printf( "upperBand = [%.4f, ..., %.4f]\n", upperBand[0], upperBand[outNBElement - 1] );
printf( "middleBand = [%.4f, ..., %.4f]\n", middleBand[0], middleBand[outNBElement - 1] );
printf( "lowerBand = [%.4f, ..., %.4f]\n", lowerBand[0], lowerBand[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 {}:", range.count, range.beg_idx);
println!("upper_band = [{:.4}, ..., {:.4}]", upper_band[0], upper_band[range.count - 1]);
println!("middle_band = [{:.4}, ..., {:.4}]", middle_band[0], middle_band[range.count - 1]);
println!("lower_band = [{:.4}, ..., {:.4}]", lower_band[0], lower_band[range.count - 1]);Java
import io.github.talib.Core;
import io.github.talib.OutRange;
import java.util.Locale;
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.printf(Locale.ROOT, "%d values from bar %d:%n", r.count(), r.begIdx());
System.out.printf(Locale.ROOT, "upperBand = [%.4f, ..., %.4f]%n", upperBand[0], upperBand[r.count() - 1]);
System.out.printf(Locale.ROOT, "middleBand = [%.4f, ..., %.4f]%n", middleBand[0], middleBand[r.count() - 1]);
System.out.printf(Locale.ROOT, "lowerBand = [%.4f, ..., %.4f]%n", lowerBand[0], lowerBand[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}:");
Console.WriteLine(FormattableString.Invariant($"upperBand = [{upperBand[0]:F4}, ..., {upperBand[r.Count - 1]:F4}]"));
Console.WriteLine(FormattableString.Invariant($"middleBand = [{middleBand[0]:F4}, ..., {middleBand[r.Count - 1]:F4}]"));
Console.WriteLine(FormattableString.Invariant($"lowerBand = [{lowerBand[0]:F4}, ..., {lowerBand[r.Count - 1]:F4}]"));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 + ':');
console.log('outUpperBand = [' + outUpperBand[0]?.toFixed(4) + ', ..., ' + outUpperBand[outUpperBand.length - 1]?.toFixed(4) + ']');
console.log('outMiddleBand = [' + outMiddleBand[0]?.toFixed(4) + ', ..., ' + outMiddleBand[outMiddleBand.length - 1]?.toFixed(4) + ']');
console.log('outLowerBand = [' + outLowerBand[0]?.toFixed(4) + ', ..., ' + outLowerBand[outLowerBand.length - 1]?.toFixed(4) + ']');Go
import (
"fmt"
"log"
talib "ta-lib.github.io/go"
)
high := make([]float64, 252) // your data, oldest first
low := make([]float64, 252) // your data, oldest first
close := make([]float64, 252) // your data, oldest first
upperBand := make([]float64, 252)
middleBand := make([]float64, 252)
lowerBand := make([]float64, 252)
core := talib.NewCore()
r, err := core.ACCBANDS(0, len(high)-1, high, low, close, 20, upperBand, middleBand, lowerBand)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%d values from bar %d:\n", r.NBElement, r.BegIdx)
fmt.Printf("upperBand = [%.4f, ..., %.4f]\n", upperBand[0], upperBand[r.NBElement-1])
fmt.Printf("middleBand = [%.4f, ..., %.4f]\n", middleBand[0], middleBand[r.NBElement-1])
fmt.Printf("lowerBand = [%.4f, ..., %.4f]\n", lowerBand[0], lowerBand[r.NBElement-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 |
| Go | accbands.go |
Python: talib.ACCBANDS, see ta-lib-python.
TA-Lib is also available for R and more using a wrapper.
Aliases
Acceleration Bands