Strategy tester using EA on Daily bars - always "market closed"

 

Greets,

I've been trying my hand at writing MQL5 EAs for a while now and everything works as expected.  I've always used the strategy tester on intra-day timeframes, but recently decided to give the Daily TF a try.

Problem is the strategy tester always fails to place any test trades because the trades are placed at midnight, eg, 2023.02.15 00:00:00 - when the market is closed of course.

Forgive me if there's an obvious solution to this (short of hand-coding the EA to detect if Daily bars are being used and adjust accordingly). Surely there's an elegant solution to this?

Thanks

The Fundamentals of Testing in MetaTrader 5
The Fundamentals of Testing in MetaTrader 5
  • www.mql5.com
What are the differences between the three modes of testing in MetaTrader 5, and what should be particularly looked for? How does the testing of an EA, trading simultaneously on multiple instruments, take place? When and how are the indicator values calculated during testing, and how are the events handled? How to synchronize the bars from different instruments during testing in an "open prices only" mode? This article aims to provide answers to these and many other questions.
 
Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 
HenZen: I've been trying my hand at writing MQL5 EAs for a while now and everything works as expected.  I've always used the strategy tester on intra-day timeframes, but recently decided to give the Daily TF a try. Problem is the strategy tester always fails to place any test trades because the trades are placed at midnight, eg, 2023.02.15 00:00:00 - when the market is closed of course. Forgive me if there's an obvious solution to this (short of hand-coding the EA to detect if Daily bars are being used and adjust accordingly). Surely there's an elegant solution to this?


Yes, there is an obvious solution — place the trade when the market is open!

In other words, your EA code, must wait for the opening time (e.g. 00:05 or whatever the session start time may be).

That also means, that you will not be able to test with the modelling method using "Open prices only" on a daily time-frame. You will need to use the "1 minute OHLC" or one of the "Every tick" methods.

 

Another indirect method, is to change the contract specifications in the tester and remove any session time limits so that the market is always open.

However, this is not a realistic emulation of what will happen on a live account, so I don't recommend it. Use it only for quick evaluations.

 
Fernando Carreiro #:

Another indirect method, is to change the contract specifications in the tester and remove any session time limits so that the market is always open.

However, this is not a realistic emulation of what will happen on a live account, so I don't recommend it. Use it only for quick evaluations.

Thanks Fernando, this was the quickest. As you say, just for quick evaluations.