Skip to content
All library documents

Exchanging MetaTrader 4 and MATLAB Data Through CSV Files

Article MQL5 articles

Summary

The article presents a file-based method for passing bar data between MetaTrader 4 and MATLAB. An MT4 indicator writes recent OHLCV bars to a semicolon-separated file when a new bar arrives. MATLAB monitors the file’s modification time, reads and processes updated data, then writes results to a separate file. The terminal polls for that response and can display returned values on a chart. The guide also sketches a MATLAB interface for choosing the input file, viewing candlesticks and starting processing.

The file handoff uses deletion and recreation of the results file to signal that computation has completed, with repeated read attempts on the terminal side. This offers a straightforward bridge for users of both programs without requiring specialized integration tools, but it is not presented as unique or optimal. File timing, concurrent access and polling can affect reliability or latency, and the article gives no measurements of either. It explains data exchange and visualization rather than a trading strategy or evidence of predictive value.

Key ideas

  • An MT4 indicator can export recent bar fields to a delimited text file when a new bar forms.
  • MATLAB can monitor file updates, process the data and return results through a second file.
  • Deleting and recreating the response file serves as a basic completion signal.
  • A MATLAB GUI can support file selection, chart display and manual processing.
  • The approach is simple but has no reported latency or reliability measurements and is not described as optimal.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.