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

Re: How might this be done in TS?



PureBytes Links

Trading Reference Links

How about using the MRO fxn?

syntax: MRO(expression, len, occur)

Best,
Bill

----- Original Message -----
From: "Alex Matulich" <alex@xxxxxxxxxxxxxx>
To: "Steve Gibbons" <sg27@xxxxxxxxxxxxxx>
Cc: <omega-list@xxxxxxxxxx>
Sent: Wednesday, May 28, 2003 11:57 PM
Subject: Re: How might this be done in TS?


> >Example: valuewhen(2,average(c,10) = C,rsi(c,20));
> >
> >would return the value of RSI on the 2nd most recent occurrence of
close
> >equal to the 10 bar moving average.
>
> The following should work because TS saves local variable values
> in separate contexts for each instance of a function call.
>
> ----------------------------------------------------------------------
> {function valuewhen
>  returns -999999 until the tested condition is true for maxcount
number
>  of times, after which the passed return value is returned.}
>
> inputs:
>     maxcount(NumericSimple),
>     testcondition(TrueFalse),
>     returnvalue(NumericSimple);
>
> var: counter(0), savedretnval(-999999);
>
> if counter < maxcount then begin
>     if testcondition then counter = counter + 1;
>     if counter = maxcount then savedretnval = returnvalue;
> end;
> ValueWhen = savedretnval;
> ----------------------------------------------------------------------
>
> -Alex
>
>