Supported Indicators

Awesome Oscillator

Introduction

The Awesome Oscillator Indicator tracks the price midpoint-movement of a security. Specifically, AO = MAfast[(H+L)/2] - MAslow[(H+L)/2] where MAfast and MAslow denote simple moving averages wherein fast has a shorter period. https://www.barchart.com/education/technical-indicators/awesome_oscillator

Create Manual Indicators

You can manually create a AwesomeOscillator 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 AwesomeOscillator constructor.

AwesomeOscillator()1/2

            AwesomeOscillator QuantConnect.Indicators.AwesomeOscillator (
     int                slowPeriod,
     MovingAverageType  type=MovingAverageType.Simple
   )
        

Creates a new Awesome Oscillator from the specified periods.

AwesomeOscillator()2/2

            AwesomeOscillator QuantConnect.Indicators.AwesomeOscillator (
     string  name,
     int     slowPeriod
   )
        

Creates a new Awesome Oscillator from the specified periods.

The following table shows the MovingAverageType enumeration members and the indicator that implements each one:

MovingAverageTypeUnderlying Indicator
SimpleSimple Moving Average
ExponentialExponential Moving Average
WildersWilder Moving Average
LinearWeightedMovingAverageLinear Weighted Moving Average
DoubleExponentialDouble Exponential Moving Average
TripleExponentialTriple Exponential Moving Average
TriangularTriangular Moving Average
T3T3 Moving Average
KamaKaufman Adaptive Moving Average
HullHull Moving Average
AlmaArnaud Legoux Moving Average

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 AwesomeOscillator _ao;

// In Initialize()
_ao = new AwesomeOscillator(name, fastPeriod, slowPeriod, type);
_ao.Updated += IndicatorUpdateMethod;

RegisterIndicator(symbol, _ao, Resolution.Daily);

// In IndicatorUpdateMethod()
if (_ao.IsReady)
{
    var indicatorValue = _ao.Current.Value;
}
    
# In Initialize()
self.ao = AwesomeOscillator(name, fastPeriod, slowPeriod, type)
self.ao.Updated += self.IndicatorUpdateMethod

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

# In IndicatorUpdateMethod()
if self.ao.IsReady:
    indicator_value = self.ao.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 a TradeBar, QuoteBar, or an IndicatorDataPoint. The indicator will only be ready after you prime it with enough data.

    
private AwesomeOscillator _ao;
private Symbol symbol;

// In Initialize()
_ao = new AwesomeOscillator(fastPeriod, slowPeriod, type);
symbol = AddEquity("SPY").Symbol;

// In OnData()
if (data.QuoteBars.ContainsKey(_symbol))
{
    _ao.Update(data.QuoteBars[symbol]);
}
if (_ao.IsReady)
{
    var indicatorValue = _ao.Current.Value;
}
    
# In Initialize()
self.ao = AwesomeOscillator(fastPeriod, slowPeriod, type)
self.symbol = self.AddEquity("SPY").Symbol

# In OnData()
if data.QuoteBars.ContainsKey(self.symbol):
    self.ao.Update(data.QuoteBars[self.symbol])
if self.ao.IsReady:
    indicator_value = self.ao.Current.Value

Create Automatic Indicators

The AO method creates an AwesomeOscillator 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 AO method:

AO()1/1

            AwesomeOscillator QuantConnect.Algorithm.QCAlgorithm.AO (
    Symbol                                symbol,
    Int32                                 slowPeriod,
    Int32                                 fastPeriod,
    MovingAverageType                     type,
    *Nullable<Resolution>           resolution,
    *Func<IBaseData, IBaseDataBar>  selector
   )
        

Creates a new Awesome Oscillator from the specified periods.


The following table shows the MovingAverageType enumeration members and the indicator that implements each one:

MovingAverageTypeUnderlying Indicator
SimpleSimple Moving Average
ExponentialExponential Moving Average
WildersWilder Moving Average
LinearWeightedMovingAverageLinear Weighted Moving Average
DoubleExponentialDouble Exponential Moving Average
TripleExponentialTriple Exponential Moving Average
TriangularTriangular Moving Average
T3T3 Moving Average
KamaKaufman Adaptive Moving Average
HullHull Moving Average
AlmaArnaud Legoux Moving Average

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.

Get Indicator Values

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

private AwesomeOscillator _ao;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_ao = AO(symbol, slowPeriod, fastPeriod, type);

// In OnData()
if (_ao.IsReady)
{
    var slowAo = _ao.SlowAo.Current.Value;
    var fastAo = _ao.FastAo.Current.Value;
    var current = _ao.Current.Value;
}
# In Initialize()
symbol = self.AddEquity("SPY").Symbol
self.ao = self.AO(symbol, slowPeriod, fastPeriod, type)

# In OnData()
if self.ao.IsReady:
    slow_ao = self.ao.SlowAo.Current.Value
    fast_ao = self.ao.FastAo.Current.Value
    current = self.ao.Current.Value

Visualization

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

private AwesomeOscillator _ao;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_ao = AO(symbol, slowPeriod, fastPeriod, type);

// In OnData()
if (_ao.IsReady)
{
    Plot("My Indicators", "slowao", _ao.SlowAo);
    Plot("My Indicators", "fastao", _ao.FastAo);
    Plot("My Indicators", "awesomeoscillator", _ao.Current);
}
# In Initialize()
symbol = self.AddEquity("SPY").Symbol
self.ao = self.AO(symbol, slowPeriod, fastPeriod, type)

# In OnData()
if self.ao.IsReady:
    self.Plot("My Indicators", "slowao", self.ao.SlowAo)
    self.Plot("My Indicators", "fastao", self.ao.FastAo)
    self.Plot("My Indicators", "awesomeoscillator", self.ao.Current)

The following image shows the plot values in a matplotlib plot. To load algorithm plot data into the Research Environment, see Charts.

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: