Need help with coding.

 

can anyone advise, what's the coding for

at the start of each candle (different from the time frame you are using for the EA itself)

thanks!

 
yuan83:

can anyone advise, what's the coding for

at the start of each candle (different from the time frame you are using for the EA itself)

thanks!

https://www.mql5.com/en/forum/139517

:)

 

You can do something like this . . .

int TF = Period_M5;   //  what timeframe do you need ?

datetime LastBarTF;

//  Time of the current bar, updated for each tick
datetime CurrentBarTF = iTime(NULL, TF, 1 );


if (CurrentBarTF2 != LastBarTF )   //return if current bar hasn't finished
   { 
   //  do stuff in here that you want to do at the first tick of the new bar
        
   LastBarTF = iTime(NULL, TF, 1 );  
   }
 
RaptorUK:

You can do something like this . . .


hi Raptor,

thanks.

let me try to make some sense of your code..

datetime CurrentBarTF = iTime(NULL, TF, 1 ); will keep showing the same value due to the time frame defined, till the next 5 min is reached?

thanks.


 
yuan83:


hi Raptor,

thanks.

let me try to make some sense of your code..

datetime CurrentBarTF = iTime(NULL, TF, 1 ); will keep showing the same value due to the time frame defined, till the next 5 min is reached?

Till the next 5 min Bar arrives . . . yes.
 
thanks bro