Candlestick Pattern

Mat Hold

Introduction

Create a new Mat Hold candlestick pattern 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 MatHold constructor.

MatHold()1/3

            MatHold QuantConnect.Indicators.CandlestickPatterns.MatHold (
     string    name,
     *decimal  penetration
   )
        

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

MatHold()2/3

            MatHold QuantConnect.Indicators.CandlestickPatterns.MatHold (
     decimal  penetration
   )
        

Initializes a new instance of the MatHold class.

MatHold()3/3

            MatHold QuantConnect.Indicators.CandlestickPatterns.MatHold (
   )
        

Initializes a new instance of the MatHold 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 MatHold _mathold;

// In Initialize()
_mathold = new MatHold(name, penetration);
_mathold.Updated += IndicatorUpdateMethod;

RegisterIndicator(symbol, _mathold, Resolution.Daily);

// In IndicatorUpdateMethod()
if (_mathold.IsReady)
{
    var indicatorValue = _mathold.Current.Value;
}
from QuantConnect.Indicators.CandlestickPatterns import MatHold
    
# In Initialize()
self.mathold = MatHold(name, penetration)
self.mathold.Updated += self.IndicatorUpdateMethod

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

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

// In Initialize()
_mathold = new MatHold(penetration);
symbol = AddEquity("SPY").Symbol;

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

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

Get Indicator Values

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

private MatHold _mathold;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_mathold = MatHold(symbol);

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

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

Visualization

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

private MatHold _mathold;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_mathold = MatHold(symbol);

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

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

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: