Does this logic work ?

 

static datetime Time0;

int start()
{

bool newBar;
newBar = Time[0] > Time0;
if (newBar) Time0 = Time[0];

if (liHour == EndHour + GMToffset && newBar)
more conditions here
then open a buy or sell

Return(0);

}

Does the above IF condition with AND clause work ? It worked on backtesting.. but on live demo it didn't. I wanted the control to go into the loop only once in a day

exactly at 7 AM (USA PST) time and when the new bar is opened.

If I remove " && newBar" clause, the control goes into the loop until time turns to 8 AM. I don't want that..

Any ideas.. does time change and new bar does not happen at the same time ?