So I have a strange problem. I tried to verify NewBar appearance with the following code from Samuels article "Step-By-Step Guide to writing an Expert Advisor in MQL5 for Beginners". I tried the code on System Tester and I saw that is no trade. Than I saw that the Old_Time variable take the value of New_Time variable without any code.
I mean that Old_Time=New_Time but IsNewBar is never equal to true.
I do not know why Old_Time is equal to New_Time[0] without execution of the if(Old_Time!=New_Time[0]) loop.
.
I hope you understand what I mean.
Sorry for my bad english.
Variable IsNewBar is declared locally, and so it will initiated on every tick with false value. To solve this, declare variable IsNewBar as statically declared local variable or globally declared variable.
Please read MQL5 doc about variable especially this Visibility Scope and Lifetime of Variables
Here's how to declare as statically declared local variable
void OnTick() { static bool IsNewBar=false;
Here's the global one
bool IsNewBar=false; void OnTick() {