Hi,
I would like to compute an indicator which works as follows:
1) calculate ROC(close,1)
2) If ROC(close,1) >0 write 1 in a new DataSeries
3) If ROC(close,1)<=0 write -1 in the new DataSeries above
4) Sum the movements for the last 20 days
5) Calculate the % rank of today’s sum, compared to the last 50 days of sums.
The original idea you will find here:
http://qusma.com/2012/10/14/the-predictive-value-of-the-number-of-recent-updown-days-udidsri/Thank you for help.
Best
Niels
Size:
Color:
Niels,
Not sure what I'm doing wrong as the end result does not look quite the same as on the website's chart:
CODE:
Please log in to see this code.
Size:
Color:
Is it possible that he is using log returns?
Vince
Size:
Color:
Thanks for your suggestion Vince. Probably I'm doing something wrong with log returns but the output is still very different...
CODE:
Please log in to see this code.
Size:
Color:
I think the exact calculation you will find at the bottom of the website. There is a link to an excel sheet in which the calculation can be reconstructed. But I don't know what the adjusted close prices are.
Best
Niels
Size:
Color:
Here's version based on the Excel spreadsheet. Still not the same. OK, I leave this up to you.
CODE:
Please log in to see this code.
Size:
Color:
QUOTE:
I think the exact calculation you will find at the bottom of the website. There is a link to an excel sheet in which the calculation can be reconstructed. But I don't know what the adjusted close prices are.
A suggestion:
Adjusted closes are from the Yahoo finance website. It adjusts for splits and dividends. Try inputting these prices into WL and see if that solves the problem
Size:
Color:
Thanks for your suggestion. I'm working with adjusted Yahoo! data and it does not solve the discrepancy in the indicator shape.
Size:
Color:
My suggestion: power and %Rank periods differ between the code above and the original ones. Thus, put the %Rank period to 50 and choose the Power value between 1 and 5. The author uses the value 5 on his website and 1 in the excel-sheet. In don't know which one is correct.
CODE:
Please log in to see this code.
Size:
Color:
Yep, 50-day Percent Rank and a Power of 1 seem to do the trick. I think it's ready for inclusion into Community Indicators. Thanks everyone.
Size:
Color: