Errors, bugs, questions - page 2467

 
Igor Makanu:

For the first time I tried to make a wrapper class for a two-dimensional array, but I couldn't overload [] to treat it as a normal two-dimensional array arr[1][2]

Such a problem was solved 4-5 years ago, there was a separate branch with ready-made solutions.
Few of the active participants survived to this day, most of them were outbanned...

P.s. It was not a two-dimensional array, but a three-dimensional array on classes.

 
Oh, I think I found that threadhttps://www.mql5.com/ru/forum/6729
В MQL5 всегда есть место подвигу ! ;)
В MQL5 всегда есть место подвигу ! ;)
  • 2012.05.16
  • www.mql5.com
Общее обсуждение: В MQL5 всегда есть место подвигу ! ;)
 
Sergey Dzyublik:

Such a problem was solved 4-5 years ago, there was a separate branch with ready-made solutions.
Of the active participants, few have survived to this day, most were re-banned...

P.s. It was not a two-dimensional array, but a three-dimensional array on classes.

Well, I went and looked in that thread - there's not a single account that's been banned or deleted. All of the people in that branch are there, and still alive.

Is that how you decided to create a scandal, throwing it at the administration? It's silly, isn't it? Stop seeing evil around here.

 
Sergey Dzyublik:
Oh, I think I found that branchhttps://www.mql5.com/ru/forum/6729

I think I read this thread last month, I'll look again tonight

but my experiments with overloading [][] ended in realizing that I can implement either L-value or R-value in MQL using overloading [][].

If you have a complete solution for a dynamic two-dimensional array - put it in CodeBase, it's a useful thing - I've looked no better than CMatrixDouble from MT: #include Math Alglib

 
class A{
public:
   uchar data1;
};

A func(){
   A a;
   a.data1 = 1;
   return a;      //object of 'A' cannot be returned, copy constructor 'A::A(const A &)' not found
}


void OnStart(){  
   A a;

   //1
   A aa = a;
   a = aa;
   
   //2
   a = func();   
}

What is the difference between //1 and //2 ?
Unfortunately, this problem cannot be avoided when using templates in containers with an arbitrary data type.

As a special case, to solve the problem, we can implement inheritance, define a copy constructor for the parent class and replace the return type in the problem function from the base to the parent.

 
Developers:
Please add a function which returns an array's Capacity (the number of elements for which space is reserved in memory). Not to be confused with reserve parameter for ArrayResize.
There isStringBufferLen for string but nothingfor array.
 

Forum on trading, automated trading systems and trading strategy testing

Bugs, bugs, questions

Sergey Dzyublik, 2019.05.22 16:01

Thanks again toTheXpert for providing the code.
We have the following results on ArrayResize capacity MT5(build 2057):


Result:
2019.05.22 17:00:50.249 Test_array_resize (EURUSD,H1)   TEST_ArrayCapacity:TEST_ArrayCapacity
2019.05.22 17:00:50.249 Test_array_resize (EURUSD,H1)   TestArrayCapacity(store,100,0):100
2019.05.22 17:00:50.249 Test_array_resize (EURUSD,H1)   TestArrayCapacity(store,100,100):100
2019.05.22 17:00:50.249 Test_array_resize (EURUSD,H1)   TestArrayCapacity(store,101,100):201
2019.05.22 17:00:50.249 Test_array_resize (EURUSD,H1)   TestArrayCapacity(store,200,100):201
2019.05.22 17:00:50.249 Test_array_resize (EURUSD,H1)   TestArrayCapacity(store,201,100):201
2019.05.22 17:00:50.249 Test_array_resize (EURUSD,H1)   TestArrayCapacity(store,202,100):302
2019.05.22 17:00:50.249 Test_array_resize (EURUSD,H1)   TestArrayCapacity(store,100,1):302
2019.05.22 17:00:50.249 Test_array_resize (EURUSD,H1)   TestArrayCapacity(store,100,400):302
2019.05.22 17:00:50.249 Test_array_resize (EURUSD,H1)   TestArrayCapacity(store,300,400):302
2019.05.22 17:00:50.249 Test_array_resize (EURUSD,H1)   TestArrayCapacity(store,301,600):302
2019.05.22 17:00:50.249 Test_array_resize (EURUSD,H1)   TestArrayCapacity(store,302,600):302
2019.05.22 17:00:50.249 Test_array_resize (EURUSD,H1)   TestArrayCapacity(store,303,600):903
2019.05.22 17:00:50.249 Test_array_resize (EURUSD,H1)   TestArrayCapacity(store,100,0):903
2019.05.22 17:00:50.249 Test_array_resize (EURUSD,H1)   TestArrayCapacity(store,100,100):903
2019.05.22 17:00:50.250 Test_array_resize (EURUSD,H1)   TestArrayCapacity(store,100,-1):100
2019.05.22 17:00:50.250 Test_array_resize (EURUSD,H1)   TestArrayCapacity(store,100,100):100
2019.05.22 17:00:50.250 Test_array_resize (EURUSD,H1)   TestArrayCapacity(store,105,100):205

 

Good evening!

Can anyone tell me what's going on?

This is the first time I've seen this happen. Simple code in one of the functions.

double yyy=28/50*100;
   
Print("test yyy=", yyy);

Result:

"2019.05.21 19:38:29.364 2019.04.01 00:05:00 test yyyy=0.0"


 
Michael2K:

Good evening!

Can anyone tell me what's going on?

int(28) / int(50) * int(100) == int(0) * int(100) == int(0) == double(0.0)


Use a full stop to specify the type double:

double yyy=28./50*100;
 
Sergey Dzyublik:
Please also provide pseudocode for using reserve_size parameter in ArrayResize.
There is no description of how the system behaves when a new reserve_size value is set for next ArrayResize.
Sergey Dzyublik:


Is the following assumption correct when calling sequentially:

The pseudocode they once gave in this thread, look it up. As far as I remember, capacity is increased there only when the array size exceeds this capacity. Though of course something could have changed.

And the function of getting the value of a saracity is really very useful.