Thread: How to code?
View Single Post
  #1060 (permalink)  
Old 07-02-2008, 01:40 AM
TheRumpledOne's Avatar
TheRumpledOne TheRumpledOne is offline
Banned
 
Join Date: Nov 2006
Posts: 802
TheRumpledOne is an unknown quantity at this point
That was nice of you, Lux.

I found this:

Only process each bar once - MQL4 forum

Automated 2008.01.15 18:54 You could execute your code at the very first tick of a new bar ( i.e. right after the previous bar has closed ).
Here's a function that will return TRUE if a new bar has just formed:
// This function returns TRUE at the very first tick a bar i.e. after the previous bar has just closed
bool NewBar()
{
if(PreviousBarTime<Time[0])
{
PreviousBarTime = Time[0];
return(true);
}

return(false); // in case if - else statement is not executed
} you need to declare datetime PreviousBarTime at the beginning of your EA...
then in your code you could just use
if ( NewBar() )
{
...... code you need to be executed after a bar has closed here ....
} thank you
automatedfx@gmail.com


---------------------------------------------------

I noticed you used STATIC... I looked it up... what's the advantage of using STATIC vs a global variable?

Last edited by TheRumpledOne; 07-02-2008 at 01:55 AM.
Reply With Quote