Forex
Google

Go Back   Forex Trading > Downloads > Tools and utilities
Forex Forum Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-13-2006, 09:45 AM
suffic369 suffic369 is offline
Member
 
Join Date: Nov 2005
Posts: 49
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 09-21-2006, 08:45 AM
fonzfx fonzfx is offline
Junior Member
 
Join Date: Sep 2006
Posts: 2
fonzfx is on a distinguished road
Hi suffic369...thanks for converting such a great function.

But after i pasted the function in my EA, i am having problem in calling the barsSince() . Can you show an example how to call it inorder to know the bar position?

Many Thanks for your effort.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-30-2006, 03:56 PM
suffic369 suffic369 is offline
Member
 
Join Date: Nov 2005
Posts: 49
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump



All times are GMT. The time now is 06:18 AM.