Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1468
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
For example MA5, average of 5 bars, set to display 100 bars. Then the indicator will calculate from the 104th to the 100th bar and will start drawing the line from the 100th bar. Then rates_total=5, or 100, or 104?
Rates_total is the number of bars of the chart available for calculation. In other words, it is Bars().
prev_calculated is how many bars the indicator has calculated at the previous OnCalculate() call. It is necessary for organising economical calculations.
If prev_calculated is equal to rates_total, it means that nothing has been calculated yet, and it is necessary to initialise the indicator buffers and perform a full calculation of the whole history.
In general, we can use the following construction:
rates_total is the number of chart bars available for calculation. In other words, it is Bars().
prev_calculated is how many bars the indicator has calculated on the previous call OnCalculate(). It is necessary to organise economical calculations.
If prev_calculated is equal to rates_total, it means that nothing has been calculated yet, and it is necessary to initialise the indicator buffers and perform a full calculation of the whole history.
In general, we can use the following construction:
Why not write instead of rates_total - Bars()?
Why not write Bars() instead of rates_total ?
You can use such a construction too. But why? When there are already predefined variables in the handler's parameters...
Bars() should be used when you really need it - when getting the number of available bars by another symbol/timestamp.
You can use this design too. But why? When there are already predefined variables in the handler's parameters...
Bars() should be used when it is really needed - when getting the number of available bars by another symbol/timeframe.
Artyom, sometimes anyone gets tired and makes mistakes. Don't consider it a criticism, but rates_total - Bars() will always be zero...
In general, it's very difficult to explain to this character. A victim of the USE...
Artyom, sometimes everyone gets tired and makes mistakes. Don't consider it a criticism, but rates_total - Bars() will always be zero...
In general, it is very difficult to explain to this character. A victim of the USE...
Yes, you're right. I didn't think that someone would decide to calculate like that. I saw Bars in the calculation out of the corner of my eye and thought it was instead of rates_total.
It happens, thanks.
I understand that you wanted to help the person, but apparently by mistake you only confused them.
The economical miscalculation in this case looks a little different.
I understand that you wanted to help the person, but apparently by mistake only confused.
The economic miscalculation in this case looks a little different.
What do you think I wrote wrong? Justify it, please.
What is the limit and where will the loop come from in my and your example.
Why not write Bars() instead of rates_total ?
In essence rates_total and Bars() are the same thing, onlyBars() is a function, so its call will cost more in terms of execution time than reading the value of the rates_total variable.
What do you think I wrote wrong? Justify it, please.
What is the limit and where the loop will come from in my and your example.
Oops))))))
I didn't see it right
I didn't see what you wrote at all.
I apologise.
Artyom, sometimes anyone gets tired and makes mistakes. Don't consider it a criticism, but rates_total - Bars() will always be zero...
In general, it is very difficult to explain to this character. A victim of the USE...
rates_total isBars() in the sentence. That is,rates_total is Bars().
In the code below
He's right.
I didn't take the USE. It didn't exist then.