Special trade history exporters for MetaTrader and Tradestation

Author: Mark Fric

January 30th, 2016

Rating:
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Special trade exporters for MetaTrader and Tradestation were added in version 4.10.

They have two advantages:

  • they allow for “automatic” export of trades to a predefined CSV data file, without the need of saving report file manually
  • MAE (max open loss) and MFE (max open profit) is recorded for every trade. This is possible only for reports loaded this way and it will display MAE/MFE on the equity chart.

How to install custom trade exporters:

For Tradestation

  1. Import file SQEXPORTTRADES.ELD into Tradestation using File -> Import/Export EasyLanguage -> Import EasyLanguage File (ELD). The file is located in /loaders folder in QA installation.
  2. then add command: Value90 = SQExportTrades(“C:Your_File_Name.csv”, 10) to the very end of your strategy.

The trading results will be then exported to the file C:Your_File_Name.csv.

This function has two parameters:
– file name including full path
– ATR period – ATR period that will be recorded whenthe trade is opened. It could be later used to compute for example volatility when the trade was opened. You can set 1 if you don’t want to use it.

For MetaTrader

  1. Copy the file SQLogTrades.mqh into your MQL4Include folder – you can find the folder in MetaTrader4 in File -> Open Data Folder. The file is located in /loaders folder in QA installation.
  2. In your EA you have to do four things:
    1. include SQLogTrader.mqh file into your EA using #include<SQLogTrades.mqh
    2. add command sqInitLog(“Your_File_Name.csv”, 0, 10); to OnInit() / init() function.
      If this function doesn’t exist in your EA you have to create it.
    3. add command sqCloseLog(); to onDeinit() / deinit() function.
      If this function doesn’t exist in your EA you have to create it.
    4. add command sqLogTrades(); to the very beginning of OnTick() / start() function.

The trading results will be then exported to the file /tester/files/Your_File_Name.csv.
You can get to the tester folder using MetaTrader4 in File -> Open Data Folder

This function has three parameters:
– file name including full path
– magic number – if not 0 it will record only trades with given magic number
– ATR period – ATR period that will be recorded whenthe trade is opened. It could be later used to compute for example
volatility when the trade was opened. You can set 1 if you don’t want to use it.

Example – old MQL code style:


#include<SQLogTrades.mqh>

int init() {
sqInitLog(“My_EA_Results.csv”, 0, 10);

return(INIT_SUCCEEDED);
}

void deinit(const int reason) {
sqCloseLog();

}

void start() {
sqLogTrades();


}

Example – new MQL code style


#include<SQLogTrades.mqh>

int OnInit() {
sqInitLog(“My_EA_Results.csv”, 0, 10);

return(INIT_SUCCEEDED);
}

void OnDeinit(const int reason) {
sqCloseLog();

}

void OnTick() {
sqLogTrades();


}

< Previous: Analyzing reportsNext: Portfolio correlation explained >

1 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Daniel
Daniel
2 years ago

Hi,
I would need an information. I should use your software to access multiple mt4 accounts opened and started on the same virtual machine simultaneously. All data (the detailed reports of the trade of the individual mt4 accounts) then exported to a MySQL database.
Is your software suitable for this operation?

Regards