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

 
Artyom Trishkin:
Number1
2
3
4
5
6
7
8
9
10
Index0
1
2
3
4
5
6
7
8
9

As you can see - there are ten orders, but their indexes are 1 less, because in any array the count starts from zero.

OrdersTotal() is 10, but if you start a loop with OrdersTotal(), it will go outside the array - there is no index for order 10 - the largest index is 9 - so OrdersTotal()-1


Thank you ... Got it ... Thank you.
 
Vitalie Postolache:

This is because it is counted from 0. If you have 10 orders, then count ordinal numbers should be 0...9, that is, 0...(10-1), whereOrdersTotal()=10.

Just keep this in mind when writing programs.


Thank you ... got it ...
 
Vitaly Muzichenko:
Print via Print() and you won't have these questions, it's not difficult.

Thanks ... Got it ... I just thought theOrdersTotal count was also including zero ... Then I was wrong, I wrote like this(int i=OrdersTotal(); i>-1; i--) and it didn't work properly.


 
Hello!
In the documentation, in the article "Indicator Styles in Examples" it says :
By default, the indicator buffer is used to store the data to be drawn (INDICATOR_DATA).

If the calculation of indicator values requires intermediate calculations and storing an auxiliary value for each bar, you can declare such an array as a calculation buffer ( INDICATOR_CALCULATIONS) when binding.

None of 18 given examples of constructions in MQL5 demonstrates thearray of calculation buffer ( INDICATOR_CALCULATIONS).
Please advise where else to read about this topic ?
 
Leo59:
Hello!
In the documentation, in the article "Indicator Styles in Examples" it says :
By default, the indicator buffer is used to store the data to be drawn (INDICATOR_DATA).

If the calculation of indicator values requires intermediate calculations and storing an auxiliary value for each bar, you can declare such an array as a calculation buffer ( INDICATOR_CALCULATIONS) when binding.

None of 18 given examples of constructions in MQL5 demonstrates thearray of calculation buffer ( INDICATOR_CALCULATIONS).
Please tell me where else to read about it ?
Think of it as a normal dynamic array for storing intermediate calculation data. You just don't need to increase/decrease its size - the client terminal will do it for you. The data of such an array-buffer will not be shown on a chart - that's the difference between DATA and CALCULATIONS
 
Artyom Trishkin:
Think of it as a normal dynamic array for storing intermediate calculations. You just do not need to control it and increase/decrease its size - the terminal will do it for you. The data of such an array-buffer will not be shown on a chart - that's the difference between DATA and CALCULATIONS.
Where is a sample code for clarity?
 
Artyom Trishkin:
Think of it as a normal dynamic array for storing intermediate calculations. You just do not need to control it and increase/decrease its size - the terminal will do it for you. The data of such an array-buffer will not be printed on a chart - this is the difference between DATA and CALCULATIONS
If the indicator #property indicator_chart_window - this is correct, it is not output. But if indicator #property indicator_separate_window - it is output for some reason.
 
Leo59:
Where's a working code example for clarity?
DemoBufferPattern
DemoBufferPattern
  • votes: 21
  • 2010.03.24
  • Loong
  • www.mql5.com
Пример использования нескольких индикаторных буферов(Candles+Fractals+ZigzagColor+ColorMaLine).
 
Artyom Trishkin:
Thank you!
 
Artyom Trishkin:
Artyom, please, a WORKING code example is needed!!!!

And the one you gave.... For example line 87 : maHandle=iMA(Symbol(),0,ExtPeriod,0,MODE_EMA,PRICE_CLOSE);
Well, what does it matter?