Using a formula that is generally used for calculating investment over time to check gains on a commodity.
Geometric mean as described here: www.investopedia.com...06/geometricmean.asp
Geometric mean as described here: www.investopedia.com...06/geometricmean.asp
//@version=2 study(title='Function Geometric Mean Oscillator', overlay=false) // ||-----------------------------------------------------------------------------------------|| // ||--- As described here: // || http://www.investopedia.com/ask/answers/06/geometricmean.asp // ||-----------------------------------------------------------------------------------------|| src = input(close) length = input(10) f_gmo(_src, _length)=> _length_adjusted = _length < 1 ? 0 : _length _perc_change = change(_src) / _src _sum = 1 for _i = 0 to (_length_adjusted) _sum := _sum * (1 + _perc_change[_i]) _return = pow(_sum, (1 / _length_adjusted)) - 1 //plot(ema(src, length), color=color(gray, 0), linewidth=5) plot(f_gmo(src, length), color=color(blue, 0), linewidth=1) hline(0)