RicardoSantos

Function Geometric Mean Oscillator

Using a formula that is generally used for calculating investment over time to check gains on a commodity.

Geometric             mean as described here: http://www.investopedia.com/ask/answers/06/geometricmean.asp
Remove from Favorite Scripts Add to Favorite Scripts
//@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)
Ideas Scripts Chart
United States
United Kingdom
India
España
Italia
Brasil
Россия
Türkiye
日本
한국
Home Stock Screener Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Billing Sign Out