Supported Indicators

Chande Momentum Oscillator

Introduction

This indicator computes the Chande Momentum Oscillator (CMO). CMO calculation is mostly identical to RSI. The only difference is in the last step of calculation: RSI = gain / (gain+loss) CMO = (gain-loss) / (gain+loss)

Create Manual Indicators

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

ChandeMomentumOscillator()1/2

            ChandeMomentumOscillator QuantConnect.Indicators.ChandeMomentumOscillator (
     int  period
   )
        

Initializes a new instance of the ChandeMomentumOscillator class using the specified period.

ChandeMomentumOscillator()2/2

            ChandeMomentumOscillator QuantConnect.Indicators.ChandeMomentumOscillator (
     string  name,
     int     period
   )
        

Initializes a new instance of the ChandeMomentumOscillator class using the specified name and period.

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 ChandeMomentumOscillator _cmo;

// In Initialize()
_cmo = new ChandeMomentumOscillator(name, period);
_cmo.Updated += IndicatorUpdateMethod;

RegisterIndicator(symbol, _cmo, Resolution.Daily);

// In IndicatorUpdateMethod()
if (_cmo.IsReady)
{
    var indicatorValue = _cmo.Current.Value;
}
    
# In Initialize()
self.cmo = ChandeMomentumOscillator(name, period)
self.cmo.Updated += self.IndicatorUpdateMethod

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

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

// In Initialize()
_cmo = new ChandeMomentumOscillator(period);
symbol = AddEquity("SPY").Symbol;

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

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

Create Automatic Indicators

The CMO method creates an ChandeMomentumOscillator 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 CMO method:

CMO()1/1

            ChandeMomentumOscillator QuantConnect.Algorithm.QCAlgorithm.CMO (
    Symbol                           symbol,
    Int32                            period,
    *Nullable<Resolution>      resolution,
    *Func<IBaseData, Decimal>  selector
   )
        

Creates a new ChandeMomentumOscillator 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 ChandeMomentumOscillator _cmo;

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

// In OnData()
if (_cmo.IsReady)
{
    var current = _cmo.Current.Value;
}
# In Initialize()
symbol = self.AddEquity("SPY").Symbol
self.cmo = self.CMO(symbol, period)

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

Visualization

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

private ChandeMomentumOscillator _cmo;

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

// In OnData()
if (_cmo.IsReady)
{
    Plot("My Indicators", "chandemomentumoscillator", _cmo.Current);
}
# In Initialize()
symbol = self.AddEquity("SPY").Symbol
self.cmo = self.CMO(symbol, period)

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