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

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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.