СIsNewBar class is necessary for the efficient work of the Expert Advisors that make calculations at the moment the new bar appears.
Usually IsNewBar() function is used for such things instead of a class. But such a function contains a static variable, and therefore we cannot use several calls of this function. To be able to reuse such function repeatedly in Expert Advisor’s code, it would be much easier to make it a class member. In this case that has been accomplished using IsNewBar.mqh.
The library code should be included in the file content on the global level using #include directive:
#include <IsNewBar.mqh>
Then, the required number of СIsNewBar class variables must be declared in OnTick() block of the Expert Advisor:
static CIsNewBar NB1,NB2;
After that we can make calls to IsNewBar() functions
bool IsNewBar(string symbol,           // currency symbol  ENUM_TIMEFRAMES timeframe)// calculation chart timeframe
in the Expert Advisor code:
if(NB1.IsNewBar(Symbol(),PERIOD_D1)) // checking for a new bar     {      /* Here is a trading signal 1 receiving block code */     }
Here is the possible example of the code that includes СIsNewBar class inside OnTick() function:
//+------------------------------------------------------------------+ //| Expert tick function                                            | //+------------------------------------------------------------------+ void OnTick()   { //----   double iClose1[1],iClose2[1]; //---- declaration of static variables   static bool Recount1=true,Recount2=true;   static CIsNewBar NB1,NB2; //+----------------------------------------------+ //| Detecting market entry signals              | //+----------------------------------------------+   if(NB1.IsNewBar(Symbol(),PERIOD_D1) || Recount1) // checking for a new bar     {       Recount1=false;             //---- copy newly appeared data in the arrays      if(CopyClose(Symbol(),PERIOD_D1,1,1,iClose1)<=0) {Recount1=true; return;}             /* Here is a trading signal 1 receiving block code */           }       if(NB2.IsNewBar(Symbol(),PERIOD_H4) || Recount2) // checking for a new bar     {       Recount2=false;             //---- copy newly appeared data in the arrays      if(CopyClose(Symbol(),PERIOD_H4,1,1,iClose2)<=0) {Recount2=true; return;}             /* Here is a trading signal 2 receiving block code */           }