View Single Post
  #3 (permalink)  
Old 09-30-2006, 03:56 PM
suffic369 suffic369 is offline
Member
 
Join Date: Nov 2005
Posts: 52
suffic369 is on a distinguished road
the prevtime variable must be staitc

example:

to find the bar position of the latest C cross up the ma


int barsSince() {

int bars=Bars;
static datetime prevtime=0;
if( prevtime == Time[0]) return(0);
prevtime = Time[0];

for (i=0,i<bars,i++) {
ci=Close[i];
c1i=Close[1+i];
mai=iMA(....,i);
ma1i=iMA(....,1+i);

bool cXmaUp=ci>mai && c1i<ma1i;

if (cXmaUp) {
int barPos=i;
break;
}
}

if (barPos<bars) return(barPos);
else return(-1);

}

to call this function you will get the latest bar position of c cross up ma.

suffic369
www.wsforex.com

Last edited by suffic369; 09-30-2006 at 08:14 PM.
Reply With Quote