class CandleFun(QCAlgorithm):
# Ticker symbol that the algo will trade.
tickerSymbol = "QQQ"
def Initialize(self):
self.SetStartDate(2003, 1, 1)
self.SetEndDate(2003, 12, 31)
self.SetCash(5000)
self.SetBrokerageModel(
BrokerageName.InteractiveBrokersBrokerage, AccountType.Cash
)
self.SetBenchmark("QQQ")
self.AddEquity(self.tickerSymbol, Resolution.Daily)
self.hammer = self.CandlestickPatterns.Hammer(
self.tickerSymbol, Resolution.Daily
)
def OnData(self, data):
"""OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
Arguments:
data: Slice object keyed by symbol containing the stock data
"""
if self.hammer == 1:
self.Log("Hammer.")
def OnOrderEvent(self, orderEvent):
self.Log(f"{orderEvent}")
How can I check if a hammer candlestick pattern has been found in Python? The following comparison doesn't work:
if self.hammer == 1: