MetaTrader Data Export
readme.txt
v1.0.0.0
2021-08-28
Copyright © 2021 Heinz Traub
www.tripleheinz.com

[INTRODUCTION]

MetaTrader Data Export.
A two-component (Expert Advisor + DLL) solution for exporting tick and current period data for the current symbol.

By default it includes a DLL that exports data to CSV files but also includes source files to create your own replacement DLL
to do whatever you want with the data such as copying it to another memory block, sending a signal to an Arduino to turn on
a led if a price reaches a threshold (just a silly idea for example) or integrating it to other services (realtime or offline).

[INSTALLATION]

Binaries are provided for the 32-bit and 64-bit versions of MetaTrader. They are in the "x86" and "x64" folders respectively.
File hashes can be found in the "changelog.txt" file included in this release package. Check them for security protocols.
1) Copy the "MTDE.ex5" file to the corresponding Expert Advisors folder and copy the "mtde.dll" file to the same folder as well.
2) The included DLL requires that you create the folder "C:\MTDE" to export the CSV files, otherwise the EA will fail.
3) Enable DLL imports for Expert Advisors in MT terminal: Go to Options (Ctrl + O), "Expert Advisors" tab then enable/check the
"Allow DLL imports" checkbox and hit the "OK" button to save the changes. Restart the terminal for changes to take effect.

[COMPILATION]

A template DLL source code is included for the C language. A DLL can be created in many languages but I leave that to you.
Source files are in the "src" subfolder included in this release package.
To compile the DLL file you need to install "mingw-w64" (32 and/or 64-bit versions, whichever one you need) and edit the
batch file "Build_MTDE.bat" (included right there, in the "src" folder of this project) and set the PATH variable in there
to point to the compiler's "bin" location, such as for example: "SET PATH=%PATH%;C:\mingw64\bin". And then finally run the
"Build_MTDE.bat" file you just edited.
If you set everything up correctly then the output DLL will compile to the same "src" folder.

[USAGE]

Open the MetaTrader terminal. You can export data 1) on demand or 2) live stream it.

1) To export a range of data offline then go to the "Strategy Tester" panel, in the "Settings tab" select "MTDE.ex5" from the list of available EAs,
choose your symbol and period to export, select a predefined date or a custom range, in the "Inputs" tab check the input variables and
leave everything by default except for the first two: Enable "in_export_tick_data" if you want to export tick data (note that it is
disabled by default because it can write massive amounts of data in a short period of time) and also enable "in_export_bar_data"
if you want to export bar data (it can write small amounts of data even in a long period of time, enabled by default). Make sure
at least one of these two input variables are enabled or the EA will fail because there is no work to do. Finally hit the "Start"
button to run the test and let the EA to perform its magic until it finish the test.
Switch to the "Journal" tab in the "Strategy Tester" panel to read any message thrown by the EA, do not ignore the warnings!

2) To export live data in realtime then browse the "Navigator" panel and find the "MTDE" node in the parent "Expert Advisors" node, then simply
drag the MTDE node to the live chart you wish to export data from. In the window that appears, in the "Inputs" tab apply the same rules
as described in the previous paragraph (focus only on "in_export_tick_data" and "in_export_bar_data"), in the "Dependencies" tab make sure
the "Allow DLL imports" checkbox is enabled/checked. Finally hit the "OK" button and let the EA to perform its magic while you continue to
use the terminal.
You are allowed to change the chart's time frame while the EA is running, MTDE will handle the switch and will run a new instance but
it is not a good idea to interrupt the export process by doing so. When you live stream data, if you stop the process for a while
and then start it again or if you change the chart's time frame and then after a while you roll back to the previous time frame then
there will be a void in your exported data and there is no way to fill in those blanks. Live streaming should be done in a single session
until you get the desired data from start to end.
Switch to the "Experts" tab in the "Toolbox" panel to read any message thrown by the EA, do not ignore the warnings!

In both cases, by using the included DLL, the data will be exported in the "C:\MTDE" folder. CSV files will be created based on the selected
symbol and period for bar data but for tick data, files will be created based on the selected symbol only. Running the EA multiple times
for the same configuration will pick up the same file and append data to it. Keep this in mind because if you do this then
there will be voids in your exported data because of the time differences between runs and there is no way to fill in those blanks.
If you want to start a fresh session then simply move the old files to another folder so that new ones will be created on the next run.
Please try to understand how the data export process works and avoid compromising your export database integrity.
Always validate your data with what is shown in the terminal and, again, do not ignore the warnings!

[WILD NOTES]

- Created for and tested with the latest version of MetaTrader 5 as of now (Version 5.00 build 3030, 27 Aug 2021).
- This project is in a modest state (it is a foundation to a DDE server). Nonetheless, it can be used to export tick and bar data.
- Does this project supersedes "MetaTrader History Toolkit"? While both are different projects, MTHT is now obsolete and MTDE can be tweaked to obtain the same final results.
- I know that data can be exported to a text file directly from the MT terminal by using the integrated file functions but this project was setup with the idea of exporting data via DLL for doing something else with it.
- I endure a custom license (license.txt) as a long time developer practice. In short, what you want to read from this license is that you are free to modify the template DLL code to suit your needs and that you can integrate this project however you want for personal or commercial projects, but do not directly sell it nor claim it as yours. No credit/attribution notice is asked (althought it is much appreciated if you do).
- This project uses all the features and tools provided by the platform (MT) itself to allow the export of data, but it will never provide you with copyrighted tick/rates data files pre-exported in the release package. Whatever you do with the data from your own trading account is your legal responsability with the copyright holder (usually the broker or MetaQuotes themselves, depending if you are on a demo account or a live account).



MetaTrader is Copyright © 2000-2021, MetaQuotes Ltd