Can you please tell me if my broker has floating leverage, how can I take it into account in lot calculation? Or it will not affect, if you go for the above option?
It goes to the chart without problems, but when I call it from the EA it says ...array out of range in 'HiLo.mq4' (121,15)
What's the problem?
It doesn't check if there are 1000 bars on the chart. For example, at the moment of terminal opening there are 0 bars in all charts, but terminal has already started indicators (I do not know why it does that, but it's a fact). Therefore, any access to indicator buffers causes exceeding of time series arrays.
There is no check that there are 1000 bars on the chart. For example, at the moment of terminal opening there are 0 bars in all charts, but terminal has already started indicators (it is unclear why it does it, but it is a fact). Therefore, any access to indicator buffers causes exit of time series arrays.
Because the check is fundamentally wrong. Let's say Bars returns 1000 and cb also returns 1000. Then in the loop on the first iteration i gets the value 1000. In the first condition of the loop body:
if (fx1[i]>fx1[i+1]) fs=1;
Two exits outside the array at once : accessing a bar with index 1000 and one with index 1001. For if the chart has 1000 bars, the first bar has index 0 and the last one has index 999.
Further on through the loop body there is a reference to the even more distant bars in the history:
All of this needs to be taken into account in the initial check.
For a proper check, see the example of the IndicatorCounted() function in MQL4 Reference. Only now, IndicatorCounted() better be replaced by joint use of rates_total (this is Bars) and prev_calculated (this is IndicatorCounted()) variables.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Try the function:
It's not so simple if you use the function on both currencies and futures. There is a margin percentage to consider.
It is not so simple if you use the function on both currencies and futures. You have to consider the percentage of margin.
If we are talking about the percentage loss, we are not interested in the margin, it will return when the position is closed
If we are talking about percentage loss, we are not interested in margin, it will come back when the position is closed
Perhaps
I'm sorry that's all you noticed.)
I'm not the only one, the Terminal can't see the difference either, in essence. The exit outside the array is still there.
Try the function:
Thank you for your help! Unfortunately it was not possible to implement a universal solution, I had to do it this way:
Can you please tell me if my broker has floating leverage, how can I take it into account in lot calculation? Or it will not affect, if you go for the above option?
Another indicator, also array out of range.
It goes to the chart without problems, but when I call it from the EA it says ...array out of range in 'HiLo.mq4' (121,15)
What's the problem?
Another indicator, also array out of range.
It goes to the chart without problems, but when I call it from the EA it says ...array out of range in 'HiLo.mq4' (121,15)
What's the problem?
It doesn't check if there are 1000 bars on the chart. For example, at the moment of terminal opening there are 0 bars in all charts, but terminal has already started indicators (I do not know why it does that, but it's a fact). Therefore, any access to indicator buffers causes exceeding of time series arrays.
There is no check that there are 1000 bars on the chart. For example, at the moment of terminal opening there are 0 bars in all charts, but terminal has already started indicators (it is unclear why it does it, but it is a fact). Therefore, any access to indicator buffers causes exit of time series arrays.
It still crashes.
It still crashes.
Because the check is fundamentally wrong. Let's say Bars returns 1000 and cb also returns 1000. Then in the loop on the first iteration i gets the value 1000. In the first condition of the loop body:
Two exits outside the array at once : accessing a bar with index 1000 and one with index 1001. For if the chart has 1000 bars, the first bar has index 0 and the last one has index 999.
Further on through the loop body there is a reference to the even more distant bars in the history:
All of this needs to be taken into account in the initial check.
For a proper check, see the example of the IndicatorCounted() function in MQL4 Reference. Only now, IndicatorCounted() better be replaced by joint use of rates_total (this is Bars) and prev_calculated (this is IndicatorCounted()) variables.