metastock-like functions:
since it costed me quite some time to figure out a self-made metastock-like function, I think it might be valuble for some people to have the function code. Therefore I decide to post the code here.
barssince() function:
//by suffic369
int barsSince() { bool cond;
int bars=Bars;
static datetime prevtime=0;
if( prevtime == Time[0]) return(0);
prevtime = Time[0];
for (int i=0;i<=bars;i++) {
if ( cond ) {
int barPos=i;
break;
}
}
if (barPos<bars) return(barPos);
else return(-1);
}
valuewhen(): if you know the bar position,it is easy to know the value of whatever you want.
suffic369
www.wsforex.com