Contents
Indicator Reference
Momersion Indicator
Introduction
Oscillator indicator that measures momentum and mean-reversion over a specified period n. sourceHarris, Michael. "Momersion Indicator." Price Action Lab., 13 Aug. 2015. Web.
Create Manual Indicators
You can manually create a MomersionIndicator
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 MomersionIndicator
constructor.
MomersionIndicator()1/3
MomersionIndicator QuantConnect.Indicators.MomersionIndicator (string
name,int?
minPeriod,int
fullPeriod )
Initializes a new instance of the MomersionIndicator
class.
MomersionIndicator()2/3
MomersionIndicator QuantConnect.Indicators.MomersionIndicator (int?
minPeriod,int
fullPeriod )
Initializes a new instance of the MomersionIndicator
class.
MomersionIndicator()3/3
MomersionIndicator QuantConnect.Indicators.MomersionIndicator (
int
fullPeriod
)
Initializes a new instance of the MomersionIndicator
class.
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 MomersionIndicator _momersion; // In Initialize() _momersion = new MomersionIndicator(name, minPeriod, fullPeriod); _momersion.Updated += IndicatorUpdateMethod; RegisterIndicator(symbol, _momersion, Resolution.Daily); // In IndicatorUpdateMethod() if (_momersion.IsReady) { var indicatorValue = _momersion.Current.Value; }
# In Initialize() self.momersion = MomersionIndicator(name, minPeriod, fullPeriod) self.momersion.Updated += self.IndicatorUpdateMethod self.RegisterIndicator(symbol, self.momersion, Resolution.Daily) # In IndicatorUpdateMethod() if self.momersion.IsReady: indicator_value = self.momersion.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 MomersionIndicator _momersion; private Symbol symbol; // In Initialize() _momersion = new MomersionIndicator(minPeriod, fullPeriod); symbol = AddEquity("SPY").Symbol; // In OnData() if (data.ContainsKey(_symbol)) { _momersion.Update(data[symbol].EndTime, data[symbol].High); } if (_momersion.IsReady) { var indicatorValue = _momersion.Current.Value; }
# In Initialize() self.momersion = MomersionIndicator(minPeriod, fullPeriod) self.symbol = self.AddEquity("SPY").Symbol # In OnData() if data.ContainsKey(self.symbol): self.momersion.Update(data[self.symbol].EndTime, data[self.symbol].High) if self.momersion.IsReady: indicator_value = self.momersion.Current.Value
Create Automatic Indicators
The MOMERSION method creates an MomersionIndicator 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 MOMERSION
method:
MOMERSION()1/1
MomersionIndicator QuantConnect.Algorithm.QCAlgorithm.MOMERSION (Symbol
symbol,Nullable<Int32>
minPeriod,Int32
fullPeriod,*Nullable<Resolution>
resolution,*Func<IBaseData, Decimal>
selector )
Creates a new Momersion indicator.
If you don't provide a resolution, it defauls 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 MomersionIndicator _momersion; // In Initialize() var symbol = AddEquity("SPY").Symbol; _momersion = MOMERSION(symbol, minPeriod, fullPeriod); // In OnData() if (_momersion.IsReady) { var current = _momersion.Current.Value; }
# In Initialize() symbol = self.AddEquity("SPY").Symbol self.momersion = self.MOMERSION(symbol, minPeriod, fullPeriod) # In OnData() if self.momersion.IsReady: current = self.momersion.Current.Value
Visualization
To plot indicator values, in the OnData
event handler, call the Plot
method.
private MomersionIndicator _momersion; // In Initialize() var symbol = AddEquity("SPY").Symbol; _momersion = MOMERSION(symbol, minPeriod, fullPeriod); // In OnData() if (_momersion.IsReady) { Plot("My Indicators", "momersionindicator", _momersion.Current); }
# In Initialize() symbol = self.AddEquity("SPY").Symbol self.momersion = self.MOMERSION(symbol, minPeriod, fullPeriod) # In OnData() if self.momersion.IsReady: self.Plot("My Indicators", "momersionindicator", self.momersion.Current)
For more information about plotting indicators, see Plotting Indicators.