Supported Indicators

Acceleration Bands

Introduction

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

To view the implementation of this indicator, see the LEAN GitHub repository.

Using ABANDS Indicator

To create an automatic indicators for AccelerationBands, call the ABANDS helper method from the QCAlgorithm class. The ABANDS method creates a AccelerationBands object, hooks it up for automatic updates, and returns it so you can used it in your algorithm. In most cases, you should call the helper method in the Initialize method.

public class AccelerationBandsAlgorithm : QCAlgorithm
{
    private Symbol _symbol;
    private AccelerationBands _abands;

    public override void Initialize()
    {
        _symbol = AddEquity("SPY", Resolution.Daily).Symbol;
        _abands = ABANDS(_symbol, 10, 4, MovingAverageType.Simple);
    }

    public override void OnData(Slice data)
    {
        if (_abands.IsReady)
        {
            // The current value of _abands is represented by itself (_abands)
            // or _abands.Current.Value
            Plot("AccelerationBands", "abands", _abands);
            // Plot all properties of abands
            Plot("AccelerationBands", "middleband", _abands.MiddleBand);
            Plot("AccelerationBands", "upperband", _abands.UpperBand);
            Plot("AccelerationBands", "lowerband", _abands.LowerBand);
        }
    }
}
class AccelerationBandsAlgorithm(QCAlgorithm):
    def Initialize(self) -> None:
        self.symbol = self.AddEquity("SPY", Resolution.Daily).Symbol
        self.abands = self.ABANDS(self.symbol, 10, 4, MovingAverageType.Simple)

    def OnData(self, slice: Slice) -> None:
        if self.abands.IsReady:
            # The current value of self.abands is represented by self.abands.Current.Value
            self.Plot("AccelerationBands", "abands", self.abands.Current.Value)
            # Plot all attributes of self.abands
            self.Plot("AccelerationBands", "middleband", self.abands.MiddleBand.Current.Value)
            self.Plot("AccelerationBands", "upperband", self.abands.UpperBand.Current.Value)
            self.Plot("AccelerationBands", "lowerband", self.abands.LowerBand.Current.Value)

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 defaults 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.

For more information about plotting indicators, see Plotting Indicators.

The following table describes the MovingAverageType enumeration members:

To avoid parameter ambiguity, use the resolution argument to set the Resolution.

public class AccelerationBandsAlgorithm : QCAlgorithm
{
    private Symbol _symbol;
    private AccelerationBands _abands;

    public override void Initialize()
    {
        _symbol = AddEquity("SPY", Resolution.Hour).Symbol;
        _abands = ABANDS(_symbol, 10, 4, MovingAverageType.Simple, resolution: Resolution.Daily);
    }
}
class AccelerationBandsAlgorithm(QCAlgorithm):
    def Initialize(self) -> None:
        self.symbol = self.AddEquity("SPY", Resolution.Hour).Symbol
        self.abands = self.ABANDS(self.symbol, 10, 4, MovingAverageType.Simple, resolution=Resolution.Daily)

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.

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/number pair or an IndicatorDataPoint. The indicator will only be ready after you prime it with enough data.

public class AccelerationBandsAlgorithm : QCAlgorithm
{
    private Symbol _symbol;
    private AccelerationBands _abands;

    public override void Initialize()
    {
        _symbol = AddEquity("SPY", Resolution.Daily).Symbol;
        _abands = new AccelerationBands("", 10, 4, MovingAverageType.Simple);
    }

    public override void OnData(Slice data)
    {
        if (data.Bars.TryGetValue(_symbol, out var bar))
        {      
            _abands.Update(bar.EndTime, bar.Close);
        }
    
        if (_abands.IsReady)
        {
            // The current value of _abands is represented by itself (_abands)
            // or _abands.Current.Value
            Plot("AccelerationBands", "abands", _abands);
            // Plot all properties of abands
            Plot("AccelerationBands", "middleband", _abands.MiddleBand);
            Plot("AccelerationBands", "upperband", _abands.UpperBand);
            Plot("AccelerationBands", "lowerband", _abands.LowerBand);
        }
    }
}
class AccelerationBandsAlgorithm(QCAlgorithm):
    def Initialize(self) -> None:
        self.symbol = self.AddEquity("SPY", Resolution.Daily).Symbol
        self.abands = AccelerationBands("", 10, 4, MovingAverageType.Simple)

    def OnData(self, slice: Slice) -> None:
        bar = slice.Bars.get(self.symbol)
        if bar:
            self.abands.Update(bar.EndTime, bar.Close)
                
        if self.abands.IsReady:
            # The current value of self.abands is represented by self.abands.Current.Value
            self.Plot("AccelerationBands", "abands", self.abands.Current.Value)
            # Plot all attributes of self.abands
            self.Plot("AccelerationBands", "middleband", self.abands.MiddleBand.Current.Value)
            self.Plot("AccelerationBands", "upperband", self.abands.UpperBand.Current.Value)
            self.Plot("AccelerationBands", "lowerband", self.abands.LowerBand.Current.Value)

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

public class AccelerationBandsAlgorithm : QCAlgorithm
{
    private Symbol _symbol;
    private AccelerationBands _abands;

    public override void Initialize()
    {
        _symbol = AddEquity("SPY", Resolution.Daily).Symbol;
        _abands = new AccelerationBands("", 10, 4, MovingAverageType.Simple);
        RegisterIndicator(_symbol, _abands, Resolution.Daily);
    }

    public override void OnData(Slice data)
    {
        if (_abands.IsReady)
        {
            // The current value of _abands is represented by itself (_abands)
            // or _abands.Current.Value
            Plot("AccelerationBands", "abands", _abands);
            // Plot all properties of abands
            Plot("AccelerationBands", "middleband", _abands.MiddleBand);
            Plot("AccelerationBands", "upperband", _abands.UpperBand);
            Plot("AccelerationBands", "lowerband", _abands.LowerBand);
        }
    }
}
class AccelerationBandsAlgorithm(QCAlgorithm):
    def Initialize(self) -> None:
        self.symbol = self.AddEquity("SPY", Resolution.Daily).Symbol
        self.abands = AccelerationBands("", 10, 4, MovingAverageType.Simple)
        self.RegisterIndicator(self.symbol, self.abands, Resolution.Daily)

    def OnData(self, slice: Slice) -> None:
        if self.abands.IsReady:
            # The current value of self.abands is represented by self.abands.Current.Value
            self.Plot("AccelerationBands", "abands", self.abands.Current.Value)
            # Plot all attributes of self.abands
            self.Plot("AccelerationBands", "middleband", self.abands.MiddleBand.Current.Value)
            self.Plot("AccelerationBands", "upperband", self.abands.UpperBand.Current.Value)
            self.Plot("AccelerationBands", "lowerband", self.abands.LowerBand.Current.Value)

The following reference table describes the AccelerationBands constructor:

AccelerationBands()1/3

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

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.

Visualization

The following image shows plot values of selected properties of AccelerationBands using the plotly library.

AccelerationBands line plot.

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: