Random Stuff

MetaTrader History ToolKit
My ATC2012 EA
Heinz Engine
Honda Steed Exhaust Mod
3DS Retro Game Gallery 
Frypan-Lamp Biquad Antenna
HTPC 001
Aerospace AL CPU Cooler
PHP Pager
Developer's Notes

MetaTrader History ToolKit

Download | Screenshots | F.A.Q. | Changelog / Archive


MetaTrader History Toolkit is a small set of tools that provides developers and traders with different approaches to DDE servers for accessing history data outside the MetaTrader terminal. These tools work by directly reading history files through the "HCC API", which is an interface for the file structure.

Traders can use the tools just like any other program and perform some filtering before exporting data to CSV format (Microsoft Excel compatible). In the other hand, developers can directly access the HCC API and map history data in system memory, once there, the possibilities are endless.

License: The toolkit is freeware and is intended por personal desktop use only. A license file is included, please read it if you would like to include the toolkit (or the library) along with your programs. I just don't want you to do bad things with the toolkit nor with the output data.

The Tools

HCC API: Not being precisely a software tool, the HCC API is a series of declarations, conventions and specifications created to promote a common interface to work with MetaTrader history files.

HCC Library: The HCC Library is the “first 3rd party” implementation of the HCC API, being the official one considered the private work from MetaQuotes (who created the file format) even if both foundations do not entirely comply between each other. The HCC Library has been conceived as a C DLL, it is fully documented and it has been developed with the D programming language spec 2. It can be used with any language with C ABI compatibility and support for DLL imports. Bindings and examples for popular languages are provided. Although using this API with MQL5 is kind of odd (data is already there in the terminal), bindings will still be provided for advanced arbitrary use (i.e. comparing data from current account with data from another broker). It also features automatic memory management, this means that you do not need to worry about memory allocation and deallocation.

HCC Command Line: Convenient and quick tool for easy exporting HCC files to CSV files.

HCC Explorer: Graphical user interface to view and analyze HCC files. Filtering can be applied before exporting data. Rates can be edited to fix corrupted data.

Other Information

Compatibility: The toolkit only works with MetaTrader 5 history files. Users of MetaTrader 4 can use the History Center (F2) to import/export history data.
The HCC Library is provided with 32 and 64 bits binaries so it can work with both versions of MetaTrader 5, along with your own programs.
All the tools are native applications and do not have extra software requeriments.

Timeframe Computation: It means generation of rates with a period greater than 1 minute. Please note that this feature is still experimental and you might not get the results you'd want. The generated data differs from the data in MetaTrader. It was clear since the beginning that this project was made for working natively with 1 minute history data. For other periods use a DDE Server.
Do not sacrifice precision and integrity. Just stick to M1 period for the time being.

Programming Notes: If you are making your own bindings for an unsupported language please take into consideration that the language must support unsigned integers. Most but not all values returned by the HCC Library fit in the positive range of a signed integer but this can not be guaranteed.
You should also consider the struct alignment which in fact is set to none. Members of a structure in the HCC Library are packed together just like they are in MQL5.

Wishlist for next release:

  • Handle cache files as well (precomputed timeframes).
  • HCC Explorer .NET (version of the explorer that uses the CLR components).
  • Java and VB.NET bindings and examples.
  • Append and insert rates data.
  • Create custom history files from scratch.

Development Notes: The HCC API development is based only by self understanding the HCC format. It takes a lot of time and experimentation to obtain results. The file format is not 100% deciphered and most probably it will never be. The current development version only supports read operations plus inline edit but more complex functions will be considered if possible.

Attributions: Thanks to "Bug Hunter" from "Looking for Bugs?" blog for pointing out the tick structure. I took his research and did further discoveries. All the credits go to him for his awesome discovery.

This project is in no way supported by MetaQuotes nor recognized by any of their products, please do not spam their help desk.

MetaTrader is Copyright 2000-2018, MetaQuotes Software Corp.