How do I get Open,Low,High,Close parameters in MQL5? - page 2

 
Igor Makanu:

like this:

Thank you. This option is more appropriate.
 
Vladimir Karputov:



This is unnecessary in MQL5.


And this is how those who

love to run into hidden errors (in general, all those who are too lazy to do basic checks)

What difference does it make where to check the data? You can check after Time[x]. That's the way it's always done in general.
 
Реter Konow:
Thank you. This option is more suitable.

Please, no problem, I'm in the same "Z" - very uncomfortable everything in MQL5

 
Alexey Volchanskiy:

Is it like a multiplatform MT4 code? Gud, I write almost everything multiplatform these days.

Alexei, this is for those who are in a tank. But for others, CopyRates() is available in mql4. So forget all the iOpen and other nonsense. I don't even understand why they put it in mql5...

CopyRates - Доступ к таймсериям и индикаторам - Справочник MQL4
CopyRates - Доступ к таймсериям и индикаторам - Справочник MQL4
  • docs.mql4.com
Получает в массив rates_array исторические данные структуры MqlRates указанного символа-периода в указанном количестве. Отсчет элементов от стартовой позиции ведется от настоящего к прошлому, то есть стартовая позиция, равная 0, означает текущий бар. При копировании заранее неизвестного количества данных рекомендуется в качестве приемного...
 

Do iOpen and other functions work by themselves, or do you still need CopyRates? I have Print(iOpen(0,CURRENT_PERIOD,1)); entry returns 0.0 without CopyRates (called from Init). Local history is there.

And where to place CopyRates if you need it and need to get data on bars all the time? In OnTick() on every tick, or in the function of a new bar?

 
Реter Konow:
And functions iOpen and others work by themselves, or do we still need CopyRates? My Print(iOpen(0,CURRENT_PERIOD,1)); entry returns 0.0 without CopyRates (called from Inite). The local history is there.

By themselves. Maybe the problem is that the named constant is incorrectly specified? Not CURRENT_PERIOD, but PERIOD_CURRENT. If it still gives 0, this is an error. It can be found out via GetLastError().

 
Реter Konow:

Do iOpen and other functions work by themselves, or do you still need CopyRates? I have Print(iOpen(0,CURRENT_PERIOD,1)); entry returns 0.0 without CopyRates (called from Init). The local history is there.

And where to place the CopyRates if it is required and we need to obtain the data on the bars all the time? In OnTick() on every tick, or in the new bar function?

Throw out ALL iXXXXXX functions - as said above - only CopyRates. There is an example of getting data in the help, though.

And you should get this data depending on your needs: whether you need values of zero (the rightmost bar on the chart) or not.

 
Ihor Herasko:

By themselves. Maybe the problem is that the named constant is incorrectly specified? Not CURRENT_PERIOD, but PERIOD_CURRENT. If it still gives 0, this is an error. It can be found out via GetLastError().

No, I wrote it wrong here. I wrote it correctly. Error 0.
 
Vladimir Karputov:

Throw out ALL iXXXXXX functions - as said above - only CopyRates. There is an example of getting data in the help.

And you should get this data depending on your needs: whether you need values of zero (the rightmost bar on the chart) or not.

OK. I'll give it a try.
 
Vladimir Karputov:

Throw out ALL iXXXXXX functions - as said above - only CopyRates. There is an example of getting data in the help.

And you should get this data depending on your needs: whether you need values of zero (the rightmost bar on the chart) or not.

Oh Vladimir. Even though I blurted it out, I regretfully didn't make a reservation. If we need only the opening price or time, for example, there's no need to use CopyRates(), in this case CopyOpen or iOpen is quite enough... respectively CopyTime or iTime. It is chosen according to religious preferences.

And I will add my caveat: In terms of productivity costs, there is no discernible difference. Consequently, it is purely a matter of religious bias.
Reason: