Very strange Strategy Tester results... expert opinion needed!

 

After several years using MT4 and, after having created/updated/tested hundreds of EAs, indicators & scripts, I thought I knew MT4 pretty well... until today!

I’ve been running some M1 back-tests on a grid-trading EA and can’t understand why the results are varying so significantly, so I’m now admitting defeat and wondering if anyone here can shed some light on the issue?

I originally edited the code so that it only processes things once per M1 bar.

That version of the EA produced 100% identical (and quite acceptable) results, regardless of whether I used the “Open prices only”, “Control points” or “Every tick” modeling option.

I then changed the code slightly, so that new positions would only be considered at the start of each new M1 bar, but trade exit management would occur “every tick”.

I figured that price wasn't going to move much within any single M1 bar and the opening price of each bar would correspond to the "Open prices only" model anyway so, at worst, there would be no differences and, at best, trades might close up to 59 seconds sooner as the high-low range of each bar would be considered, not just the opening price.

The EA includes a "per tick" floating loss display which I assumed would be slightly different due to the potentially earlier trade close-outs but, to my surprise, the floating loss actually increased by over 400%!

I've looked at this from every angle I can think of and I've now got bored with pulling my hair out in frustration so I’m hoping someone can help identify the cause and put me out of my misery.

Neo

 

...

Maybe this helps a bit ...

The chart shows a "simulated ticks" that metatrader is producing during back test. It s not even a single tick chart but, to make it a bit easier to read it, a 2 ticks per bar chart. As you can see, the chart that is produced is not what one would normally expect (gaps can be quite significant and in a lot of cases are far, far away from a real price changes) and that might be the cause of your back test results.

PS: price used in this chart is a close. Simulated bid and ask, due to some problems if you try to record then to offline chart from a back test, are not used in this example (but they even do not matter due to the lack of historical spread, which makes back test bid virtually same as close and ask is equal to that close + current spread)

Neo:
After several years using MT4 and, after having created/updated/tested hundreds of EAs, indicators & scripts, I thought I knew MT4 pretty well... until today!

I’ve been running some M1 back-tests on a grid-trading EA and can’t understand why the results are varying so significantly, so I’m now admitting defeat and wondering if anyone here can shed some light on the issue?

I originally edited the code so that it only processes things once per M1 bar.

That version of the EA produced 100% identical (and quite acceptable) results, regardless of whether I used the “Open prices only”, “Control points” or “Every tick” modeling option.

I then changed the code slightly, so that new positions would only be considered at the start of each new M1 bar, but trade exit management would occur “every tick”.

I figured that price wasn't going to move much within any single M1 bar and the opening price of each bar would correspond to the "Open prices only" model anyway so, at worst, there would be no differences and, at best, trades might close up to 59 seconds sooner as the high-low range of each bar would be considered, not just the opening price.

The EA includes a "per tick" floating loss display which I assumed would be slightly different due to the potentially earlier trade close-outs but, to my surprise, the floating loss actually increased by over 400%!

I've looked at this from every angle I can think of and I've now got bored with pulling my hair out in frustration so I’m hoping someone can help identify the cause and put me out of my misery.

Neo
Files:
back_test.gif  16 kb
 

Thanks for the info but, as is often the case, the issue was actually down to code blindness (politically correct alternative to admittiing fault) :-D

Having walked away for an hour, I spotted a line of code that was bypassing the "once per bar" limitation.

Back to back-testing, I guess :-)

Neo

 

Check my post here

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

I developed many scalpers but when the time came to trade them live , I gave up because MT4 and the brokers who use it wont allow you to scalp by manipulating the add on from their server side.

IMHO If you are going down to a tick level and 1M bar then you better look for something other than MT4

Reason: