MT5 export of history to MyFXBook
From Shmuma
Excellent MyFXBook service currently doesn't support MetaTrader5 platform. But there is a workaround.
Contents |
Software
Here you can grab archive with the following stuff: MFB_Publish.zip
- mfb_lib.ex5 — core export routines, copy into MQL5/Libraries of MT5 installation;
- mfb_lib.mq5 — it's sources;
- mfb_lib.mqh — library header file, required only for rebuild from source;
- mfb_publisher.ex5 — publishing expert which generates the report and uploads it into myfxbook ftp server. Copy into MQL5/Experts;
- mfb_publisher.mq5 — it's sources;
- mfb_send.ex5 — script for manual report upload. Copy into MQL5/Scripts (not required).
Setup
When all ex5 files have copied into proper places, you need to make FTP publishing settings according to MyFXBook instructions: http://www.myfxbook.com/help/connect-metatrader-publisher
The single difference is that FTP publisher interval doesn't matter, expert has it's own interval setting (and it could be less than 5 minutes).
MyFXBook account creation is the same as usual. Platform should be MetaTrader4.
Usage
After set up, there are two usage scenarios:
- manually launch script mfb_send.ex5. It will generate report and upload it into MyFXBook ftp server you specified. After some time (usually two or three minutes), report will be parsed and account information will be updated.
- attach expert mfb_publisher.ex5 on any chart. Expert will do the same as a script, but without user intervention and with specified interval of minutes. It doesn't matter on which quote to attach the expert, it will upload all history on all currency pairs.
Algorithm
The main idea is simple — we generate report in the same format as MT4 does from MT5 history data. But due to internal MT5 changes, there is no 1-to-1 mapping from new information into old-style orders list. So, I used the following method:
- build a set of position IDs from history;
- for each position, make list of deals sorted by time;
- for each 'out' (close) or 'out/in' (reversal) deal find total profit for previous 'in' positions.
In fact, it won't guarantee 100% adequate list. Fo rexample, if there was solme position for a long time, and after that it was increased in volume for short period of time, there may be invalid swap distribution among these orders. But in most cases, the result is adequate. At least till MyFXBook developers invent something better :).
Feedback
If you have a bug, a patch, suggestion or a good words about this small software piece, you could contact me via max.lapan <at> gmail.com.
If you found the situation when generated report is not adequate, please send both generated report (statement.htm file from MQL5/Files directory) and original MT5 report to have information for bugfix.