Custom Back Testing

 

hi there,


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.


Does anybody know where to start?


thanks in advance

 
i doubt you can insert such function easly into mt4 terminal. what you can do is to write own mql interpreter but mql is not little language you can re-write everything.
 

i dont know what your code is, but some of my EA's are really do a lot of stuff

string-operations slow it down a lot, so i simply dont use it in optimisation or testing, or only each hour

i have no problems with my dual core,7 years in 60 minutes, tick based

its better to optimize the code....

 
meikel:

i dont know what your code is, but some of my EA's are really do a lot of stuff

string-operations slow it down a lot, so i simply dont use it in optimisation or testing, or only each hour

i have no problems with my dual core,7 years in 60 minutes, tick based

its better to optimize the code....

I think there is a misunderstanding.


I want to rewrite the backtesting function of mt4 in C++.

the new function should use exported tick data from MT4.

Since C++ is faster, i can do more back test.

Thats the point.

Any suggestions?

 

oh, i have understand your statement.

but why do you think, that C++ is faster ?

can you tell me, what language/compiler is used for compiling MQ4 code ?

at the moment i think, that the whole MT4 is written in C and the compiler compile to C code - but maybe i am wrong..

curious listening ....

 
Yeah it is based on C. If you wanna do that as meikel said you have to rewrite everything from the beginning. Like how would you get the values of indicators etc...
 

Look, in fact i can't really tell what is faster, since i don't know how the backtesting functions of MT4 are working.

I've wrote a similar backtesting function in C++ and back testing my code seems to be faster.

But thats not the point. I just want to know how exactly the backtesting function of mt4 is calculating things like TP, SL and Profit.

With this knowlege i could build my own backtesting program.

I've got another topic on this forum but in a different way of view. But it describes in the end the same problem.

Maybe it can describe the problem better:

https://www.mql5.com/en/forum/121982

 
Itachi:
Yeah it is based on C. If you wanna do that as meikel said you have to rewrite everything from the beginning. Like how would you get the values of indicators etc...

I dont need to do that, since i can export that values from mt4. and read them aout with my program.

 
wuut:

I want to rewrite the backtesting function of mt4 in C++.

the new function should use exported tick data from MT4.

Since C++ is faster, i can do more back test.

Thats the point.

Any suggestions?

My very personal suggestion is: don't do it.


About 18 months ago I did an exercise for a client optimising a strategy by examining about 10,000,000 variants over 5 years of historic data. Running in parallel on a machine with 16 physical cores and tons of RAM. The code maxed out the northbridge long before exhausting the processors, but that's not the point...


Of the 10,000,000 strategy variants which the system analyzed, about 1,000,000 were seriously profitable over the 5 years of data. However, every single variant was nonsense. All the system achieved was curve-fitting on a massive scale. The more variants of a strategy which you backtest, the less likely your results are to be meaningful - unless you're doing the exercise in order to inspect something like the median performance, rather than the "best parameter combination".


Modern technology makes it easy to find strategies which have worked well historically. The speed of MT4's backtesting isn't a problem, because finding historically profitable strategies isn't a problem...

 
jjc:

My very personal suggestion is: don't do it.


About 18 months ago I did an exercise for a client optimising a strategy by examining about 10,000,000 variants over 5 years of historic data. Running in parallel on a machine with 16 physical cores and tons of RAM. The code maxed out the northbridge long before exhausting the processors, but that's not the point...


Of the 10,000,000 strategy variants which the system analyzed, about 1,000,000 were seriously profitable over the 5 years of data. However, every single variant was nonsense. All the system achieved was curve-fitting on a massive scale. The more variants of a strategy which you backtest, the less likely your results are to be meaningful - unless you're doing the exercise in order to inspect something like the median performance, rather than the "best parameter combination".


Modern technology makes it easy to find strategies which have worked well historically. The speed of MT4's backtesting isn't a problem, because finding historically profitable strategies isn't a problem...

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...

 

How off is the calculation results in your backtester, a few pips per closed order?. Are your results always wrong, or is it just sometimes? Maybe a Bid versus Ask problem in your code?

I think you could figure out how the mt4 backtester does a calculation if you looked at the difference with yours.

Or give an example of a SINGLE closed order that is wrong paired with the mt4 result.

Reason: