Just started coding my first algo!
Question here is how do I compare the stochrsi from 3 days ago to the current stochrsi on a daily chart?
All advice appreciated!
Just started coding my first algo!
Question here is how do I compare the stochrsi from 3 days ago to the current stochrsi on a daily chart?
All advice appreciated!
Welcome, Dennis. I'm not sure exactly what you're looking for, but here's the super basic implementation of STOCHRSI.
(Ignore all the commented out stuff - that's leftover from a different algo I forgot to clean out).
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 Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian 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.
Hi Dan, thanks for your response. What I want to know is if it is possible to compare the stochrsi value today to the stochrsi value from 3 days ago?
And I may be wrong, but isn't stochrsi supposed to return a float that oscillates between 0 and 1 instead of %d and %k?
@Dan,
Can you please add UserList to support in the near future?
I can think of using a circular list to store the most recent numbers.
stochrsi = ta.STOCHRSI()
import UserList
class Ring(UserList.UserList):
def __init__(self, data = []):
self.data = data
self.offset=0
def turn(self, n=1):
self.offset = self.offset+n
while self.offset<0:
self.offset = self.offset + len(self.data)
while self.offset>=len(self.data):
self.offset = self.offset - len(self.data)
def __getitem__(self, i):
if abs(i)>=len(self.data):
return self.data[i] # raise IndexError
return self.data[(i-self.offset)%len(self.data)]
def append(self, x):
length = len(self.data)
while self.offset>=length:
self.offset = self.offset - length
self.data[length-self.offset:length-self.offset] = [x]