Hi,
i would like to be able to use candlestick patterns on my algorithm, with a custom timeframe, i.e 15 minutes.
Here is the candlestick pattern i'm trying to work with.
class CalibratedDynamicComputer(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2016, 1, 30)
#self.SetEndDate(2020, 2, 15)
self.SetCash(10000)
self.SetBrokerageModel(BrokerageName.OandaBrokerage)
symbol = self.AddForex("EURUSD", Resolution.Minute, Market.Oanda).Symbol
self.engulfing = self.CandlestickPatterns.Engulfing(symbol, Resolution.Minute)
self.engulfing_window = RollingWindow[float](10)
def OnData(self, data):
engulfing = self.engulfing.Current.Value
#self.Plot("IndicatorValue", "Engulfing", engulfing)
self.engulfing_window.Add(engulfing)
if self.engulfing_window.IsReady:
#self.Plot("TrailingIndicatorValue", "TrailingHammer", self.engulfing_window[self.engulfing_window.Count-1])
self.SetHoldings("EURUSD", 1)
Fred Painchaud
Hi Samwel,
Interesting. There is either no engulfing pattern in EURUSD between 2016/1/30 and 2020/1/30, or the indicator is buggy. Look at the backtest, from modifying your code a bit. I'm waiting for two engulfing patterns but there are none. I don't think it is the pattern which is buggy. I will include another backtest for SPY.
Fred
Fred Painchaud
Here is the backtest for SPY, which trades, without waiting for 2 in a row (which is a rare event at day resolution).
Forgot to mention that for the EURUSD one. Lower your resolution maybe, to hour/consolidated minutes.
Fred
Vladimir
Here is my code for Engulfing Candlestick Pattern on 15 minute Quote Bar consolidated EURUSD.
Unfortunately for some reason it dose not generate any signals.
But if I switch to 15 minute equity Trade Bar consolidated the same code recognizes
Engulfing Candlestick Pattern.
Samwel Kibet
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!