Download MetaTrader 5

How to force EA to don't calculate anything in the first bars!!

To add comments, please log in or register
How to use MQL5.community messages editor? Find out in the article!
Wemerson Guimaraes
575
Wemerson Guimaraes 2015.06.12 18:40 

Hi... Greetings from Brazil!

I'm starting to build my first EA and one of his strategies is analise RSI from the last 3 past candles... But i need to force the EA to do start the calculations only on data after EA stated, then the past candles on EA starting must be discard.


I'm working on the logic, but do not understand how to do it right.

think someting like:

int barStart = Bars + 3;

void OnTick(){

   if(Bars <= barStart)
      return ;

}

Any tip? I'm testing it and appears to works fine... but i don't have 100% of certain if this is the best option to do!

Paul B
175
Paul B 2015.06.13 18:51  

Try this:

 

int init()
{
   startBar=Time[0]+Period()*3*60;
return(0);
}

int start()
{
   if(Time[0]<=startBar) return(0);

   // Place your EA code here

return(0);
}
Wemerson Guimaraes
575
Wemerson Guimaraes 2015.06.15 16:10  
Ok, tks
To add comments, please log in or register