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

 
How can I work with this? I've been sitting here for two days now for nothing. What other solution could there be?
 
Question please. in the OnCalculate(...) handler, the buffer constants open,high,low,close overflow for the entire history one character at a time, what should I do? For example, I want to calculate the value of array mas[i]= open[i] /close[i] for the whole history of one pair and average this value with another character. I searched through a lot of topics, there is not much similar. Can you tell me where to look.
 
Juer:
How can I work with this? I've been sitting here for two days now for nothing. What other solution could there be?

And where did you show a reproducible example? You're just giving us scraps of code. Do we have to compile them into working code at our discretion? What if we don't guess and you need the wrong one?

 
Artyom Trishkin:

And where did you show a reproducible example? You only give scraps of code. Do we have to link them into working code at our discretion? What if we don't guess and you need the wrong thing?

OK, but how to do it properly not through an array of structures, but through a CArrayObj class, where the object would be an object of structure type? I don't really understand how to declare and how to add and is this even possible?

 
Juer:

OK, but how to do it properly not through an array of structures, but through a CArrayObj class, where the object would be an object of structure type? I don't really understand how to declare and how to add and is this even possible?

Try to describe the problem in general, not in specifics - what you want to get as a result of having this or that data.

 
mwwm:
Question please. in the OnCalculate(...) handler, the buffer constants open,high,low,close overflow for the entire history one character at a time, what should I do? For example, I want to calculate the value of array mas[i]= open[i] /close[i] for the whole history of one pair and average this value with another character. I searched through a lot of topics, there is not much similar. Can you tell me where to look.
What do you mean by overflow?
 
Дед пенсионер:
what does overflow mean?

XAUUSD,Daily: array out of range in '!2019.mq4' (243,6) gives out during calculations via constants inOnCalculate, and CopyOpen' - no one of the overloads can be applied to the function call when I try to do like this int prices1=CopyOpen(Symbol(),0,0,Bars(_Symbol,_Period),open); It's very confusing to organize access to data via structures, at what point OHLC takes all quotes and then only new ones, I'm stuck on iOpen(,,,))


 
Juer:

So error invalid array access.

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

I'm sorry. I got a bit silly. Of course, it will have to be a bit more complicated:

bool CCandleRule::GetRulesArray(input_rule &rules_array[])
{
   int nArraySize = ArraySize(rules);
   if (ArraySize(rules_array) != nArraySize)
      if (ArrayResize(rules_array, nArraySize) != nArraySize)
         return false;

   for (int i = 0; i < nArraySize; ++i)
      rules_array[i] = rules[i];
      
   return true;
}

It's not a vector, like in C++. That's why element-by-element copying is required. Also we have to take care of matching the size of the original array and the destination array. That's why the function doesn't get in one line. And it won't always be executed successfully. That's why we need to return the confirmation that it was executed successfully.

 
mwwm:

XAUUSD,Daily: array out of range in '!2019.mq4' (243,6) gives out during calculations via constants inOnCalculate, and CopyOpen' - no one of the overloads can be applied to the function call when I try to do like this int prices1=CopyOpen(Symbol(),0,0,Bars(_Symbol,_Period),open); It's very confusing to organize access to data via structures, at what point OHLC takes all quotes and then only new ones, stuck on iOpen(,,,))


Doesn't override, and you're accessing a non-existent index.
 
Artyom Trishkin:
It doesn't override, and you are addressing a non-existent index.

and how to do it correctly?

Reason: