Contents
Candlestick Pattern
Engulfing
Create Manual Indicators
A candlestick pattern indicator requires manual creation and update with a TradeBar
object. Manual indicators let you update their values with any data you choose. The following reference table describes the Engulfing
constructor.
Engulfing()1/2
Engulfing QuantConnect.Indicators.CandlestickPatterns.Engulfing (
string
name
)
Initializes a new instance of the Engulfing
class using the specified name.
Engulfing()2/2
Engulfing QuantConnect.Indicators.CandlestickPatterns.Engulfing ( )
Initializes a new instance of the Engulfing
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.
using QuantConnect.Indicators.CandlestickPatterns; private Engulfing _engulfing; // In Initialize() _engulfing = new Engulfing(name); _engulfing.Updated += IndicatorUpdateMethod; RegisterIndicator(symbol, _engulfing, Resolution.Daily); // In IndicatorUpdateMethod() if (_engulfing.IsReady) { var indicatorValue = _engulfing.Current.Value; }
from QuantConnect.Indicators.CandlestickPatterns import Engulfing # In Initialize() self.engulfing = Engulfing(name) self.engulfing.Updated += self.IndicatorUpdateMethod self.RegisterIndicator(symbol, self.engulfing, Resolution.Daily) # In IndicatorUpdateMethod() if self.engulfing.IsReady: indicator_value = self.engulfing.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
. The indicator will only be ready after you prime it with enough data.
using QuantConnect.Indicators.CandlestickPatterns; private Engulfing _engulfing; private Symbol symbol; // In Initialize() _engulfing = new Engulfing(); symbol = AddEquity("SPY").Symbol; // In OnData() if (data.Bars.ContainsKey(_symbol)) { _engulfing.Update(data.Bars[symbol]); } if (_engulfing.IsReady) { var indicatorValue = _engulfing.Current.Value; }
from QuantConnect.Indicators.CandlestickPatterns import Engulfing # In Initialize() self.engulfing = Engulfing() self.symbol = self.AddEquity("SPY").Symbol # In OnData() if data.Bars.ContainsKey(self.symbol): self.engulfing.Update(data.Bars[self.symbol]) if self.engulfing.IsReady: indicator_value = self.engulfing.Current.Value
Get Indicator Values
To get the value of the indicator, use its Current.Value
attribute.
private Engulfing _engulfing; // In Initialize() var symbol = AddEquity("SPY").Symbol; _engulfing = Engulfing(symbol); // In OnData() if (_engulfing.IsReady) { var current = _engulfing.Current.Value; }
# In Initialize() symbol = self.AddEquity("SPY").Symbol self.engulfing = self.Engulfing(symbol) # In OnData() if self.engulfing.IsReady: current = self.engulfing.Current.Value
Visualization
To plot indicator values, in the OnData
event handler, call the Plot
method.
private Engulfing _engulfing; // In Initialize() var symbol = AddEquity("SPY").Symbol; _engulfing = Engulfing(symbol); // In OnData() if (_engulfing.IsReady) { Plot("My Indicators", "engulfing", _engulfing.Current); }
# In Initialize() symbol = self.AddEquity("SPY").Symbol self.engulfing = self.Engulfing(symbol) # In OnData() if self.engulfing.IsReady: self.Plot("My Indicators", "engulfing", self.engulfing.Current)
For more information about plotting indicators, see Plotting Indicators.