PureBytes Links
Trading Reference Links
|
> Hi All,
> I am trying to find the Easylanguage code for multiplying a series of
> numbers together which is the same as Excel's "PRODUCT" function.
>
I haven't checked it out, but you might try something along
the following lines:
{ function: product }
intputs: p(numericseries), N(numericsimple);
vars: j(0), init(false), prod(0);
if not init then begin
product = 1.0;
for j = 0 to (N-1) begin
product = product * p[j];
end;
init = true;
end else begin
product = product / p[N] * p[0];
end;
This uses the technique that I mentioned earlier, that uses past
values of the price series, in order to speed up the computation.
Above, I don't know if EL will remember the last value of
prodcut but I think it will. Give it a try. Note: set maxbarsback
manually to be as far back as you need (don't use autodetect),
and make sure your price series doesn't have zeroes in it.
Slower, but simpler is:
product = expvalue(summation(log(Price), N));
This needs N data bars after the first bar to begin calculating
the correct value though, unless you wrap it in a function
that first looks back to calculate the initial value.
|