ERROR wrong timeframe request in Open Prices testing mode

 

Dear developers!

I continue to get the error "wrong timeframe request in Open Prices testing mode". All the testing is provided in "Open prices only" mode EXCLUSIVELY on M1 timeframe. I actually test the EA, in which timeframe of the loaded custom indicator is set as an input parameter. Because I use M1 as main timeframe, I expect to be able to load indicators from all other timeframes (according to this https://www.mql5.com/en/forum/6494 ), and that goes smoothly with all my other indicators. However, I get this error even when the indicator timeframe is set to M1.

Moreover, the error condition is unstable, e.g. sometimes I get it and sometimes not. For example. I start the slow optimisation and about half of the passes return this error, while others do not. When I run the same optimisation with same inputs ranges without recompiling any EAs or indicators, I get other confings, which return error (and sometimes all the testing goes smoothly). When I try to make a single run of a config. which returned the error, it sometimes goes smoothly too. Usually, the restart of the terminal changes the situation.

I pin the code of the indicator, which causes the error (line 60 mainly). 

Step on New Rails: Custom Indicators in MQL5
Step on New Rails: Custom Indicators in MQL5
  • 2009.11.23
  • Андрей
  • www.mql5.com
I will not list all of the new possibilities and features of the new terminal and language. They are numerous, and some novelties are worth the discussion in a separate article. Also there is no code here, written with object-oriented programming, it is a too serous topic to be simply mentioned in a context as additional advantages for developers. In this article we will consider the indicators, their structure, drawing, types and their programming details, as compared to MQL4. I hope that this article will be useful both for beginners and experienced developers, maybe some of them will find something new.
Files:
IndexUSD.mq5  3 kb
journal.PNG  25 kb
journal_2.PNG  17 kb
 
Can you provide a sample EA which helps to reproduce the problem ?
 
The error occurs or doesn't ocuur randomly, as I see it.
Files:
TEST.mq5  2 kb
No1.PNG  16 kb
No1_journal.PNG  30 kb
No2.PNG  16 kb
No2_journal.PNG  35 kb
SingleRun.PNG  38 kb
IndexCHF.mq5  3 kb
IndexUSD.mq5  3 kb
 
c1664:
The error occurs or doesn't ocuur randomly, as I see it.

I don't have any problem. Are all the symbols used by your IndexXXX indicators selected in Market Watch ?

I run it with Metaquotes-demo server.

 

OK, let's make it even more simple - down to single function.

EURUSD is selected in MarketWatch. I run it on USDCHF, M1, Normal, Open prices only.

Documentation on MQL5: Standard Constants, Enumerations and Structures / Indicator Constants / Price Constants
Documentation on MQL5: Standard Constants, Enumerations and Structures / Indicator Constants / Price Constants
  • www.mql5.com
Standard Constants, Enumerations and Structures / Indicator Constants / Price Constants - Documentation on MQL5
Files:
TEST.mq5  1 kb
20131201.log  24 kb
 

Tested it in 3 different terminals with the same result.

There is evidently a bug in functions for copying rates from other symbols in "Open prices only" mode. 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Indicator Constants / Price Constants
Documentation on MQL5: Standard Constants, Enumerations and Structures / Indicator Constants / Price Constants
  • www.mql5.com
Standard Constants, Enumerations and Structures / Indicator Constants / Price Constants - Documentation on MQL5
 
c1664:

Tested it in 3 different terminals with the same result.

There is evidently a bug in functions for copying rates from other symbols in "Open prices only" mode. 

Ok, I got it. The error is only with "Open prices only" mode. Also if I run a "1 minutes OHLC" first, and then "Open prices only" I don't get errors.

I don't know about your original code, but the code you posted here don't have error processing, I strongly suggest you to include error processing everywhere. For example with this code :

   if(CopyOpen("EURUSD",Inp_timeframe,0,1,buffer_1)!=1)
      Print("CopyOpen Error : ",_LastError);

I got error 4401 which is "Requested history not found", each time you see "wrong timeframe request..." in the Strategy Tester logs.

Anyway, that seems weird to have this error with the Strategy Tester, if your wrote to ServiceDesk to report this, please let us know their answer.

 

I have this same error appear..... and I have resolved it by switching as you indicated......


I can send to the service desk a letter, however, I di not write the ea that I am using so I am unable to add any code to it.

 
Hey there,

i have the same problem with "error wrong timeframe in open prices testing mode"

Alain Verleyen:

Ok, I got it. The error is only with "Open prices only" mode. Also if I run a "1 minutes OHLC" first, and then "Open prices only" I don't get errors.

I don't know about your original code, but the code you posted here don't have error processing, I strongly suggest you to include error processing everywhere. For example with this code :

I got error 4401 which is "Requested history not found", each time you see "wrong timeframe request..." in the Strategy Tester logs.

Anyway, that seems weird to have this error with the Strategy Tester, if your wrote to ServiceDesk to report this, please let us know their answer.

 Dear Alan. Can you tell me, where i have to implement this error request? I think it should be in the onInit function beacause the history is only loaded at the beginning of the tester.
 

"Open Prices Only"

...
In the tested Expert Advisor, you cannot access data of the timeframe lower than that used for testing/optimization. For example, if you run testing/optimization on the H1 period, you can access data of H2, H3, H4 etc., but not M30, M20, M10 etc. In addition, the higher timeframes that are accessed must be multiple of the testing timeframe. For example, if you run testing in M20, you cannot access data of M30, but it is possible to access H1. These limitations are connected with the impossibility to obtain data of lower or non-multiple timeframes out of the bars generated during testing/optimization.

Documentation on MQL5: MQL5 programs / Testing Trading Strategies
Documentation on MQL5: MQL5 programs / Testing Trading Strategies
  • www.mql5.com
Testing Trading Strategies - MQL5 programs - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Thank you very much. I appreciate your efforts here in the forum. One day i am ready to give it back
Reason: