[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Unweighted Composites (again!)



PureBytes Links

Trading Reference Links

Did  I not understand what you write? It seems quite straightforward to me.

To calculate, use formala:
AddToComposite(ROC(C, 1), "~WhatEver", "X");
AddToComposite(1, "~WhatEver", "I");

To refer to the unweighted composite, use:
100 + cum(Foreign("~WhatEver", "C")/Foreign("~WhatEver", "I"));


  ----- Original Message ----- 
  From: timgadd 
  To: amibroker@xxxxxxxxxxxxxxx 
  Sent: Monday, August 14, 2006 5:02 PM
  Subject: [amibroker] Unweighted Composites (again!)


  After spending MUCH time searching, I have found this topic started 
  many times in the group archive, but i've never seen a final solution 
  given in AFL. I would greatly appreciate assistance with the AFL code 
  or reference to a prior solution.

  The standard AddToComposite function produces a "price weighted" 
  composite. For analyzing the breadth of a sector, for 
  instance, "unweighted" composites are more appropriate and revealing. 
  I have seen the term "equal weighted" used for what i am calling 
  an "unweighted" composite, so i will explain in boring detail what i 
  am looking for just to be clear.

  By unweighted composite, i refer to one that is produced by 
  calculating an arithmetic or geometric average of the day to day %
  change for each component, so that each component has equal weight 
  (no weighting is introduced by the calculation). I am interested in 
  the arithmetic average - the simplest form, but i don't know how to 
  initialize the starting value and then cumulate(?) the successive %
  change averages for the open, high, low, close (volumes are simply 
  added). I have seen references regarding problems with averaging 
  values for high and low for this type of composite, so if necessary, 
  a composite calculated on the close only will suffice. I am only 
  interested in the average changes between end-of-day values, but 
  would like to produce candlesticks of the composites if possible.

  Assuming closing values only, each composite will start with an 
  initial value (like 100) and then, for each day, the average of all 
  the %changes (from the previous day) will be added to the preceding 
  value. Using a simple 3 component composite as an example, assume for 
  the second value of the composite (remember the first value will be 
  100), we have the following %changes.

  Component1 = +1.2%
  Component2 = +2.4%
  Component3 = -1.7%

  So the first day's average %change = ( 0.012 + 0.024 - 0.017 ) / 3

  100 + ((0.012 + 0.024 - 0.017) / 3) + (the next day's average %
  change) + ...

  The component values for volume are just added (or averaged) to get 
  the daily values.

  TIA for any help.