Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 510

 

A question about the algorithm. Who here understands theoretical and mathematical statistics? Look, there is a price series, levels. I need to select "strong" levels from them. Strong means the value where the frequency of distribution of these levels is the highest.

For example, the series 1,8,10,11,13,35,40,60,65. Say there is a delta, say 2, which denotes the maximum difference between the values. So there is a strong level around 8,10,11,13 which equals (8+10+11+13)/4. Maybe there's just a ready-made statistical function for this, so I don't have to reinvent the wheel? Can you give me a hint, please?

 
Please tell me, there are standard CArray classes for working with arrays. As I understand it, are they for working exclusively with one-dimensional arrays? Or with multidimensional (two-dimensional) arrays too? If not, is there a class for working with multidimensional arrays.
 
Juer:
Please tell me, there are standard CArray classes for working with arrays. As I understand it, are they for working exclusively with one-dimensional arrays? Or with multidimensional (two-dimensional) as well? If not, is there a class for working with multidimensional arrays?

https://www.mql5.com/ru/articles/567

Found here.

Основы программирования на MQL5 - Массивы
Основы программирования на MQL5 - Массивы
  • 2012.11.03
  • Dmitry Fedoseev
  • www.mql5.com
Наряду с переменными и функциями, массивы являются практически неотъемлемой частью любого языка программирования. Замечено, что некоторые начинающие изучать программирование, панически боятся массивов. Удивительно, но факт! Смею заверить вас, что бояться их не нужно. Массивы, по своей сути, это все те же обычные переменные. Если не вдаваться в...
 

How do I return an array of structures in a function?

custom_struct values[];
...
custom_struct Func(void)
  {
   return GetPointer(values);
  }

class type expected, object required errors.

What is the correct way?

 
Juer:

How do I return an array of structures in a function?

class type expected, object required errors.

What is the correct way?

The pointer can be to an object of a class, but not to a structure
 
Juer:

How do I return an array of structures in a function?

class type expected, object required errors.

What is the correct way to do this?

Pass by reference:

struct A
{
...
};

A structA[];

void GetStructA(A &structA[])
{
....
   structA = _structA;
}
This is if the structure only contains simple data types (no strings or arrays). If the structure contains strings and/or arrays, then add an assignment operator overload to the structure.
 
Ihor Herasko:

Transfer by reference:

This is if the structure only contains simple data types (no strings and arrays). If the structure contains strings and/or arrays, then add an assignment operator overload to the structure.

So error invalid array access.

There are no arrays or strings in the structure. Only bool, integer, double and enums.

 
Juer:

So the error is invalid array access.

Do you just have a structure, not an array of structures?

You don't show the code normally. Do we have to guess?

 
Artyom Trishkin:

You just have a structure, not an array of structures?

You don't show the code properly. Do we have to guess?

An array of structures, I wrote it...

 
class CCandleRule : public CObject
  {
protected:
   input_rule        rules[];
public:
   void              GetRulesArray(input_rule &rules_array[]);
  }

void CCandleRule::GetRulesArray(input_rule &rules_array[])
  {
   rules_array=rules;
  }
The input_rule structure is large, but only has int, double, bool and enum fields. It does not contain strings or arrays.
Reason: