5 October 2021

Do work only at the time of the birth of a new candle.

Source code viewer
  1. datetime previousCandleDatetime, currentCandleDatetime;
  2.  
  3. void OnTick()
  4. {
  5. currentCandleDatetime = iTime(Symbol(), Period(), 0);
  6. if (currentCandleDatetime == previousCandleDatetime)
  7. return;
  8. previousCandleDatetime = currentCandleDatetime;
  9.  
  10. // ... your work
  11.  
  12. }
Programming Language: MQL5