Contents
Indicator Reference
De Marker Indicator
Introduction
In the DeMarker strategy, for some period of size N, set:
Create Manual Indicators
You can manually create a DeMarkerIndicator
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 DeMarkerIndicator
constructor.
DeMarkerIndicator()1/2
DeMarkerIndicator QuantConnect.Indicators.DeMarkerIndicator (int
period,*MovingAverageType
type )
Initializes a new instance of the DeMarkerIndicator class with the specified period.
DeMarkerIndicator()2/2
DeMarkerIndicator QuantConnect.Indicators.DeMarkerIndicator (string
name,int
period,*MovingAverageType
type )
Initializes a new instance of the DeMarkerIndicator class with the specified name and period.
The following table shows the MovingAverageType
enumeration members and the indicator that implements each one:
MovingAverageType | Underlying Indicator |
---|---|
Simple | Simple Moving Average |
Exponential | Exponential Moving Average |
Wilders | Wilder Moving Average |
LinearWeightedMovingAverage | Linear Weighted Moving Average |
DoubleExponential | Double Exponential Moving Average |
TripleExponential | Triple Exponential Moving Average |
Triangular | Triangular Moving Average |
T3 | T3 Moving Average |
Kama | Kaufman Adaptive Moving Average |
Hull | Hull Moving Average |
Alma | Arnaud 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 DeMarkerIndicator _dem; // In Initialize() _dem = new DeMarkerIndicator(name, period); _dem.Updated += IndicatorUpdateMethod; RegisterIndicator(symbol, _dem, Resolution.Daily); // In IndicatorUpdateMethod() if (_dem.IsReady) { var indicatorValue = _dem.Current.Value; }
# In Initialize() self.dem = DeMarkerIndicator(name, period) self.dem.Updated += self.IndicatorUpdateMethod self.RegisterIndicator(symbol, self.dem, Resolution.Daily) # In IndicatorUpdateMethod() if self.dem.IsReady: indicator_value = self.dem.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 DeMarkerIndicator _dem; private Symbol symbol; // In Initialize() _dem = new DeMarkerIndicator(period); symbol = AddEquity("SPY").Symbol; // In OnData() if (data.QuoteBars.ContainsKey(_symbol)) { _dem.Update(data.QuoteBars[symbol]); } if (_dem.IsReady) { var indicatorValue = _dem.Current.Value; }
# In Initialize() self.dem = DeMarkerIndicator(period) self.symbol = self.AddEquity("SPY").Symbol # In OnData() if data.QuoteBars.ContainsKey(self.symbol): self.dem.Update(data.QuoteBars[self.symbol]) if self.dem.IsReady: indicator_value = self.dem.Current.Value
Create Automatic Indicators
The DEM method creates an DeMarkerIndicator 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 DEM
method:
DEM()1/1
DeMarkerIndicator QuantConnect.Algorithm.QCAlgorithm.DEM (Symbol
symbol,Int32
period,MovingAverageType
type,*Nullable<Resolution>
resolution,*Func<IBaseData, TradeBar>
selector )
Creates a new DeMarker Indicator (DEM), an oscillator-type indicator measuring changes in terms of an asset's High and Low tradebar values.
The following table shows the MovingAverageType
enumeration members and the indicator that implements each one:
MovingAverageType | Underlying Indicator |
---|---|
Simple | Simple Moving Average |
Exponential | Exponential Moving Average |
Wilders | Wilder Moving Average |
LinearWeightedMovingAverage | Linear Weighted Moving Average |
DoubleExponential | Double Exponential Moving Average |
TripleExponential | Triple Exponential Moving Average |
Triangular | Triangular Moving Average |
T3 | T3 Moving Average |
Kama | Kaufman Adaptive Moving Average |
Hull | Hull Moving Average |
Alma | Arnaud Legoux Moving Average |
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 DeMarkerIndicator _dem; // In Initialize() var symbol = AddEquity("SPY").Symbol; _dem = DEM(symbol, period, type); // In OnData() if (_dem.IsReady) { var current = _dem.Current.Value; }
# In Initialize() symbol = self.AddEquity("SPY").Symbol self.dem = self.DEM(symbol, period, type) # In OnData() if self.dem.IsReady: current = self.dem.Current.Value
Visualization
To plot indicator values, in the OnData
event handler, call the Plot
method.
private DeMarkerIndicator _dem; // In Initialize() var symbol = AddEquity("SPY").Symbol; _dem = DEM(symbol, period, type); // In OnData() if (_dem.IsReady) { Plot("My Indicators", "demarkerindicator", _dem.Current); }
# In Initialize() symbol = self.AddEquity("SPY").Symbol self.dem = self.DEM(symbol, period, type) # In OnData() if self.dem.IsReady: self.Plot("My Indicators", "demarkerindicator", self.dem.Current)
For more information about plotting indicators, see Plotting Indicators.