Here are two ways to identify a new candlestick using MQL for MetaTrader.

static int BARS;
bool IsNewCandle()
  {
   if(BARS!=Bars(Symbol(),PERIOD_CURRENT))
     {
      BARS=Bars(Symbol(),PERIOD_CURRENT);
      return(true);
     }
   return(false);
  }
datetime NewCandleTime=TimeCurrent();
datetime NewCandleTime=TimeCurrent();
bool IsNewCandle(){
   if(NewCandleTime==iTime(Symbol(),0,0)) return false;
   else{
      NewCandleTime=iTime(Symbol(),0,0);
      return true;
   }
}
 

Share with your friends

Share on facebook
Share on twitter
Share on linkedin
Share on reddit
Share on telegram
Share on whatsapp
Share on email