Candlestick Patterns

Long Line Candle

Introduction

Create a new Long Line Candle candlestick pattern indicator to indicate the pattern's presence.

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 LongLineCandle constructor.

LongLineCandle()1/2

            LongLineCandle QuantConnect.Indicators.CandlestickPatterns.LongLineCandle (
     string  name
   )
        

Initializes a new instance of the LongLineCandle class using the specified name.

LongLineCandle()2/2

            LongLineCandle QuantConnect.Indicators.CandlestickPatterns.LongLineCandle (
   )
        

Initializes a new instance of the LongLineCandle 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 LongLineCandle _longlinecandle;

// In Initialize()
_longlinecandle = new LongLineCandle(name);
_longlinecandle.Updated += IndicatorUpdateMethod;

RegisterIndicator(symbol, _longlinecandle, Resolution.Daily);

// In IndicatorUpdateMethod()
if (_longlinecandle.IsReady)
{
    var indicatorValue = _longlinecandle.Current.Value;
}
from QuantConnect.Indicators.CandlestickPatterns import LongLineCandle
    
# In Initialize()
self.longlinecandle = LongLineCandle(name)
self.longlinecandle.Updated += self.IndicatorUpdateMethod

self.RegisterIndicator(symbol, self.longlinecandle, Resolution.Daily)

# In IndicatorUpdateMethod()
if self.longlinecandle.IsReady:
    indicator_value = self.longlinecandle.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 LongLineCandle _longlinecandle;
private Symbol symbol;

// In Initialize()
_longlinecandle = new LongLineCandle();
symbol = AddEquity("SPY").Symbol;

// In OnData()
if (data.Bars.ContainsKey(_symbol))
{
    _longlinecandle.Update(data.Bars[symbol]);
}
if (_longlinecandle.IsReady)
{
    var indicatorValue = _longlinecandle.Current.Value;
}
from QuantConnect.Indicators.CandlestickPatterns import LongLineCandle
    
# In Initialize()
self.longlinecandle = LongLineCandle()
self.symbol = self.AddEquity("SPY").Symbol

# In OnData()
if data.Bars.ContainsKey(self.symbol):
    self.longlinecandle.Update(data.Bars[self.symbol])
if self.longlinecandle.IsReady:
    indicator_value = self.longlinecandle.Current.Value

Get Indicator Values

To get the value of the indicator, use its Current.Value attribute.

private LongLineCandle _longlinecandle;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_longlinecandle = LongLineCandle(symbol);

// In OnData()
if (_longlinecandle.IsReady)
{
    var current = _longlinecandle.Current.Value;
}
# In Initialize()
symbol = self.AddEquity("SPY").Symbol
self.longlinecandle = self.LongLineCandle(symbol)

# In OnData()
if self.longlinecandle.IsReady:
    current = self.longlinecandle.Current.Value

Visualization

To plot indicator values, in the OnData event handler, call the Plot method.

private LongLineCandle _longlinecandle;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_longlinecandle = LongLineCandle(symbol);

// In OnData()
if (_longlinecandle.IsReady)
{
    Plot("My Indicators", "longlinecandle", _longlinecandle.Current);
}
# In Initialize()
symbol = self.AddEquity("SPY").Symbol
self.longlinecandle = self.LongLineCandle(symbol)

# In OnData()
if self.longlinecandle.IsReady:
    self.Plot("My Indicators", "longlinecandle", self.longlinecandle.Current)

The following image shows the plot values in a matplotlib plot. To load algorithm plot data into the Research Environment, see Charts.

For more information about plotting indicators, see Plotting Indicators.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: