Skip to content
All library documents

MQL4-to-MQL5 Migration: Timeframes, Data, and API Replacements

Article MQL5 articles

Summary

This guide is a practical reference for porting MQL4 programs to MQL5. It maps legacy timeframe values to MQL5 timeframe constants, including the additional periods available in the newer platform, and explains that timeframe constants cannot always be treated as a bar’s number of minutes. It also lists compatibility constants that may need declarations and gives replacements for common predefined market data, account information, and chart functions.

Examples show how to retrieve bid and ask through tick data, copy price and time series into arrays, and query account values through the MQL5 information functions. The guide’s purpose is quick identification of analogous interfaces, not automatic conversion of a complete trading system. It explicitly excludes trading functions because MQL5 uses a different trading model and says that converting them requires changes to trading logic. The material is a broad reference table rather than a tested migration procedure, so individual replacements and behavior still need to be checked against the target program.

Key ideas

  • MQL5 timeframe constants differ numerically from many MQL4 values, so legacy periods need explicit mapping.
  • MQL5 obtains bar series through copy functions and current quotes through tick information.
  • Account and chart queries often use dedicated information and chart functions in place of MQL4 calls.
  • Missing legacy constants can be declared to ease compatibility work.
  • Trading functions need a redesign around MQL5’s trading model rather than a direct name-for-name conversion.

Tags

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