Hello!
I'm wondering if anyone has an example of candle filtering universe for a particular candlstick pattern? I'm just looking at the previous day after I've done the universe filtering. I believe I can just loop through the active securites on the OnSecuritiesChanged to just pull the bar from yesterday and make a list of stocks that have that particular candle? Something like this:
def OnSecuritiesChanged(self, changes):
# Create indicator for each new security
for security in changes.ActiveSecurities:
self.indicators[security.Symbol] = self.CandlestickPatterns.HangingMan(security.Symbol)
history = self.History([security.Symbol], 2, Resolution.Daily)
for time, row in history.loc[security.Symbol].iterrows():
self.indicators[security.Symbol].Update(time, row['close'])
The issue I'm running into is a knowledge based one, I think. My row['close'] I don't believe is correct. I think I have to pass OHLC in there? I guess I'm just not sure how that works. Hopefully the rest of my approach here is correct. Any help would be great!
Best,
Stephen
Derek Melchin
Hi Stephen,
We need to update the candlestick pattern with a TradeBar object. This can be with
history = self.History(self.symbol, 1, Resolution.Daily).loc[self.symbol] for time, row in history.iterrows(): tradebar = TradeBar(time, self.symbol, row.open, row.high, row.low, row.close, row.volume) self.pattern.Update(tradebar)
The attached backtest shows an example of performing this. For demonstration purposes, the algorithm below places this logic in the OnData method. A better approach would be to include this logic inside universe selection so that our universe only consists of securities that have a hanging man signal. Refer to the EmaCrossUniverseSelectionAlgorithm for assistance moving this technical indicator logic into universe selection.
Best,
Derek Melchin
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.
Stephen
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!