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

Re: Better Method



PureBytes Links

Trading Reference Links


-----Message d'origine-----
De : Gary Fritz <fritz@xxxxxxxx>
À : Bert <mbcsne@xxxxxxx>
Cc : omega-list@xxxxxxxxxx <omega-list@xxxxxxxxxx>
Date : dimanche 2 mai 1999 03:28
Objet : Re: Better Method


> Is there a better way to check for a series of similar events?
> I know this works, but I can't believe it's the best way to do
> it...... any help would be appreciated.
> If C > C[1] and C[1] > C[2] and C[2] > C[3] and C[3] > C[4]
> ........{etc. out to 7, 9, 17, or 23 days ago.....}

A loop is probably the easiest way to do this:

Vars: Idx(0);

Condition1 = True;
for Idx = 0 to Length-1 begin
  Condition1 = Condition1 AND C[Idx] > C[Idx+1];
  end;

{ Now Condition1 is True if you had Length consecutive rising closes }

Gary

=========
Yes but there is a clever method that will avoid the for loop and take
advantage of the maxbarsback concept:

Vars: Idx(0);
Condition1 = c>c[1];
if  Condition1 = then idx=idx+1;

Now idx contains an updated running sum of occurences since the begining of
that database.
The numbers are stored in the maxbarsback  buffer up to mbb bars before
curentbar
If you want  to check the N days ago condition then write:

if idx-inx[N]= N then [do something....]

Of course, if N occuences occured during the N previous bars, this is
reflected by the fact that idx is N higher than inx[N] , Nbars ago.
( N must be less than mbb).

This simple code avoids x for loops of length N where  x = nb bars of
database -mbb and N the number of occurence tested.
The incraese of speed is proportional to (x*N-N)/x =x*(N-1)/x = N-1.
 roughly, I do discuss only on the for loop code)

For a N=23 value you should expect a 22 times faster code.


Sincerely,

-Pierre Orphelin
Représentant exclusif de Omega Research en France.
web: http://www.sirtrade.com