View Single Post
  #1 (permalink)  
Old 04-13-2006, 09:45 AM
suffic369 suffic369 is offline
Member
 
Join Date: Nov 2005
Posts: 52
suffic369 is on a distinguished road
barssince(), vauewhen()

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

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