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();
bool IsNewCandle() {
if (NewCandleTime == iTime(Symbol(), 0, 0)) return false;
else {
NewCandleTime = iTime(Symbol(), 0, 0);
return true;
}
}