Errors, bugs, questions - page 645

 

Hello all!

Please help a newbie to understand the use of arrays in classes. Cut the key code into a small piece to represent the problem:

class base
{
protected:
int Stf_ZZ_Handle;
double Stf_ZZ_Val[];
public:
void InitArray()
  {
   Stf_ZZ_Handle=iCustom(_Symbol,_Period,"Examples\\ZigZag",12,0,0);
   ArraySetAsSeries(Stf_ZZ_Val,true);
   CopyBuffer(Stf_ZZ_Handle,0,0,200,Stf_ZZ_Val);
   Print("array[0]= ",Stf_ZZ_Val[0]);
  }
};
class second : public base
  {
    public:
    void Printer() {Print("array[0]= ",Stf_ZZ_Val[0]);}
  };
int OnInit()
  {
//---
base Cbase;
second Csecond;
Cbase.InitArray();
Csecond.Printer();
//---
   return(0);
  }

When executing gets an error Array out of range in the string of inherited class, in the parent class I get the expected 0.

2012.02.13 00:41:25 2011.01.01 00:00:00 array out of range in 'test1.mq5' (29,36)
2012.02.13 00:41:25 2011.01.01 00:00:00 array[0]= 0.0

   void Printer() {Print("array[0]= ",Stf_ZZ_Val[0]);}

I understand that I am incorrectly passing (or addressing) an array to an inheritor class, although with normal variables there is no error with such handling.

What am I doing wrong?

 

I've been seeing this message very often lately when running *.mq5 files:

What could be the problem?

 
Radix:

Hello, everyone!

base Cbase;
second Csecond;
Cbase.InitArray();
Csecond.Printer();

What am I doing wrong?

Look, when you declare "second Csecond;" in the second line, the InitArray() method is not called, right? At the same time, the Csecond object itself has already been created. So it turns out that when you call the "Csecond.Printer();", it refers to uninitialized and undimensional array Stf_ZZ_Val[].

 
Can you please tell me if the 1000 bar limit of available history from the start date (as in MT4) has been removed when testing?
 
muallch:

Please, tell me if the limit of 1000 bars available history from the start date has been removed (like in MT4) during testing?

Explain what you mean by that?

In Five, data is loaded from the previous year from the start of testing. So, if you are testing from 2012.02.01, the data will be loaded from 2011.01.01.

The only exception is testing on Days, Weeks and Months - the beginning of data there is calculated based on the need of having 100 bars before the start of testing.

 
stringo:

Explain what you mean by that.

When running from e.g. 2011.01.01 on dailies, we need a history of at least 3000 bars. Thus, we have to set a knowingly longer period than that needed for testing and trace the "start point" programmatically. What is the difficulty of providing the entire history (or upon request) during testing?
 
There is also the question of the availability of history not in testing, but in real auto-trading. What should we do in this case? The tester can be outsmarted...
 
muallch:
When running, for example from 2011.01.01 on daily data we need a history with at least 3000 bars. In other words, we have to set a knowingly longer period, than we need for testing, and to track the "starting point" programmatically. What is the difficulty of providing the entire history (or upon request) during testing?

There is no difficulty at all. We didn't want to introduce an extra check box in the test settings, which would have been incomprehensible to most users and would have been misused in a large number of cases.

It is a normal solution to specify a knowingly longer period.

Another solution - to order testing on a monthly basis, and use daily indicators and price data (i.e., instead of PERIOD_CURRENT set PERIOD_D1 explicitly).

 
muallch:

There is also the question of the availability of history not in testing, but in real auto-trading. What should we do in this case? The tester can be outsmarted...
You can download all available history. Check the documentation for data access organisation
 

Thanks for the clarification!

On a side note: I am testing with remote agents via the internet. Why do agents get the full minute history if I'm testing at opening day prices? The preparation time before the tests start is simply obscene - an hour, for example. Good for those with a 10-100 megabit pipe, but here you're sitting on a measly megabit...

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