How to find new candle (new bar) use MQL programming?

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
bitcoin analysis

ETH

We suggest buying Atrium for a short period of time...

bitcoin analysis

BTC

According to version 2.1 of the FMP trading system, the...

Scroll to Top