2

I'm using the TesterStatistics() function (called from the OnDeinit() function) to export various strategy-testing statistical values:

void OnDeinit(const int /*reason*/)
{
  int h = FileOpen("results.txt", FILE_WRITE|FILE_UNICODE|FILE_TXT|FILE_COMMON);

  if (h != INVALID_HANDLE)
  {
    FileWrite(h, TesterStatistics(STAT_PROFIT));
    FileWrite(h, TesterStatistics(STAT_SHORT_TRADES));
    FileWrite(h, TesterStatistics(STAT_LONG_TRADES));
    FileWrite(h, TesterStatistics(STAT_BALANCE_DD));
    FileWrite(h, TesterStatistics(STAT_BALANCE_DDREL_PERCENT));
    FileClose(h);
  }
}

This works but seems limited to simple back-testing.

How can I export both the back-testing and forward-testing results?


Results of the forward test are displayed on the separate tab "Forward". The start date of the forward period is marked by a vertical line on the chart:

Results of the forward test

Can I access these information programmatically?

manlio
  • 18,345
  • 14
  • 76
  • 126

1 Answers1

2

You are right in the point, MetaTrader 5 Terminal does not recognise ( and frankly speaking, no one else could either ) a difference between a doing a real-trading and doing the very same things, but just as a forward-testing.

Yet, there is a way to collect statistics

We use this in another context either, when our backtesting is not actually using the StrategyTester built in tools ( we found some strange accounting issues ( when non-major Deposit Currency was not correctly involved into S/T records in the flow of time ).

We wrote our own ReportResults() and call it from the OnDeinit() handler.

This works like a charm.

halfer
  • 19,824
  • 17
  • 99
  • 186
user3666197
  • 1
  • 6
  • 50
  • 92
  • 1
    MT5 calculates these information (see my edit)... I was hoping for a way to get at them programmatically. Unfortunately it seems there isn't and I have to perform multiple back-tests or write my own function as you suggest... PS Yes, a very interesting place and a fascinating research area! – manlio Oct 29 '17 at 10:25