ROC from the first bar
Author: gbullr
Creation Date: 7/20/2012 12:02 PM
profile picture

gbullr

#1
I am trying to get ROC for ^GSPC but lets say for any stock from the first bar and I don't seem to be able to get it.
Trying to create series in rocGSPC
extGSPC is an external symbol


CODE:
Please log in to see this code.
profile picture

Eugene

#2
This will be assigning a Series Bars.Count-212 times to RocGSPC. You forgot a [bar]:
CODE:
Please log in to see this code.

But being then partially correct from syntax standpoint, it's still a waste of resources. You should simply do this instead:
CODE:
Please log in to see this code.
profile picture

gbullr

#3
Ok. but then when I want to plot it I cannot because it "does not exist in the current context" so how do I bring it into the main loop?

CODE:
Please log in to see this code.
profile picture

Eugene

#4
You overlooked my comment and kept putting the code in the wrong place. My 2 lines were to replace your RocGSPC definition (i.e. the 2nd line of code that you've just commented out).

At the risk of repeating, defining a DataSeries in the loop is an unnecessary waste or resources - naturally, define any variable within a block of curly braces and it won't be accessible by the code below it.
profile picture

gbullr

#5
At the risk of proving that I am retarded.


If i put the code where you are suggesting; outside the for loop then bar is undefined and I get an error. Bars.Count does not work either.

profile picture

Eugene

#6
I made a copy/paste typo in my code while pasting from your code on the fly, this is why nothing will work. However, the nature of error made me have an extra look at your code, raising a series of questions:

1. Actually, not only were you "assigning a Series Bars.Count-212 times to RocGSPC". You were creating Bars.Count-212 * Series. Is this intentional? What is the point?

2. Could you explain what "ROC for any stock from the first bar" you think is? Because any DataSeries starts from the first bar, by design.

3. What is "accumdays", should it be based on ^GSPC or the current Bars as it is currently?

I want to have a clear picture of what you were trying to accomplish with that code, before giving out any fix.
profile picture

gbullr

#7
I am asking a retarded question. I just figured out in trying to explain to you what I am looking for what I am looking for.

Thanks.





profile picture

Eugene

#8
A wise man's question contains half the answer :)
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).