Need help: I want to compare RSI of different equities. The log returns 0.0 on the following- not getting RSI correctly. I have read through hundreds of scripts and cannot find a solution. Any help appreciated.
from clr import AddReference
AddReference("System")
AddReference("QuantConnect.Algorithm")
AddReference("QuantConnect.Indicators")
AddReference("QuantConnect.Common")
from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Indicators import *
from QuantConnect.Parameters import *
class DynamicUncoupledPrism(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2020, 10, 7) #Set Start Date
self.SetEndDate(2020, 10, 11) #Set End Date
self.SetCash(100000) #Set Strategy Cash
self.AddEquity("MSFT", Resolution.Minute)
self.MSFTrsi = RelativeStrengthIndex("MSFT", 6)
self.MSFTrsiWindow = RollingWindow[float](5)
self.AddEquity("APPL", Resolution.Minute)
self.APPLrsi = RelativeStrengthIndex("APPL", 6)
self.APPLrsiWindow = RollingWindow[float](5)
self.AddEquity("AMZN", Resolution.Minute)
self.AMZNrsi = RelativeStrengthIndex("AMZN", 6)
self.AMZNrsiWindow = RollingWindow[float](5)
self.AddEquity("TSLA", Resolution.Minute)
self.TSLArsi = RelativeStrengthIndex("TSLA", 6)
self.TSLArsiWindow = RollingWindow[float](5)
def OnData(self, data):
'''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.'''
self.MSFTrsiWindow.Add(self.MSFTrsi.Current.Value)
self.APPLrsiWindow.Add(self.APPLrsi.Current.Value)
self.AMZNrsiWindow.Add(self.AMZNrsi.Current.Value)
self.TSLArsiWindow.Add(self.TSLArsi.Current.Value)
# wait for our indicators to ready
if not self.MSFTrsi.IsReady or not self.APPLrsi.IsReady or not self.AMZNrsi.IsReady or not self.TSLArsi.IsReady:
return
self.Log(f"MSFTrsi: {RelativeStrengthIndex('MSFT', 6)}")
Vladimir
Matthew Griffin,
This may help you
2021-04-01 15:55:00 : MSFTrsi: 76.16475
2021-04-01 15:56:00 : MSFTrsi: 66.04615
2021-04-01 15:57:00 : MSFTrsi: 69.3275
2021-04-01 15:58:00 : MSFTrsi: 70.3392
2021-04-01 15:59:00 : MSFTrsi: 71.10917
2021-04-01 16:00:00 : MSFTrsi: 45.71547
Matthew Griffin
Thank you!
Matthew Griffin
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!