Dear All's,

as the name itself says addtocomposite is a very useful tool to build
indicator which can be obtained by summing over all the elements of a
given set a given function of its values.

For example using a quite obvious mathematical notations :
average=1/N Sum(x_i,i=1,i=N) or in general
with addtocomposite would be obatined by 

addtocomposite(x)/N 
run in scan mode of the set.

(forget about the afl sysntax here..)
i index here stands for element i.e. stock for example, not for bar
index, which is implicitly the same for all elements in this notatios

What twhen I want to create a different indicator which has a more
general form like product(x_1,i=1,i=N) or sum(x_i^2+x_(i-1)^3,i..)
That is required for example to calculate the geometric mean, which
has some importance in maximizing expectancy in ( kelly criterion ..)

The only way I see would be to loop through the elements and build the
indicator (also looping through the bars if necessary), but how would
I then the assign the result to the value of a symbol ?

I could scan the formula over 1 dummy symbol calculating my indicator
and then use addtocomposite(which since I scan only over one symbol
will simply assign the result) but I wonder if there is a better way.
For Example creating ProductToComposite to afl ..

Also an out of scope question, when the option to use addtocomposite
in backtesting mode is activated, is the ~symbol  constructed first
and then the backtester is using it(juest after) ?In this case two
full loops over all symbols would be required but I noticed that there
seems to be just one loop no matter what setting is used.


Thank
Ly


Reply via email to