Contents
Candlestick Pattern
Harami
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 Harami
constructor.
Harami()1/2
Harami QuantConnect.Indicators.CandlestickPatterns.Harami (
string
name
)
Initializes a new instance of the Harami
class using the specified name.
Harami()2/2
Harami QuantConnect.Indicators.CandlestickPatterns.Harami ( )
Initializes a new instance of the Harami
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 Harami _harami; // In Initialize() _harami = new Harami(name); _harami.Updated += IndicatorUpdateMethod; RegisterIndicator(symbol, _harami, Resolution.Daily); // In IndicatorUpdateMethod() if (_harami.IsReady) { var indicatorValue = _harami.Current.Value; }
from QuantConnect.Indicators.CandlestickPatterns import Harami # In Initialize() self.harami = Harami(name) self.harami.Updated += self.IndicatorUpdateMethod self.RegisterIndicator(symbol, self.harami, Resolution.Daily) # In IndicatorUpdateMethod() if self.harami.IsReady: indicator_value = self.harami.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 Harami _harami; private Symbol symbol; // In Initialize() _harami = new Harami(); symbol = AddEquity("SPY").Symbol; // In OnData() if (data.Bars.ContainsKey(_symbol)) { _harami.Update(data.Bars[symbol]); } if (_harami.IsReady) { var indicatorValue = _harami.Current.Value; }
from QuantConnect.Indicators.CandlestickPatterns import Harami # In Initialize() self.harami = Harami() self.symbol = self.AddEquity("SPY").Symbol # In OnData() if data.Bars.ContainsKey(self.symbol): self.harami.Update(data.Bars[self.symbol]) if self.harami.IsReady: indicator_value = self.harami.Current.Value
Get Indicator Values
To get the value of the indicator, use its Current.Value
attribute.
private Harami _harami; // In Initialize() var symbol = AddEquity("SPY").Symbol; _harami = Harami(symbol); // In OnData() if (_harami.IsReady) { var current = _harami.Current.Value; }
# In Initialize() symbol = self.AddEquity("SPY").Symbol self.harami = self.Harami(symbol) # In OnData() if self.harami.IsReady: current = self.harami.Current.Value
Visualization
To plot indicator values, in the OnData
event handler, call the Plot
method.
private Harami _harami; // In Initialize() var symbol = AddEquity("SPY").Symbol; _harami = Harami(symbol); // In OnData() if (_harami.IsReady) { Plot("My Indicators", "harami", _harami.Current); }
# In Initialize() symbol = self.AddEquity("SPY").Symbol self.harami = self.Harami(symbol) # In OnData() if self.harami.IsReady: self.Plot("My Indicators", "harami", self.harami.Current)
For more information about plotting indicators, see Plotting Indicators.