I have been playing around with quantconnect using other people's algos and changing them . I am a Beginner on coding/algo trading in gereral XD. So could someone give me a example on using CCI. I want to use 4 of them 14,50,100,200 periods. So the buy conditions when 14 period crosses up -100 while the persistant of the other 3 longer period CCI is greater than 0. And the sell condition being when any of the 50,100,200 period dipping below -100
examples:
https://www.tradingview.com/x/Df6eCWzS/
Superfatkorean
heres what I have rn but for somereason it doesnt work
class Quadcci(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2007, 1, 1) # Set Start Date
self.SetCash(100000) # Set Strategy Cash
self.AddEquity("spy", Resolution.Daily,)
self.Fast = self.CCI("spy", 14, MovingAverageType.Simple, Resolution.Daily)
self.Med = self.CCI("spy", 50, MovingAverageType.Simple, Resolution.Daily)
self.CCIupperBound = 100 # CCI upper bound line
self.CCIlowerBound = -100 # CCI lower bound
self.CCIBaseLine = 0 # cci baseline
def OnData(self, data):
# get current price of Spy
holdings = self.Portfolio["spy"].Quantity
price = self.Securities["spy"].Close
# buy if price closes above upper bollinger band
if holdings <= 0:
if self.Fast and self.Med > self.CCIupperBound:
self.SetHoldings("spy", 1.0)
# sell if price closes below middle bollinger band
if holdings > 0 and self.Fast and self.Med < self.CCIupperBound:
self.Liquidate()
Greg Kendall
Here is some documentation that should help with using CCI:
Greg Kendall
I did a little work on this to get it going a bit. Needs lots more work but now it does some trading….
Greg Kendall
I'm looking at CCI with a long period as a start to a risk-off method using it on spy to find when equities are overbought and then return a boolean “isRiskOff” that lets you know you should liquidate and maybe buy bonds.
Superfatkorean
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!