Please explain the code line by line...

 

if (TimeBar==Time[0]) return(0);
if (TimeBar==0) {TimeBar=Time[0];return(0);}//first program run
double EMA0 = iMA(NULL,0,period_EMA,0,MODE_EMA, PRICE_OPEN,0)

What is Time[0]? I think it is time of the first bar.

here Time[0] is 0, if it is 0 it retuns(0).it means it shops execution,

when it will be comes 3rd line?

Thanks,

Venkat.

 
venkates.99:

when it will be comes 3rd line?


immediately after a new bar has appeared, because timebar is NOT zero and NOT time[0]

after a newbar timebar is time[1]

 
Alternatively:
datetime TimeBar;
int init() {
   TimeBar = Time[0]; // Comment out if you want to handle
                      // partial bar on start up.
   //...
}
int start() {
   if (Time[0] <= TimeBar) return(0); // Process on new bar only.
   TimeBar = Time[0];                 // Once per bar.
   //...
Reason: