Automate a Trading Strategy (Part 5) — From OHLC to Real Tick Logic: Buckets, Statefulness, Debounce, and Realistic Execution

Lab Note (Part 5). Up to now we have been building a research workflow step-by-step: prototype fast, port to MT5, add context filters, and iterate with discipline. In this part we make the next critical leap: leaving simplistic OHLC modelling behind and moving toward real tick logic and realistic execution behavior.

If you haven’t read the previous parts, start here:

In Parts 2–4 we primarily tested in OHLC. That is a useful model for early research, but it becomes dangerously optimistic (or simply inconsistent) when you move toward live trading.

So in Part 5 we address two core problems:

  • OHLC modelling hides intrabar sequencing and timing issues
  • OHLC-based “clock logic” does not behave like a real tick-driven engine

OHLC vs Real Ticks: what changes (and why live results diverge)

OHLC backtesting uses candle summaries: Open, High, Low, Close. The engine must make assumptions about what happens inside the candle.

Real ticks are the actual sequence of price updates as they occurred, with irregular timing and real intrabar paths.

This difference can generate major discrepancies in live trading:

  • TP/SL ordering ambiguity: if both TP and SL are inside the same candle range, OHLC must guess which happened first.
  • Entry timing drift: OHLC logic triggers exactly on bar boundaries; real ticks may arrive late or cluster around those boundaries.
  • Spread and microstructure: OHLC often simplifies execution; ticks expose the real path and the real “opportunity cost” of spread/slippage.
  • False confidence: OHLC can look smoother than reality because it compresses the path.

Engineering principle: a backtest is only as realistic as the combination of data quality and execution model.

From “OHLC clock logic” to “real-time bucket logic”

Many OHLC strategies rely on hard time matching such as:

  • minute % 5 == 0
  • minute % 15 == 0
  • hour % N == 0

That looks clean in OHLC backtests, but live markets do not deliver ticks perfectly on the boundary second. In reality, the first usable tick of a new candle can arrive late.

So we move to a different architecture: continuous epoch buckets.

Instead of asking “is it exactly the boundary minute?”, the engine asks:

  • did we enter a new time bucket?
  • if yes, fire the bucket event once

Theoretical effect: fewer false/missed triggers caused by imperfect tick timing at candle boundaries.

Multi-timeframe events become edge-triggered and stateful

With OHLC clock logic, multi-timeframe synchronization often produces either:

  • duplicates (the same event fires multiple times inside the same interval), or
  • misses (the event never fires if the first tick arrives late).

In a tick-driven system, each timeframe maintains a state: the last processed bucket ID. Events fire only when the bucket changes.

Theoretical effect:

  • no duplicate triggers within the same timeframe interval
  • fewer lost triggers when the first tick is delayed relative to the theoretical OHLC boundary

Warm-up at startup: eliminating ghost triggers

One classic OHLC/backtest problem is a “phantom” trigger at startup. It happens when internal time states are uninitialized.

We solve this with explicit warm-up:

  • at boot/backtest start, initialize each timeframe bucket state to the current bucket
  • do not generate events until a genuine bucket transition occurs

Theoretical effect: you remove spurious events right after start and keep behavior aligned with a live engine.

More realistic tick handling: debounce / throttling

Tick streams can be noisy. Without protection, a naive engine can fire redundant logic multiple times in the same second.

We introduce a debounce/throttling mechanism:

  • avoid repeated processing bursts inside the same minimal time slice
  • execute only when meaningful time transitions occur (bucket changes)

Theoretical effect: the pipeline becomes more stable and closer to real live execution behavior.

Operational windows tied to real time buckets (not just “new minute”)

In OHLC logic, operational triggers are often “minute-by-minute”. In a tick-driven model, the logic is synchronized to:

  • M5 bucket transitions
  • session operability conditions (trade/skip rules)

Theoretical effect: less over-triggering, better alignment with how a live system actually operates (defined cadence + real session gating).

State continuity even during non-operable periods

When the system is not allowed to trade (session closed, skip windows, roll constraints), a naive approach is to “freeze everything”. That creates problems when trading resumes: the engine can generate catch-up bursts.

Instead, we update temporal state continuously even during non-operable periods.

Theoretical effect: no retroactive spikes, no catch-up triggers, smoother re-entry behavior.

Why we must use real ticks (and why broker ticks are often not enough)

Once we shift to tick-driven logic, using real ticks becomes mandatory.

But there is a second layer: tick quality.

Broker-provided ticks can be helpful, but they can also be:

  • sparse (especially in older history)
  • patched or incomplete
  • inconsistent across time due to feed changes
  • broker-dependent (your “history” becomes your broker’s artifact)

And this is where the problem becomes serious.

You can run a “real tick” backtest in MT5 and still get a completely wrong answer if the tick history is incomplete.

Case study: default MT5 real ticks vs downloaded real ticks

To demonstrate the impact of tick quality, we ran the same strategy with two different datasets:

  • MT5 default “real ticks” (broker history)
  • downloaded real ticks imported into MT5 (cleaner and more complete)

The difference is visible immediately inside MT5: the “History Quality” bar changes color. When the bar turns brown, it indicates missing tick coverage.

And the results are radically different:

