Supported Indicators

Ultimate Oscillator

Introduction

This indicator computes the Ultimate Oscillator (ULTOSC) The Ultimate Oscillator is calculated as explained here: http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:ultimate_oscillator

Create Manual Indicators

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

UltimateOscillator()1/2

            UltimateOscillator QuantConnect.Indicators.UltimateOscillator (
     int  period3
   )
        

Initializes a new instance of the UltimateOscillator class using the specified parameters.

UltimateOscillator()2/2

            UltimateOscillator QuantConnect.Indicators.UltimateOscillator (
     string  name,
     int     period3
   )
        

Initializes a new instance of the UltimateOscillator class using the specified parameters.

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 UltimateOscillator _ultosc;

// In Initialize()
_ultosc = new UltimateOscillator(name, period1, period2, period3);
_ultosc.Updated += IndicatorUpdateMethod;

RegisterIndicator(symbol, _ultosc, Resolution.Daily);

// In IndicatorUpdateMethod()
if (_ultosc.IsReady)
{
    var indicatorValue = _ultosc.Current.Value;
}
    
# In Initialize()
self.ultosc = UltimateOscillator(name, period1, period2, period3)
self.ultosc.Updated += self.IndicatorUpdateMethod

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

# In IndicatorUpdateMethod()
if self.ultosc.IsReady:
    indicator_value = self.ultosc.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 UltimateOscillator _ultosc;
private Symbol symbol;

// In Initialize()
_ultosc = new UltimateOscillator(period1, period2, period3);
symbol = AddEquity("SPY").Symbol;

// In OnData()
if (data.QuoteBars.ContainsKey(_symbol))
{
    _ultosc.Update(data.QuoteBars[symbol]);
}
if (_ultosc.IsReady)
{
    var indicatorValue = _ultosc.Current.Value;
}
    
# In Initialize()
self.ultosc = UltimateOscillator(period1, period2, period3)
self.symbol = self.AddEquity("SPY").Symbol

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

Create Automatic Indicators

The ULTOSC method creates an UltimateOscillator 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 ULTOSC method:

ULTOSC()1/1

            UltimateOscillator QuantConnect.Algorithm.QCAlgorithm.ULTOSC (
    Symbol                                symbol,
    Int32                                 period1,
    Int32                                 period2,
    Int32                                 period3,
    *Nullable<Resolution>           resolution,
    *Func<IBaseData, IBaseDataBar>  selector
   )
        

Creates a new UltimateOscillator 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.

Get Indicator Values

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

private UltimateOscillator _ultosc;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_ultosc = ULTOSC(symbol, period1, period2, period3);

// In OnData()
if (_ultosc.IsReady)
{
    var current = _ultosc.Current.Value;
}
# In Initialize()
symbol = self.AddEquity("SPY").Symbol
self.ultosc = self.ULTOSC(symbol, period1, period2, period3)

# In OnData()
if self.ultosc.IsReady:
    current = self.ultosc.Current.Value

Visualization

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

private UltimateOscillator _ultosc;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_ultosc = ULTOSC(symbol, period1, period2, period3);

// In OnData()
if (_ultosc.IsReady)
{
    Plot("My Indicators", "ultimateoscillator", _ultosc.Current);
}
# In Initialize()
symbol = self.AddEquity("SPY").Symbol
self.ultosc = self.ULTOSC(symbol, period1, period2, period3)

# In OnData()
if self.ultosc.IsReady:
    self.Plot("My Indicators", "ultimateoscillator", self.ultosc.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: