Over the past couple of years I've gotten a lot of help from the forex community. I've taken a lot of mt4 code from the net that's been really helpful for me and I'd like to give a little back. I've written a handy library for outputting trade data during backtesting or live trading. The Tradestats library is easy to implement and outputs various trade data in tabular format (csv file) that's readable in any spreadsheet program. Output values include:
order type
order ticket
lot size
direction of trade
open/close price
open/close time
initial stoploss/takeprofit
%risk of equity per trade
day opened
close reason
pip profit
dollar profit
MAE (Maximum Adverse Excursion)
MFE (Maximum Favorable Excursion)
MAE time
MFE time
Duration of trade (still buggy)
Additional output is completely customizable as well. With a little editing of the mq4 file, you can output any indicator data you can imagine. Currently you can output up to 41 indicator values for every trade.
Tradestats also has the capability to send email notifications when trading live (granted you've setup mt4 correctly). Tradestats will send mail whenever an order is opened or closed and include a few stats as well (which stats it sends is still being worked out).
The mq4 file should be placed in the experts/libraries folder and the mqh file should be placed in experts/include. Once you have both files, take a look inside using metaeditor. The files are documented thoroughly and should explain everything you need to do in order to get it up and running. You only need to insert 4 lines of code in your EA for Tradestats to work. Its very simple to implement.
There are a few things you should know before using Tradestats. The handling of pending orders is a little tricky. When a pending order is set all values are final and are not changed when the order is actually executed. I'm debating whether to have Tradestats update the values when pending orders are actually executed. Also, pending orders that are not executed are not written to the output file. ONLY EXECUTED ORDERS ARE OUTPUTTED. In the future, a switch can be added to turn on the ability to output pending orders as well, but currently it does not exist.
Also, for every customized output variable that is not set, there will be a column of zero's in the output file. This is easily removable with a spreadsheet program though.
Tradestats is geared towards analyzing entries. Its analysis for exits and position sizing are limited in comparision. If you have a system developed and need help optimizing it, let me know. I'm always looking for successful systems
The mq4 and mqh files are included in the reply below. I've also included a sample csv file so you can see what the output looks like.
order type
order ticket
lot size
direction of trade
open/close price
open/close time
initial stoploss/takeprofit
%risk of equity per trade
day opened
close reason
pip profit
dollar profit
MAE (Maximum Adverse Excursion)
MFE (Maximum Favorable Excursion)
MAE time
MFE time
Duration of trade (still buggy)
Additional output is completely customizable as well. With a little editing of the mq4 file, you can output any indicator data you can imagine. Currently you can output up to 41 indicator values for every trade.
Tradestats also has the capability to send email notifications when trading live (granted you've setup mt4 correctly). Tradestats will send mail whenever an order is opened or closed and include a few stats as well (which stats it sends is still being worked out).
The mq4 file should be placed in the experts/libraries folder and the mqh file should be placed in experts/include. Once you have both files, take a look inside using metaeditor. The files are documented thoroughly and should explain everything you need to do in order to get it up and running. You only need to insert 4 lines of code in your EA for Tradestats to work. Its very simple to implement.
There are a few things you should know before using Tradestats. The handling of pending orders is a little tricky. When a pending order is set all values are final and are not changed when the order is actually executed. I'm debating whether to have Tradestats update the values when pending orders are actually executed. Also, pending orders that are not executed are not written to the output file. ONLY EXECUTED ORDERS ARE OUTPUTTED. In the future, a switch can be added to turn on the ability to output pending orders as well, but currently it does not exist.
Also, for every customized output variable that is not set, there will be a column of zero's in the output file. This is easily removable with a spreadsheet program though.
Tradestats is geared towards analyzing entries. Its analysis for exits and position sizing are limited in comparision. If you have a system developed and need help optimizing it, let me know. I'm always looking for successful systems
The mq4 and mqh files are included in the reply below. I've also included a sample csv file so you can see what the output looks like.