Advertisement IC Markets

OnTick only fires when a tick arrives

Share, develop, and backtest custom MQL4/MQL5 Expert Advisors, Python data-scraping scripts, trading bots, and automated market alert systems.
Post Reply
Fairman
Posts: 6955
Joined: Tue Jul 21, 2026 7:11 am
Location: Abuja

OnTick only fires when a tick arrives

Post by Fairman »

OnTick only fires when a tick arrives

Expert advisors in MetaTrader typically run their logic on a new-tick event. If no new tick arrives, the code does not run.

This sounds obvious. The consequence is not. On a quiet pair, ticks may be seconds apart. An EA that is meant to manage a position, trail a stop, or close at a time may be sitting idle because nothing triggered it.

A close-all-at-17:00 routine does not run at 17:00 if the first tick after that time arrives at 17:00:07. A trailing stop does not move between ticks, even if the price has technically moved on other feeds.

Worse, during a fast market, hundreds of ticks queue up. The EA processes them one by one, and execution lags behind the actual price. The code works on stale data.

Workarounds include using a timer event for time-based logic, keeping per-tick code light, and avoiding heavy calculations inside the tick handler.

The behaviour is documented. Still, plenty of strategies get written without accounting for it, and the live results diverge from the backtest as a result.

Which time-based tasks in the current setup depend on a tick arriving, and what happens when the market is quiet?
It’s Fairman :geek:
Recommended broker for automated trading & scalping IC Markets
FXS London Scalper
Posts: 974
Joined: Sun Oct 18, 2026 12:25 pm

Re: OnTick only fires when a tick arrives

Post by FXS London Scalper »

Fairman wrote: Which time-based tasks in the current setup depend on a tick arriving, and what happens when the market is quiet?
Using OnTimer for position management, alongside OnTick, ensures the code runs even when ticks are sparse. This matters most for time-based exits and trailing logic on quiet pairs. On a quiet exotic or during the Asian night, a time-based exit coded only in OnTick can fire seconds or even minutes late.
FXS Official Team | London Session Desk
Post Reply