With default ticks, the strategy looks profitable.
With downloaded real ticks, the strategy becomes a complete loss.

This is exactly the kind of discrepancy that destroys retail research and creates false confidence.

RSI SAMPLE STRATEGY | TRADING ENGINEERING LAB | 2021 TO 2026 | SP500 | DEFAULT TICK DATAS
RSI SAMPLE STRATEGY | TRADING ENGINEERING LAB | 2021 TO 2026 | SP500 | DEFAULT TICK DATAS

Real tick results (downloaded): the strategy collapses

When we test with downloaded real ticks, we obtain:

  • Initial deposit: $100,000
  • Net profit: -$7,240
  • Profit factor: 0.84
  • Max equity drawdown: 13.52%
  • Total trades: 123

This is not a small deterioration. It is a structural failure.

And that’s the point: once you remove modelling artifacts and missing data, the “edge” disappears.

RSI SAMPLE STRATEGY | TRADING ENGINEERING LAB | 2021 TO 2026 | SP500 | REAL TICK DATAS
RSI SAMPLE STRATEGY | TRADING ENGINEERING LAB | 2021 TO 2026 | SP500 | REAL TICK DATAS

Default MT5 real ticks: why it can look profitable (and why it’s misleading)

When we run the test with MT5 default ticks, the backtest looks dramatically better:

  • Initial deposit: $100,000
  • Net profit: +$9,797
  • Profit factor: 1.41
  • Max equity drawdown: 5.75%
  • Total trades: 86

At first glance this looks like we finally found a weak but usable edge.

But the “History Quality” is only 46%, which means the tick sequence is incomplete.

That leads to multiple distortions:

  • missing micro-moves that would hit stops
  • missing adverse sequencing inside candles
  • incorrect spread exposure during fast movement
  • artificially smoother paths that allow TP to be reached more often

Lab takeaway: incomplete tick data can literally turn a losing strategy into a profitable one on paper.

Why does this happen?

Because when tick history is missing, the backtester is forced to “fill gaps” or reconstruct price paths using incomplete information.

That reconstruction often becomes optimistic by default:

  • stops are hit less frequently
  • TPs are reached more easily
  • sequencing becomes cleaner than reality

In other words:

The strategy didn’t change. The market data did.

And when you are working on scalping or short-horizon mean reversion systems, tick quality is not optional — it is the entire game.

Our workflow: importing reliable ticks into MT5 with Quant Data Manager

In our internal workflow we use Quant Data Manager to manage and prepare tick data for MetaTrader 5.

Once data is prepared, it can be imported into MT5 so that Strategy Tester can run using a more realistic tick history.

Official guide:

Why this matters: when your execution model becomes real-time and tick-driven, the data source becomes the foundation. If tick data is unreliable, your conclusions are unreliable.

OHLC vs Real Ticks: final comparison

Now we can finally complete the full comparison between the modelling stages.

OHLC backtest (previous model):

  • Total return: ~+10%
  • Max drawdown: ~5%
  • Key observation: the strategy looked “weak but stable”.

Real ticks backtest (downloaded):

  • Total return: -7.24%
  • Max drawdown: 13.52%
  • Key observation: the strategy collapses once realistic microstructure is restored.

This is exactly why Part 5 exists.

Professional conclusion: a strategy that cannot survive the transition from OHLC to real ticks was never validated in the first place.

Get the code (free) — Telegram channel

If you want the exact code used in this series, you can get it for free in our Telegram channel.

Inside you’ll find:

  • EA source code used in the articles
  • the bot files plus settings presets
  • notes to reproduce the same tests step-by-step

Join the Telegram channel here: https://t.me/tradingengineeringlab

We share it there because it’s the easiest way to keep everything updated in one place (code, settings, fixes, and future improvements).

What’s next: validating beyond in-sample

The series ends here. But if we see enough interest, we’ll create a new series with a strategy that has a real edge in the market and show step-by-step how to validate and improve it. Furthermore, since the strategy will survive where this one failed, we’ll look at another vital point: we will focus on the step that separates serious research from “pretty backtests”:

  • how to validate the strategy after in-sample testing
  • out-of-sample evaluation, stability checks, and robustness criteria
  • how to avoid building a strategy that only works on its training period

Because the real objective is not to win the backtest — it’s to build a system that survives reality.

The Trading Engineer
The Trading Engineer
For over five years I’ve used trading as a real laboratory: I design rule-based strategies, test them on real data with code, bots, and tools I build myself, and deploy them on funded accounts with a verifiable track record. I hold three technical degrees, all completed with top grades, and I bring the same rigor into the markets. I founded Trading Engineering Lab to document this work transparently: no shortcuts, no easy promises, no “signals” or improvised courses—just numbers, journaling, rigorous analysis, and continuous system improvement. I write about systematic trading, risk management, statistical validation of strategies, and how discipline in trading and in life shapes performance. For me, trading is an experiment, not a lottery ticket. If you’re looking for hype, I’m probably not the right fit. If you’re interested in models, data, and process, welcome to the lab.

Artículos relacionados

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Subscribe to our newsletter

To stay up to date with the latest news, offers and special announcements.

I have read and agree to the terms of use page and privacy policy provided in accordance with Article 13 of EU Regulation 679/2016 and I consent to email marketing purposes.

Trending Now