StrategyQuant Products Documentation and Knowledge Base

Special trade history exporters for MetaTrader and Tradestation

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 \MQL4\Include 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();

...
}

Attached Files
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Name
Email
Security Code Security Code
MENU
Products

StrategyQuant
Quant Analyzer
EA Wizard
TickDataDownloader
Company

Home
About us
Support

Documentation & KB
Forum
Contact us
Partnership

Partner with us
Affiliate program
Stay in touch

Newsletter
Facebook

Copyright © StrategyQuant.com 2012 - 2017, All rights reserved.
Terms of service     Privacy policy