How would I calculate the standard deviation of the last 12 months of monthly returns for use in a ranking system?
See if LoopStdDev works for you.
Looks promising but I’m having trouble implementing it. I know this isn’t right because it returns the same rank for everything:
loopstddev("pr4w%chg",12)
Look at the definition of how to use it. You are not using it correctly. You wont be able to use it with that factor.
PctDev calculates the standard deviation of the percentage moves.
PctDev(12,21) returns the standard deviation of the past 12 samples of 21 day returns.
As for LoopStdDev, you’re not using the right format. Use this code as starting point:
ShowVar(@vola, LoopStdDev(“Close(CTR+21)/Close(CTR)”,12,0,1,TRUE))
Try PctDev(12,21)
Steve
i believe this is it for anyone else looking.
loopstddev(“100*(close(ctr)-close(ctr+20))/close(ctr+20)”,12,0,20)
Thanks.
What are you planning on using this for?
I want to include a volatility component in my momentum rank. It didn’t work as I expected.
Are you trying to reduce violatiolity? If so, The problem woujld be one of trying to travel east and west at the same time. If you are a momentum investor, higher volatility is better.
The difficilty lies in the weakness of standard deviation as a measure of risk. It’s symetric; mathematicians lack the capacity to distingush between upside and downside volatility, other than by measuring what ocurred in a specific measurement period in the past. Investors, however, have asymmetric preferences.
The company characteristics that increase or decrease volatility are the same (one example: high debt leverage with high fixed interest expense that increases the volatility of the earnings stream). The difference in outcome depends on whether things break well or badly in the future. My suggestion, if you are a momentum investor, is to nlot consider volatility statstics at al, or use them in a higher-is-better manner and use other aspects of your ranking system or screen (buy rules) to teae out companies for which things are more liklely than not to breakl better in the future.
P.S. Even if my initial ssumption is wrong, and you started with a higher-is-better approch, it still can;t be expectede to work well for you absent other factors in the ranking system of but rules that pre-qualify a sub-universe of companies for which thibngs are likely to break well. You can do this with fundamentals and/or sentiment (including technical) measures.
You could have a look on the Sortino ratio, which penalize only downward volatility.