Candlestick Pattern

Hammer

Introduction

Create a new Hammer 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 Hammer constructor.

Hammer()1/2

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

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

Hammer()2/2

            Hammer QuantConnect.Indicators.CandlestickPatterns.Hammer (
   )
        

Initializes a new instance of the Hammer 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 Hammer _hammer;

// In Initialize()
_hammer = new Hammer(name);
_hammer.Updated += IndicatorUpdateMethod;

RegisterIndicator(symbol, _hammer, Resolution.Daily);

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

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

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

// In Initialize()
_hammer = new Hammer();
symbol = AddEquity("SPY").Symbol;

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

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

Get Indicator Values

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

private Hammer _hammer;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_hammer = Hammer(symbol);

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

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

Visualization

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

private Hammer _hammer;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_hammer = Hammer(symbol);

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

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