Indicator Reference

Acceleration Bands

Introduction

The Acceleration Bands created by Price Headley plots upper and lower envelope bands around a moving average.

Create Manual Indicators

You can manually create a AccelerationBands indicator, so it doesn’t automatically update. Manual indicators let you update their values with any data you choose. The following reference table describes the AccelerationBands constructor.

AccelerationBands()1/3

            AccelerationBands QuantConnect.Indicators.AccelerationBands (
     string   name,
     int      period,
     decimal  width,
   )
        

Initializes a new instance of the AccelerationBands class.

AccelerationBands()2/3

            AccelerationBands QuantConnect.Indicators.AccelerationBands (
     int      period,
     decimal  width
   )
        

Initializes a new instance of the AccelerationBands class.

AccelerationBands()3/3

            AccelerationBands QuantConnect.Indicators.AccelerationBands (
     int  period
   )
        

Initializes a new instance of the AccelerationBands class.

Update Manual Indicators

You can update the indicator automatically or manually.

Automatic Update

To register a manual indicator for automatic updates with the security data, call the RegisterIndicator method.


private AccelerationBands _abands;

// In Initialize()
_abands = new AccelerationBands(name, period, width, movingAverageType);
_abands.Updated += IndicatorUpdateMethod;

RegisterIndicator(symbol, _abands, Resolution.Daily);

// In IndicatorUpdateMethod()
if (_abands.IsReady)
{
    var indicatorValue = _abands.Current.Value;
}
    
# In Initialize()
self.abands = AccelerationBands(name, period, width, movingAverageType)
self.abands.Updated += self.IndicatorUpdateMethod

self.RegisterIndicator(symbol, self.abands, Resolution.Daily)

# In IndicatorUpdateMethod()
if self.abands.IsReady:
    indicator_value = self.abands.Current.Value

To customize the data that automatically updates the indicator, see Custom Indicator Periods and Custom Indicator Values.

Manual Update

Updating your indicator manually enables you to control when the indicator is updated and what data you use to update it. To manually update the indicator, call the Update method with time/decimal pair. The indicator will only be ready after you prime it with enough data.

    
private AccelerationBands _abands;
private Symbol symbol;

// In Initialize()
_abands = new AccelerationBands(period, width, movingAverageType);
symbol = AddEquity("SPY").Symbol;

// In OnData()
if (data.ContainsKey(_symbol))
{
    _abands.Update(data[symbol].EndTime, data[symbol].High);
}
if (_abands.IsReady)
{
    var indicatorValue = _abands.Current.Value;
}
    
# In Initialize()
self.abands = AccelerationBands(period, width, movingAverageType)
self.symbol = self.AddEquity("SPY").Symbol

# In OnData()
if data.ContainsKey(self.symbol):
    self.abands.Update(data[self.symbol].EndTime, data[self.symbol].High)
if self.abands.IsReady:
    indicator_value = self.abands.Current.Value

Create Automatic Indicators

The ABANDS method creates an AccelerationBands indicator, sets up a consolidator to update the indicator, and then returns the indicator so you can use it in your algorithm.

The following reference table describes the ABANDS method:

ABANDS()1/1

            AccelerationBands QuantConnect.Algorithm.QCAlgorithm.ABANDS (
    Symbol                            symbol,
    Int32                             period,
    *Decimal                          width,
    *MovingAverageType                movingAverageType,
    *Nullable<Resolution>       resolution,
    *Func<IBaseData, TradeBar>  selector
   )
        

Creates a new Acceleration Bands indicator.


If you don't provide a resolution, it defauls to the security resolution. If you provide a resolution, it must be greater than or equal to the resolution of the security. For instance, if you subscribe to hourly data for a security, you should update its indicator with data that spans 1 hour or longer.

For more information about the selector argument, see Alternative Price Fields.

Get Indicator Values

To get the value of the indicator, use its Current.Value attribute.

private AccelerationBands _abands;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_abands = ABANDS(symbol, period);

// In OnData()
if (_abands.IsReady)
{
    var middleBand = _abands.MiddleBand.Current.Value;
    var upperBand = _abands.UpperBand.Current.Value;
    var lowerBand = _abands.LowerBand.Current.Value;
    var current = _abands.Current.Value;
}
# In Initialize()
symbol = self.AddEquity("SPY").Symbol
self.abands = self.ABANDS(symbol, period)

# In OnData()
if self.abands.IsReady:
    middle_band = self.abands.MiddleBand.Current.Value
    upper_band = self.abands.UpperBand.Current.Value
    lower_band = self.abands.LowerBand.Current.Value
    current = self.abands.Current.Value

Visualization

To plot indicator values, in the OnData event handler, call the Plot method.

private AccelerationBands _abands;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_abands = ABANDS(symbol, period);

// In OnData()
if (_abands.IsReady)
{
    Plot("My Indicators", "middleband", _abands.MiddleBand);
    Plot("My Indicators", "upperband", _abands.UpperBand);
    Plot("My Indicators", "lowerband", _abands.LowerBand);
    Plot("My Indicators", "accelerationbands", _abands.Current);
}
# In Initialize()
symbol = self.AddEquity("SPY").Symbol
self.abands = self.ABANDS(symbol, period)

# In OnData()
if self.abands.IsReady:
    self.Plot("My Indicators", "middleband", self.abands.MiddleBand)
    self.Plot("My Indicators", "upperband", self.abands.UpperBand)
    self.Plot("My Indicators", "lowerband", self.abands.LowerBand)
    self.Plot("My Indicators", "accelerationbands", self.abands.Current)

For more information about plotting indicators, see Plotting Indicators.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: