I found the following in some old code written by someone else.
This is not AFL but you can see the way the weighted average is created.
Is this the mathematically correct way?
 

f1 = fselx  (In AFL this would be f1 = Foreign("FSELX","C")  )

w1 = 60

f2 = fsvlx

w2 = 30

f3 = fsrbx

w3 = 10

 

//Sum their weighted exponential growth rates.

RateSum = w1 * Log(f1 / First(f1)) + 

          w2 * Log(f2 / First(f2)) + 

          w3 * Log(f3 / First(f3))

 

//Average the weighted exponential growth rates.

RateAvg = RateSum / (w1 + w2 + w3)

 

//Create a price series using the new growth rates.

WeightedAvg = Pow(10, RateAvg)


  _____  

From: Mr. Valley [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 23, 2007 12:32 PM
To: [EMAIL PROTECTED]
Subject: RE: [AmiBroker] Weighted Average


If the total of the four symbols = 100%
Then each are a portion of 100%, then what portion is each to the total?
 

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] Behalf
Of Ken Close
Sent: Tuesday, January 23, 2007 10:25 AM
To: [email protected]
Subject: [amibroker] Weighted Average





What would be the correct way to get a weighted average of three or four
tickers, with the weightings unequal?
 
WtAvg = Wt1 * Price1 + Wt2 * Price2 + Wt3 * Price3.   ??????
 
I am asking because I thought I remember seeing here or on another list that
doing what I wrote above will give an incorrect result.  But I do not
remember what alternative was suggested.
 
Any help?
 
Thanks,
Ken 



 

Reply via email to