Supported Indicators

Aroon Oscillator

Introduction

The Aroon Oscillator is the difference between AroonUp and AroonDown. The value of this indicator fluctuates between -100 and +100. An upward trend bias is present when the oscillator is positive, and a negative trend bias is present when the oscillator is negative. AroonUp/Down values over 75 identify strong trends in their respective direction.

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

Using AROON Indicator

To create an automatic indicators for AroonOscillator, call the AROON helper method from the QCAlgorithm class. The AROON method creates a AroonOscillator 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 AroonOscillatorAlgorithm : QCAlgorithm
{
    private Symbol _symbol;
    private AroonOscillator _aroon;

    public override void Initialize()
    {
        _symbol = AddEquity("SPY", Resolution.Daily).Symbol;
        _aroon = AROON(_symbol, 10, 20);
    }

    public override void OnData(Slice data)
    {
        if (_aroon.IsReady)
        {
            // The current value of _aroon is represented by itself (_aroon)
            // or _aroon.Current.Value
            Plot("AroonOscillator", "aroon", _aroon);
            // Plot all properties of aroon
            Plot("AroonOscillator", "aroonup", _aroon.AroonUp);
            Plot("AroonOscillator", "aroondown", _aroon.AroonDown);
        }
    }
}
class AroonOscillatorAlgorithm(QCAlgorithm):
    def Initialize(self) -> None:
        self.symbol = self.AddEquity("SPY", Resolution.Daily).Symbol
        self.aroon = self.AROON(self.symbol, 10, 20)

    def OnData(self, slice: Slice) -> None:
        if self.aroon.IsReady:
            # The current value of self.aroon is represented by self.aroon.Current.Value
            self.Plot("AroonOscillator", "aroon", self.aroon.Current.Value)
            # Plot all attributes of self.aroon
            self.Plot("AroonOscillator", "aroonup", self.aroon.AroonUp.Current.Value)
            self.Plot("AroonOscillator", "aroondown", self.aroon.AroonDown.Current.Value)

The following reference table describes the AROON method:

AROON()1/2

            AroonOscillator QuantConnect.Algorithm.QCAlgorithm.AROON (
    Symbol                                symbol,
    Int32                                 period,
    *Nullable<Resolution>           resolution,
    *Func<IBaseData, IBaseDataBar>  selector
   )
        

Creates a new AroonOscillator indicator which will compute the AroonUp and AroonDown (as well as the delta).

AROON()2/2

            AroonOscillator QuantConnect.Algorithm.QCAlgorithm.AROON (
    Symbol                                symbol,
    Int32                                 upPeriod,
    Int32                                 downPeriod,
    *Nullable<Resolution>           resolution,
    *Func<IBaseData, IBaseDataBar>  selector
   )
        

Creates a new AroonOscillator indicator which will compute the AroonUp and AroonDown (as well as the delta).

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.

You can manually create a AroonOscillator 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 a TradeBar or QuoteBar. The indicator will only be ready after you prime it with enough data.

public class AroonOscillatorAlgorithm : QCAlgorithm
{
    private Symbol _symbol;
    private AroonOscillator _aroon;

    public override void Initialize()
    {
        _symbol = AddEquity("SPY", Resolution.Daily).Symbol;
        _aroon = new AroonOscillator(10, 20);
    }

    public override void OnData(Slice data)
    {
        if (data.Bars.TryGetValue(_symbol, out var bar))
        {      
            _aroon.Update(bar);
        }
    
        if (_aroon.IsReady)
        {
            // The current value of _aroon is represented by itself (_aroon)
            // or _aroon.Current.Value
            Plot("AroonOscillator", "aroon", _aroon);
            // Plot all properties of aroon
            Plot("AroonOscillator", "aroonup", _aroon.AroonUp);
            Plot("AroonOscillator", "aroondown", _aroon.AroonDown);
        }
    }
}
class AroonOscillatorAlgorithm(QCAlgorithm):
    def Initialize(self) -> None:
        self.symbol = self.AddEquity("SPY", Resolution.Daily).Symbol
        self.aroon = AroonOscillator(10, 20)

    def OnData(self, slice: Slice) -> None:
        bar = slice.Bars.get(self.symbol)
        if bar:
            self.aroon.Update(bar)
                
        if self.aroon.IsReady:
            # The current value of self.aroon is represented by self.aroon.Current.Value
            self.Plot("AroonOscillator", "aroon", self.aroon.Current.Value)
            # Plot all attributes of self.aroon
            self.Plot("AroonOscillator", "aroonup", self.aroon.AroonUp.Current.Value)
            self.Plot("AroonOscillator", "aroondown", self.aroon.AroonDown.Current.Value)

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

public class AroonOscillatorAlgorithm : QCAlgorithm
{
    private Symbol _symbol;
    private AroonOscillator _aroon;

    public override void Initialize()
    {
        _symbol = AddEquity("SPY", Resolution.Daily).Symbol;
        _aroon = new AroonOscillator(10, 20);
        RegisterIndicator(_symbol, _aroon, Resolution.Daily);
    }

    public override void OnData(Slice data)
    {
        if (_aroon.IsReady)
        {
            // The current value of _aroon is represented by itself (_aroon)
            // or _aroon.Current.Value
            Plot("AroonOscillator", "aroon", _aroon);
            // Plot all properties of aroon
            Plot("AroonOscillator", "aroonup", _aroon.AroonUp);
            Plot("AroonOscillator", "aroondown", _aroon.AroonDown);
        }
    }
}
class AroonOscillatorAlgorithm(QCAlgorithm):
    def Initialize(self) -> None:
        self.symbol = self.AddEquity("SPY", Resolution.Daily).Symbol
        self.aroon = AroonOscillator(10, 20)
        self.RegisterIndicator(self.symbol, self.aroon, Resolution.Daily)

    def OnData(self, slice: Slice) -> None:
        if self.aroon.IsReady:
            # The current value of self.aroon is represented by self.aroon.Current.Value
            self.Plot("AroonOscillator", "aroon", self.aroon.Current.Value)
            # Plot all attributes of self.aroon
            self.Plot("AroonOscillator", "aroonup", self.aroon.AroonUp.Current.Value)
            self.Plot("AroonOscillator", "aroondown", self.aroon.AroonDown.Current.Value)

The following reference table describes the AroonOscillator constructor:

AroonOscillator()1/2

            AroonOscillator QuantConnect.Indicators.AroonOscillator (
    int  upPeriod,
    int  downPeriod
   )
        

Creates a new AroonOscillator from the specified up/down periods.

AroonOscillator()2/2

            AroonOscillator QuantConnect.Indicators.AroonOscillator (
    string  name,
    int     upPeriod,
    int     downPeriod
   )
        

Creates a new AroonOscillator from the specified up/down periods.

Visualization

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

AroonOscillator 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: