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

Re: Arrrgh!!! Call for Simple(?) ELA Help, Please



PureBytes Links

Trading Reference Links

> I've been playing with the MRO function.  For example, assuming
> approximately 10 ticks/min and that the Time function is expressed in
> seconds:
> 
> Value1 = MRO(Time <= Time - 300,100,1), where Value 1 should return the
> BarNumber of the Bar 300 seconds ago, and therefore Bars in the Past 300
> Seconds = CurrentBar - Value1.
> 
> Nevertheless, Value1 as above returns 0.  I'm missing something,
> somewhere.

I'm missing something too.  That should return -1, as in "that event 
never happened."

You're trying to determine the most recent occurrence of:

  Time (on bar X) <= Time (on **THIS** bar) - 300

But MRO doesn't know you wanted to use two different values of Time.  
It's looking for

  Time (on bar X) <= Time (on bar X) - 300

...which of course is never true.

I don't think you can use MRO to do what you want.  MRO evaluates its 
expression on every bar, and then it looks back to find the last time 
the result of that (static, unchanging) expression was true.  You 
want the "Time (on THIS bar)" element to change on each bar, and MRO 
doesn't do that.

Also, I assume you're not really using Time (the EL variable that 
expresses the current time as 100*hours+minute), but some seconds-
based variable of your own, right?

You'll have to do the looping yourself, something like this:

BarsBack = 0;
while TimeSecs[BarsBack] > TimeSecs-300 begin
  BarsBack = BarsBack + 1;
  end;

If you're not certain you'll find a 300-second-old bar within your 
MaxBarsBack limit, you should also add in a test for MaxBarsBack.  
Otherwise your indicator will barf in a hyperactive market.

Gary