In general it isn't really necessary to use bar counting in your EA. But it can be helpful if you want to make it absolutely sure you won't get a signal until your indicators are giving the correct output. For instance if your using a MA(24), it will return the correct output from bar 25
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Here is some typical code which prevents an EA from trading until enough bars are available.
start()
{
.....
.....
//Are there enough bars to consider a trade?
if (Bars < 25)
{
Print(" Bars < 25. Waiting for more bars.");
return(0);
}
.....
.....
}
Code like this is seen in some examples and not in others.
While I appreciate that an EA cannot work if there are no bars, I don't understand why or when this would happen.
Thank you in advance.