I'm attempting to use Ichimoku to determine sentiment for a trading algorithm: bullish, bearish, neutral. The algo works on 5 min time buckets. The challange is that I cannot figure out how to get Ichimoku to operate over anything other than the default 1 min timeframe.
The link below goes to a gdoc which has a screencapture from etrade for August 17th showing what Ichimoku looks like on that day in both 5 min time (top) and 1 min (middle). As you can see Chikou is above the cloud for almost the entire day in the 5 min vs the 1 min which is very choppy. The sentiment output from my algo is also attached (bottom) and maps pretty well to the etrade 1 min chart.
I've tried to replicate every example of bucketed time that I can find on Quantconnect, but no luck. The attached code and backtest should make it easy to see what I'm trying to achieve.
Any help would be appreciated !
https://docs.google.com/document/d/1IAH3Bi16jUvU2aiYQ4I1rPrYZ9KKsxHSiQDv9xBuxOU/edit?usp=sharing
Angus MacDonald
I think I've fixed my use of the indicators, rollingwindows and timebuckets. Will update later today. Still working to validate that the Ichimoku output aligns with what I'm seeing from etrade.
Angus MacDonald
As promised, here is the revised 5 min Ichimoku test case. This seems to work now, excepct for the results coming out of the Ichimoku algorithm itself. I generate Sentiment based on some really simple conditions, note that this is just for validation not for generating real insights:
- if price is over the Cloud and Tenkan is over Kinjun, then the Sentiment is Bullish
- if price is under the Cloud and Kinjun is over Tenkan, then the Sentiment is Bearish
- if price is in the Cloud, then Sentiment is Neutral
If you apply these conditions to a chart from etrade for a specific day (8/17/2020) it is clear that you go Bullish immediately and don't go Neutral until 14:45 in the afternoon. In the picture below, price is plotted as a mountain to make it really clear where it enters the cloud.
However, when I implement on the platform this is not the Sentiment I get. In the screenshot below you can see that Sentiment is very different that what the etrade chart is showing (the white line where high is bullish, middle is neutral and low is bearish). Why is this ?
If you look at the backtest results the values for SenkouA, SenkouB, Tenkan and Kijun are different than the numbers shown in the etrade chart. I've gone through this painstakingly and the varience is generally between 0.15% to 0.2%, which is enough to get you really different resutls and make my strategies invalid. Is this differences in tick values from the data sources or is somethign else going on ?
Any ideas or input are welcome. I'm trully baffled.
Angus MacDonald
I'm seeing similar varients in behavior of other indicators when comparing this platform with etrade. So I conclude that this is most likely a difference in data sources. Given that, I built out my model with a mix of indicators and the overall performance is in line with my expectations. Now that I have a pretty good undestanding of the platform basics, I can focus on trading strategies. Onwards and upwards !
Derek Melchin
Hi Angus,
The reason the plots look different on our platform is because the algorithm updates the ichimoku cloud indicator with 1-minute and 5-minute data. To resolve this, we need to use the indicator class instead of the shortcut method.
self.Ichi = IchimokuKinkoHyo('ichi', TenkanPeriod, KijunPeriod, SenkouAPeriod, SenkouBPeriod, SenkouADelay, SenkouBDelay)
Additionally, we need to change the warm up period to
self.SetWarmup(self.Ichi.WarmUpPeriod * 5)
The algorithm subscribes to minute data, so we multiply by 5 since we're consolidating the data into 5-minute bars.
See the attached backtest plot for a cloud that matches the Etrade screen capture above.
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.
Angus MacDonald
Thank you so much. That fix has made a significant difference to my algo. It is now doing what I expected it to do with Ichimoku.
In addition to Ichimoku I'm using moving averages, a Chande oscillator and a Parabolic SAR. The respective initalizations look like:
self.MA_Fast = self.SMA(self.long_symbol, self.fastPeriod, Resolution.Minute)
self.RegisterIndicator(self.long_symbol, self.MA_Fast, timedelta(minutes = self.timebucket))
self.Chande = self.CMO(self.long_symbol, 9, Resolution.Minute)
self.RegisterIndicator(self.long_symbol, self.Chande, timedelta(minutes = self.timebucket))
self.ParabolicSAR = self.PSAR(self.long_symbol, 0.02, 0.2, Resolution.Minute)
self.RegisterIndicator(self.long_symbol, self.ParabolicSAR, timedelta(minutes = self.timebucket))
self.timebucket is 5.
Do these look ok ? They seem to be workign well.
Angus MacDonald
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!