Stock Portfolio Organizer
The ultimate porfolio management solution.
WiseTrader Toolbox
#1 Selling Amibroker Plugin featuring:
Volatility Estimator for Amibroker (AFL)
This AFL calculates various volatility estimators (including Yang-Zhang volatility estimator). For detailed algorithm, see this site: http://atmif.com/papers/range.pdf
Indicator / Formula
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | /////////// the preferred volatility estimator is Yang-Zhang volatility estimator // all the estimators compute sigma^2 // the preferred volatility estimator // for more info, see paper "Drift-independent Volatility Estimation Based on High, Low, Open and Close Prices" function Yang_Zhang_vol( n, _open, _high, _low, _close ) { _N_o = log ( _open ) - log ( Ref ( _close, -1 ) ); // normalized open _N_u = log ( _high ) - log ( _open ); // normalized high _N_d = log ( _low ) - log ( _open ); // normalized low _N_c = log ( _close ) - log ( _open ); // normalized close V_rs = 1 / n * Sum ( _N_u * ( _N_u - _N_c ) + _N_d * ( _N_d - _N_c ), n ); // RS volatility estimator _N_o_avg = 1 / n * Sum ( _N_o, n ); V_o = 1 / ( n - 1 ) * Sum ( ( _N_o - _N_o_avg ) ^ 2, n ); _N_c_avg = 1 / n * Sum ( _N_c, n ); V_c = 1 / ( n - 1 ) * Sum ( ( _N_c - _N_c_avg ) ^ 2, n ); k = 0.34 / ( 1.34 + ( n + 1 ) / ( n - 1 ) ); V_yang_zhang = V_o + k * V_c + ( 1 - k ) * V_rs; return V_yang_zhang ; } // the Parkinson volatility estimator function Parkinson_vol( n, _open, _high, _low, _close ) { //_N_o = log( _open ) - log( Ref( _close, -1 ) ); // normalized open _N_u = log ( _high ) - log ( _open ); // normalized high _N_d = log ( _low ) - log ( _open ); // normalized low //_N_c = log( _close ) - log( _open ); // normalized close V_p = 1 / ( n * 4 * log ( 2 ) ) * Sum ( ( _N_u - _N_d ) ^ 2, n ); return V_p; } // volatility recommended by Rogers AND Satchell (1991) AND Rogers, Satchell, AND Yoon (1994) function RS_vol( n, _open, _high, _low, _close ) { // _N_o = log( _open ) - log( Ref( _close, -1 ) ); // normalized open _N_u = log ( _high ) - log ( _open ); // normalized high _N_d = log ( _low ) - log ( _open ); // normalized low _N_c = log ( _close ) - log ( _open ); // normalized close V_rs = 1 / n * Sum ( _N_u * ( _N_u - _N_c ) + _N_d * ( _N_d - _N_c ), n ); return V_rs; } // the traditional close-to-close volatility function C_2_C( n, _close ) { _ret = log ( _close ) - log ( Ref ( _close, -1 ) ); _avg = 1 / n * Sum ( _ret, n ); _vol = 1 / ( n - 1 ) * Sum ( ( _ret - _avg ) ^ 2, n ); return _vol; } |
7 comments
Leave Comment
Please login here to leave a comment.
Back
not working
not working
not working
sir how i can configure this with my ami
Wow. Thank you for those functions
Thanks for a great indicator. It’s working. Add plot to draw this indicator. For ex :
Yang_Zhang_vol( n, _open, _high, _low, _close ) -- > Plot(Yang_zhang_vol (C, O, H, L, C), "Yang Zhang", colorBlack, styleOwnScale);
n is a free paramater. You can use closing price, or other prices you like. I’m still trying to find out how to use this indicator.
sir very lovely website