I'm trying to do some research. I'd like to calculate the average daily range (High-Low) for a data set over time (daily) and then output the dates and average ranges to a .csv file. I can create a dataseries with the range for one stock. But averaging in all the stocks in a data set is stumping me...thanks!
CODE:
Please log in to see this code.
Size:
Color:
Size:
Color:
Sidenote: Index Manager (Index-Lab) is coming in the summer release.
Size:
Color:
Thanks...works great! BTW, in case you do stick it in the wiki, technically, this is just an average range calculation. I guess we reserve the term Average True Range for the Wilder approach.
Size:
Color:
Hi,
I have a similar task, but instead of the average daily range of the set I need an average daily range of each given Symbol in the Dataset. In other words, I have a set of 14 Symbols in a set, each symbol is different, time period is almost the same for everyone. I want to have a table with all the symbols and their average daily ranges (see below).
Symbol 1 - Average daily range = X (Where X is the Sum of Daily ranges (High - Low) divided by the number of days)
Symbol 2 - Average daily range = Y
Symbol 3 - Average daily range = Z
Dates are not important.
I would really appreciate if some one could suggest a solution. I just started to code and things are a lit complicated for me.
Thanks.
Size:
Color:
Hi Anton,
At first glance this seems to be what you're looking for:
CODE:
Please log in to see this code.
Size:
Color:
Hi Eugene,
Thanks. It works, but results are not the same compared to Ecxel. I took two symbols from the set and calculated the average in Excel (time period is the same). The results are 50-100% different. Any ideas why it happens?
Regards,
Anton
Size:
Color:
Sorry Anton, I have little idea as to what may be wrong with your Excel calculation.
Size:
Color:
Eugene,
I was saying that the code perfomed the wrong calculation, not Excel. I double checked with ATR and it showed that Excel was correct. My question was what could be wrong in the code.
Size:
Color:
Anton,
And I was implying that I've double checked my code and the output was correct. This discussion is going nowhere without providing facts.
Size:
Color: