Candlestick Patterns

Closing Marubozu

Introduction

Create a new Closing Marubozu 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 ClosingMarubozu constructor.

ClosingMarubozu()1/2

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

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

ClosingMarubozu()2/2

            ClosingMarubozu QuantConnect.Indicators.CandlestickPatterns.ClosingMarubozu (
   )
        

Initializes a new instance of the ClosingMarubozu 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 ClosingMarubozu _closingmarubozu;

// In Initialize()
_closingmarubozu = new ClosingMarubozu(name);
_closingmarubozu.Updated += IndicatorUpdateMethod;

RegisterIndicator(symbol, _closingmarubozu, Resolution.Daily);

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

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

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

// In Initialize()
_closingmarubozu = new ClosingMarubozu();
symbol = AddEquity("SPY").Symbol;

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

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

Get Indicator Values

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

private ClosingMarubozu _closingmarubozu;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_closingmarubozu = ClosingMarubozu(symbol);

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

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

Visualization

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

private ClosingMarubozu _closingmarubozu;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_closingmarubozu = ClosingMarubozu(symbol);

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

# In OnData()
if self.closingmarubozu.IsReady:
    self.Plot("My Indicators", "closingmarubozu", self.closingmarubozu.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: