30 April 2023

If you prefer not to run your code on every tick, you can schedule it to run during the launch of a new bar or after any specific time period. This can be a useful feature for those who want more control over when their script runs.

Source code viewer
  1. static datetime PrevBars=0;
  2. datetime time_0 = iTime(Symbol(), PERIOD_M1, 0);
  3. if(time_0 == PrevBars)
  4. return;
  5. PrevBars = time_0;
  6.  
  7. // Code after this will only run once per the given period.
Programming Language: MQL5