Questions from a "dummy" - page 188

 
Karlson:
I haven't tried it yet, but I understand the idea of putting it together in one file, so maybe the developers can point out an option - howto connect unchanged data from a folder.
And you go straight to the CD with this suggestion: connect immutable data from a folder.
 

Good afternoon!

Here's a function I've written. It calculates the ratio of the current exchange rate to the rate at the beginning of 2010.

double CalcKorr()
{
   double Bid = SymbolInfoDouble(_Symbol,SYMBOL_BID); 

   double OtkrVal[1]; 

   datetime time=D'2010.01.01 00:00:00';

   if (CopyOpen(_Symbol,PERIOD_MN1,time,1,OtkrVal) != 1) return(0);

   return(Bid / OtkrVal[0]);

}

It works correctly if I run a test for 2011 or earlier periods, but returns 0 if I test for 2012 :(

Please advise what may be the problem.

Expert Advisor is running on 10 minutes, I am using server and account from Championship 2012 for testing.

 
MegaVoin:

Good afternoon!

Here's a function I've written. It calculates the ratio of the current exchange rate to the rate at the beginning of 2010.

double CalcKorr()
{
   double Bid = SymbolInfoDouble(_Symbol,SYMBOL_BID); 

   double OtkrVal[1]; 

   datetime time=D'2010.01.01 00:00:00';

   if (CopyOpen(_Symbol,PERIOD_MN1,time,1,OtkrVal) != 1) return(0);

   return(Bid / OtkrVal[0]);

}

It works correctly if I run a test for 2011 or earlier periods, but returns 0 if I test for 2012 :(

Please advise what may be the problem.

Expert Advisor is running on 10 minutes, I am using server and account from Championship 2012 for testing.

Put up a printout of the error - we'll see.
 
Yedelkin:
Yes, I don't know what the logic of the program is, but the period of 10 min is denoted a little differently.

Everything else works on 10 minutes, such as this:

CopyHigh(_Symbol, _Period, 0, 2, MaxVal ) 

Only this function tries to take data from the month.

And how to print the error? I understand that CopyOpen(_Symbol,PERIOD_MN1,time,1,OtkrVal) returns -1 instead of 1.

 
MegaVoin:

And how to print the error? I understand that CopyOpen(_Symbol,PERIOD_MN1,time,1,OtkrVal) returns -1 instead of 1. But why does this happen, can it output an error?

double CalcKorr()
{
   double Bid = SymbolInfoDouble(_Symbol,SYMBOL_BID); 
   double OtkrVal[1]; 
   datetime time=D'2010.01.01 00:00:00';
   ResetLastError();
   if (CopyOpen(_Symbol,PERIOD_MN1,time,1,OtkrVal) != 1) 
     {
      Print("error = ",_LastError);
      return(0);
     }
   return(Bid / OtkrVal[0]);
}
 
Yedelkin:
Put up a printout of the error - let's see.

error = 4401

I can't find any decodingof error codes in Metatrader...

Документация по MQL5: Стандартные константы, перечисления и структуры / Коды ошибок и предупреждений
Документация по MQL5: Стандартные константы, перечисления и структуры / Коды ошибок и предупреждений
  • www.mql5.com
Стандартные константы, перечисления и структуры / Коды ошибок и предупреждений - Документация по MQL5
 
MegaVoin:

error = 4401

I can't find any decodingof error codes in Metatrader...

https://www.mql5.com/ru/docs/constants/errorswarnings/errorcodes
Документация по MQL5: Стандартные константы, перечисления и структуры / Коды ошибок и предупреждений / Ошибки времени выполнения
Документация по MQL5: Стандартные константы, перечисления и структуры / Коды ошибок и предупреждений / Ошибки времени выполнения
  • www.mql5.com
Стандартные константы, перечисления и структуры / Коды ошибок и предупреждений / Ошибки времени выполнения - Документация по MQL5
 
MegaVoin: error = 4401

OK, "Requested history not found". I.e. January 2010 is not found in 2012, right?

And on the demo account (not in the tester) what does it show?

 
Yedelkin:

OK, "Requested history not found". I.e. January 2010 is not found in 2012, right?

And on the demo account (not in the tester) what does it show?

Uh-huh, it is not detected.

I created a new demo account (not championship one). Lots greater than 5 are now skipped if I test for 2011, but there is the same error for 2012.

I guess I have to set somewhere how much history is accessible before the test period. And by default it must be 2 years... Only where is it configured...

 
MegaVoin: Created a new demo account (not championship account). Lots over 5 are now skipped if testing for 2011, but still the same error for 2012.

So this error also occurs on a demo account(not in the tester)?

MegaVoin : I guess I have to set somewhere how much history is available before the test period. The default setting is probably 2 years... Only where it is set...

I would rather read about the history for testing in the "Testing of trading strategies" section.

Reason: