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