Professional

MT5 OHLCV Bars Pipeline

· Pricesearcher

Market candle bars flowing through a pipeline into partitioned storage tiles.

Problem

Trading research needed repeatable histories of one-minute OHLCV bars across symbols and dates. MetaTrader 5 held the source, but the Windows terminal loads symbol history on demand; manual exports did not provide a dependable shared dataset.

Constraints

Extraction depended on terminal and broker history, not an independent market-data feed. The current day was still being written, repeated imports could duplicate bars, and leaving a Windows EC2 instance running continuously would cost money.

Solution

An hourly Monday–Friday job on Windows EC2 fetched M1 bars via the MT5 Python API. Compressed daily symbol/date Parquet partitions and monthly aggregates went to S3. A CLI discovered symbols, fetched selected partitions into a local cache and ingested historical CSV exports into the same layout. Lambda, CloudWatch, Pulumi and PowerShell handled scheduling and operations.

My Role

I built the scheduled extraction with symbol filters and a tick-preload fallback for unloaded terminal history. I implemented partitioned storage, read-merge-deduplicate-write imports, the cache/backfill CLI, logging, heartbeats, bank-holiday handling and timestamp/timezone fixes.

Technologies

Python, MetaTrader 5, pandas, Parquet, AWS (S3, EC2, Lambda, CloudWatch), Pulumi, PowerShell.

Engineering Challenges

  • Unreliable availability at the source: Terminal history might not yet be loaded. Tick preloading and explicit backfills addressed that condition without presenting broker data as complete by default.
  • Repeatable updates without a database: Partitioning by symbol and date matched research reads; merging and deduplicating before writes made repeated imports safe. Cache updates skip the in-progress day to avoid freezing partial data locally.
  • Operational cost versus freshness: Hourly weekday collection and scheduled EC2 startup/shutdown provided regular updates without paying for an always-on terminal host.

Outcome

The trading platform and research tools can read a shared bar history by symbol and date, with historical CSVs feeding the same format. Coverage still depends on what the terminal and broker provide; this is not a claim of complete market history.

Relevant services

Have a Python, AI or automation problem?

Tell me what is slowing the business down, what you have tried, and what a successful outcome looks like. I'll help you identify the most sensible next step.