Custom Back Testing - page 2

 
wuut:

I want to adapt (c++) the backtesting function of mt4 in order to make faster back tests.

I mean functions like "control of the stoploss or tradeprofit". Also the function for closing orders and calculate the profit correctly.


1A) Don't optimize multiple parameters, optimize each one at a time with a large step size, then repeat the group with a smaller step size with limits near the original value.


1B) Optimize the code. Don't do any unnecessary stuff:

bool Show=true;
init() {
  if ( IsTesting() && !IsVisualMode() ) Show = false;
}
start() {
  //...
  if (Show) {
     Comment(...);
     ObjectMove(...);
     //...
  }

2) functions like "control of the stoploss or tradeprofit" are done in YOUR EA, nothing to do with the tester. Why do you think profits are calculated incorrectly?

 
wuut wrote >>

I think i can understand your point of view.

But i am trying to optimize an EA that works on a short term using kind of genetic algorithms. It doesnt matter whether i makes sense or not.

I just want to get rid of the MT4 backtester and make my own way, faster...

Replacing the MT4 optimizer is relatively easy. The way I do it is to set-up my own independent loop variables which I non-genetic "optimize" using the MT4 platform. Then within the EA I check to see if my own customized optimization is running (a set of extern bools control various aspects of it) and then I tune my parameters within the customized optimization code that lives right inside the EA. My Init and DeInit functions are huge and make use of a lot of global variables (GlobalVariableSet, GlobalVariableGet, etc.) to save values and control things between the cycles.

In effect I've used the EA itself and the core MT4 optimization platform to write my own optimization within the EA. No linkages to the MT4 platform are required.

 

Sometimes I need to optimize a multi-pair system outside MetaTrader 4, because you can not test a multi-pair expert advisor in MetaTrader 4.

I export tick data from MetaTrader using an expert advisor as you can see in (http://www.brokenpatterns.com/articles/mql4-export.html).

Then, I program the system in C or Java using the exported data.

Now, with MQL5 you can test a multi-pair system directly from Strategy Tester.