Accesing to order history in backtest

 

Hi all!

This has been my first week with MQL4, so I can be considered as a very big newbie ;-) Otherwise, I'm a Java Developer so programming MQL4 isn't being too difficult.


I have a big doubt about a question that I've already found in forum, but with no responses: https://forum.mql4.com/29916 :-(

I'm developing an antimartingale MM function that is inspired on Ralph's Vince's F value. To calculate it I need access to the complete order history of an EA.


I have used OrderSelect(i,SELECT_BY_POS,MODE_HISTORY) successfully.


But... when I try backtesting, I see that OrderSelect always returns me the results of the CURRENT CLOSED orders from my account, skipping all simulated results.


Does somebody know a way to get this info on backtest time?


Thanks in advance, and best regards from Spain!!!


PS: Sorry because of my English :-/

 

Hi,

Try to look at the article "Testing Features and Limits in MetaTrader 4"

Best regards from Russia

 

javi_eu wrote >>

I have used OrderSelect(i,SELECT_BY_POS,MODE_HISTORY) successfully.

But... when I try backtesting, I see that OrderSelect always returns me the results of the CURRENT CLOSED orders from my account, skipping all simulated results.

Does somebody know a way to get this info on backtest time?

OrderSelect(...,MODE_HISTORY) should work fine in Tester. It does for me...

That post u mentioned is talking about using an indicator on a Tester visual chart... Are u trying to do that?

 

Hi, thanks for your response... No, no visual chart during backtest...


As I have seen, OrderSelect(i,SELECT_BY_POS,MODE_HISTORY) always returns what you are currently seeing on the "Account history" tab. I mean, if you for instance filter results by last month, you only get access to these operations thru OrderSelect method in API. And I'm truly thinking that this is what you get, no matter you are on simulation or live...


@gordon, during testing, you get info about tested orders, or about current orders?


Thanks!

 

javi_eu wrote >>

@gordon, during testing, you get info about tested orders, or about current orders?

In Live/Demo - OrderSelect(...,MODE_HISTORY) can select from what's in the history tab, which relies on user settings (yeah, it's bad design... but nothing to do about it).

In Tester/Optimization - OrderSelect(...,MODE_HISTORY) can select from ENTIRE history during the test/pass.


I have not seen once any discrepancy with the above... So I don't know what's happening on your side.

 
gordon:

In Live/Demo - OrderSelect(...,MODE_HISTORY) can select from what's in the history tab, which relies on user settings (yeah, it's bad design... but nothing to do about it).

In Tester/Optimization - OrderSelect(...,MODE_HISTORY) can select from ENTIRE history during the test/pass.


I have not seen once any discrepancy with the above... So I don't know what's happening on your side.

javi_eu


While using Strategy Tester over the weekend I've experienced problems with pulling orders from the 'order stack' as well. Gordon was also kind enough to respond to my inquiry. For whatever reason it happens very sporadically and only late on Sundays after the market has re-opened for the upcoming week. In both instances my problems went away after returning to it the next day. I changed no code and ran with the same test dates and setting as on Sunday. Both of the EAs where this occurred used data from multiple timeframes on the same currency pair. To date I have not found an explanation and cannot re-create the problem at will, nor can I suggest a solution. The only other similarity is that I was using an FXDD test account when this problem occurred.


I know this doesn't provide any concrete answers, however, though I'd share what happened.


Don

Reason: