To get the number of candles in the intersection of a line and a price, in MQL5, instead of the ObjectGetShiftByValue function, I used ObjectGetShiftByValueMQL4, the code of which is suggested as follows:
For when the intersection of price and object is in the chart range, a positive number is returned and is not a problem. But when the intersection point is in the empty part of the chart. In MQL4 its value is negative and in MQL5 the number zero is always returned. As shown in the image below:
The expected and logical value is a negative number.
What is your suggestion for solving this problem in MQL5?
This article is a quick guide to MQL4 language functions, it will help you to migrate your programs from MQL4 to MQL5. For each MQL4 function (except trading functions) the description and MQL5 implementation are presented, it allows you to reduce the conversion time significantly. For convenience, the MQL4 functions are divided into groups, similar to MQL4 Reference.
As mentioned here:
https://www.mql5.com/fa/articles/81
To get the number of candles in the intersection of a line and a price, in MQL5, instead of the ObjectGetShiftByValue function, I used ObjectGetShiftByValueMQL4, the code of which is suggested as follows:
For when the intersection of price and object is in the chart range, a positive number is returned and is not a problem. But when the intersection point is in the empty part of the chart. In MQL4 its value is negative and in MQL5 the number zero is always returned. As shown in the image below:
The expected and logical value is a negative number.
What is your suggestion for solving this problem in MQL5?