Position sizing based on Yhang-Zhan variation of Garman-Klass volatility

Category: Indicators By: gabri Created: September 13, 2017, 11:08 AM
September 13, 2017, 11:08 AM
Indicators
5 Comments

This code has to be used in conjunction with a screener, that I will post soon, in order to build a weighted portfolio based on volatility and momentum. You can choose to use the EWMA (Exponential Weighted Moving Average) or the most sophisticated Yang-Zhang variation of the Garman-Klass volatility to build your positioning. Just multiply the number the graph is showing for the basic import you are normally investing. Let’s say for example that you normally invest 1000 Euros per trade per stock and the code gives you the number 9 for stock A and 5 for stock B. You would want to buy 9000 stocks A and 5000 stocks B (or a different number but always weighted 9 to 5).

This positioning works excellent in portfolios with 20-30 stocks minimum.

Blue skies!!

//periodo=254

a=log(close/close[periodo])

//volatility with GARMAN-KLASS YANG-ZHANG
zz=call "mio - tsmom improved volat"[22]
vol=sgn(a)/zz
ret=log(close/close[1])
//l=60/61
l=0.983
cx=ret*ret
if barindex>2 then
 s2=l*s2[1]+(1-l)*cx[1]
endif

sann=(periodo*s2)


return SGN(a)*1/sann as "Positions with EWMA",0, vol as "Positions with GARMAN-KLASS YANG-ZHANG"

Download
Filename: Position-size-YZGK.itf
Downloads: 126
gabri Master
Currently debugging life, so my bio is on hold. Check back after the next commit for an update.
Author’s Profile

Comments

Logo Logo
Loading...