Help converting small piece of code from mt4 editor to mt5 editor

 

So I was using this piece of code to calculate the most recent bar.

 

   static datetime BarTime=0;
   datetime now_bar=Time[0];
   if(BarTime!=now_bar)
     {
      BarTime=now_bar;





     }


 I am having trouble converting it to do the same thing on meta trader 5.

Im relatively new to coding but thought I may aswell learn mt5 editor cause mt4 is dieing out. 

 
The "New Bar" Event Handler
The "New Bar" Event Handler
  • 2010.10.11
  • Konstantin Gruzdev
  • www.mql5.com
MQL5 programming language is capable of solving problems on a brand new level. Even those tasks, that already have such solutions, thanks to object oriented programming can rise to a higher level. In this article we take a specially simple example of checking new bar on a chart, that was transformed into rather powerful and versatile tool. What tool? Find out in this article.