Is it really necessary for an EA to count available bars at every price tick?

 

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.

 

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


hth

Reason: