Thanks for the confirmation Joris.

--- In [email protected], "Joris Schuller" <jschul...@...> wrote:
>
> I sent this as a response on Jan 2009 (Message #133785). Look at the
> derivation and compare with your formula. I looked at your formula below and
> they look identical.
> 
> Geometric Moving Average (GMA): the 'n'th root product of 'n' numbers, For
> example,( Return1* Return2 *.* Return n)**(1/N). Value Line used and
> probably still uses a geometric MA to compute returns.
> 
> So for example: 
> 
> 10,100,100; GMA=(10*100**1000)**(1/3) =100.
> 
> 2,4,8,16; (2*4*8*16)**(1/4) = 5.657
> 
> In AFL:
> 
> /*
> 
> Formula Derivation
> 
> C1 = Ref(C,-1);C2 = Ref(C,-2);C3 = Ref(C,-3);Cn = Ref(C,-n);
> 
> GMA = Nth root of:(C*C1*C2*C3*C4*...*C(n-1))
> 
> lnGMA = (1/N)(ln(C)+ln(C1)+ln(C2)+ln(C3)+...+ln(Cn-1)) =(1/N)*Sum(ln(C),N)
> 
> GMA = exp(lnGMA);
> 
> */
> 
> /*
> 
> //Number examples
> 
> Period = Param("Period",1,1,100,1);
> 
> //Numbers: 10,100,1000; period = 3;
> 
> lnGMA = (1/period)*(ln(10)+ ln(100)+ln(1000));
> 
> //Plot(exp(lnGMA ),"GMA",1,5);
> 
> //Numbers: 2,4,8,16; period = 4;
> 
> lnGMA = (1/period)*(ln(2)+ ln(4)+ln(8)+ln(16));
> 
> Plot(exp(lnGMA ),"GMA",1,5);
> 
> */
> 
> //In AFL language
> 
> Period = Param("Period",1,1,100,1);
> 
> lnGMA = (1/Period)*Sum(ln(C),Period);
> 
> Plot(exp(lnGMA),"GMA",1,5);
> 
>  
> 
>  
> 
> From: [email protected] [mailto:[email protected]] On Behalf
> Of droskill
> Sent: Monday, April 26, 2010 2:24 PM
> To: [email protected]
> Subject: [amibroker] Geometric average
> 
>  
> 
>   
> 
> Anyone have any AFL code for calculating a geometric average of a data set?
> 
> I'm trying to duplicate, in AB, the following:
> 
> http://www.investopedia.com/ask/answers/06/geometricmean.asp
> 
> I found some code in the group, but it looks a bit funny to me:
> 
> Period = Param("Period",1,1,100,1);
> lnGMA = (1/Period)*Sum(ln(C),Period);
> Plot(exp(lnGMA),"GMA",1,5);
> 
> Or, put more simply:
> 
> GMA = exp((1/Period)*Sum(ln(C),Period));
> 
> Does that look right to anyone? I'm just find it hard to verify the numbers
> inside AB....
> 
> Any help appreciated!
>


Reply via email to