OnTick vs OnTimer in MQL5: structure a responsive EA

An EA is an event-driven program. A clear division between setup, market decisions and maintenance helps both a human developer and an AI coding assistant make smaller, safer changes.

Give each handler a clear responsibility

Use OnInit for setup and input validation, and OnDeinit for cleanup. OnTick receives new-quote events for the chart symbol. OnTimer handles timer events after a timer is subscribed. These entry points are a useful architectural map when you open an unfamiliar source project.

Keep the event queue responsive

MQL5 processes events sequentially for a program. If a NewTick event is already queued or being handled, another NewTick is not added. Long blocking work inside a handler therefore deserves attention. A loop that waits indefinitely for a condition is not a substitute for an event-aware design.

Use periodic work intentionally

A timer can suit a status panel or periodic housekeeping. A shorter timer period can also increase tester work, so choose a frequency that serves a visible purpose. A timer is not a guarantee that a fresh market quote exists, and it does not automatically improve execution quality.

Sketch the flow before editing

  1. List what happens once at startup.
  2. List what requires every relevant quote.
  3. List what only needs a periodic refresh.
  4. Define how the program reacts when data is unavailable.
  5. Test shutdown and reinitialization as well as normal operation.

Make it yours with MQLume

Bring a clear architecture to your next custom build. MQLume gives you editable projects that you can read, compile and refine, including Quantum Titan MT5.

Sources and further reading

Back to top

Inspect the source projects

Review the delivered release, input guide and documented testing scope for each package.

Quantum Titan MT5The Gold Reaper MT5My AI Gold MT5Ultimate Breakout System MT5Quantum Commander MT5

Cart

One personal-use licence per project. Each project can be added once.

Your cart is empty

Choose a source project to get started.

Continue shopping