RicardoSantos

Function Geometric Moving Average

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/...
Skrypt open-source

Zgodnie z prawdziwym duchem TradingView, autor tego skryptu opublikował go jako open-source, aby traderzy mogli go zrozumieć i zweryfikować. Brawo dla autora! Możesz używać go za darmo, ale ponowne wykorzystanie tego kodu w publikacji jest regulowane przez Dobre Praktyki. Możesz go dodać do ulubionych, żeby używać go na wykresie.

Chcesz użyć tego skryptu na wykresie?
//@version=2
study(title='Function Geometric Moving Average', overlay=true)
//  ||-----------------------------------------------------------------------------------------||
//  ||---   As described here:
//  ||      http://www.investopedia.com/ask/answers/06/geometricmean.asp
//  ||-----------------------------------------------------------------------------------------||

src = input(close)
length = input(10)

f_gma(_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 = nz(_return[1], _src) + _src * (pow(_sum, (1 / _length_adjusted)) - 1)

//plot(ema(src, length), color=color(gray, 0), linewidth=5)
plot(f_gma(src, length), color=color(blue, 0), linewidth=1)

Komentarze

This is actually real cool. Just messing with settings on 4hr btc all time chart... there are some interesting potential models that can be derived already. I'll have to mess with this a bit and see if I can produce any attractive models just to see if they hold up in the future as an experiment. Seems like a weird formula to derive models from but I feel there is something here... I'm a noob though maybe its obvious haha
Odpowiedz