Alert when bar breaks current daily high/low - page 2

 
Conor Mcnamara #:
Well they have a purpose.

They don't have a purpose. These functions were added due to user requests (if I remember correctly).

As for me, these features were asked to be added mainly by 2 user groups:

  • users who want to convert code from MQL4 to MQL5 quickly and without straining their brains;
  • users who cannot write a simple loop.

Forum on trading, automated trading systems and testing trading strategies

New MetaTrader 5 Platform build 1860: MQL5 functions for operations with bars and Strategy Tester improvements

MetaQuotes, 2018.06.14 16:06

  1. MQL5: New functions: iTime, iOpen, iHigh, iLow, iClose, iVolume, iBars, iBarShift, iLowest, iHighest, iRealVolume, iTickVolume, iSpread. These functions are similar to those used in MQL4. The functions provide for an easier transfer of code of trading applications to the fifth generation platform.

    Earlier, most of tasks performed through these functions could be implemented using Copy* functions. However, users had to implement their own functions in order to find the High/Low values ​​on the chart and to search for bars based on their time. Now, these tasks can be easily executed using iHighest, iLowest and iBarShift functions.

In the case of the indicator, you don’t even need to copy anything. Just write a small loop and find the bar you need in the ready array.

 
Vladislav Boyko #:
Why do you need these terrible functions?

Each call to such a function can generate an error. You need to check for error every time you call any of these functions.

If the function generated an error, then on this tick it is better not to use any data related to prices at all. The quotes are most likely loading and you will need to wait for them to load.

Each such function contains a CopyXXX call inside. That is, they can request data from the server.

If you write a simple loop yourself, then you don't need to handle any errors, you don't need to request anything from the server. You simply find the index of the bar you need in the array that the terminal has prepared for you.

 
Vladislav Boyko #:

Each call to such a function can generate an error. You need to check for error every time you call any of these functions.

If the function generated an error, then on this tick it is better not to use any data related to prices at all. The quotes are most likely loading and you will need to wait for them to load.

Each such function contains a CopyXXX call inside. That is, they can request data from the server.

If you write a simple loop yourself, then you don't need to handle any errors, you don't need to request anything from the server. You simply find the index of the bar you need in the array that the terminal has prepared for you.

Good to know. But I found them handy for a use case anyway. The indicator looks nice, neat, and maintainable as well by using them.