PureBytes Links
Trading Reference Links
|
On Feb 25, 7:31pm, Earl Adamy wrote:
>
> When I attempt a direct backward reference (variable[n]) or
> indirect backward reference (a crosses above b) in a simple
> function I get syntax errors. An Xavg requires reference to the
> previous period value, so if you've got an example where backward
> reference is performed withing the function, I'd like to see how
> it's done. As I think about it, the example you saw probably
> recurses the same variable so that the value being passed to the
> next iteration of the function is the same as the value returned
> by the previous iteration e.g. xAvg = f_xavg(xAvg)?
Here's the example, that was described in the Sept/Oct 1996 issue
of TS Express, p. 5 (copyright Inside Edge Systems). (The article
gave a thorough coverage of the use (and misuse) of simple/series
functions). I've cut the example down, to show the use of
the previous value of a variable declared inside the function. I
actually haven't checked this method out, but assume that it works:
(
User function: Xavg
Property: Simple
}
Inputs: Price(numericseries), Length(numericsimple);
Var: Factor(0), Return(0);
{ .... initialize Factor .... }
Return = Factor*Price+(1-Factor)*Return;
Xavg = Return;
For this to work, Xavg has to be called on each bar, and I'd
guess there's a problem if you call it with more than one
numericseries in the same chart.
--
--
| Gary Funck, Intrepid Technology, gary@xxxxxxxxxxxx, (650) 964-8135
|