Example:
I think this may be a bug, although I'm not sure if metaquotes did this by design...
I fixed the issue by making a change on line 169 in the ArrayInt.mqh
//+------------------------------------------------------------------+ //| Resizing (with removal of elements on the right) | //+------------------------------------------------------------------+ bool CArrayInt::Resize(const int size) { int new_size; //--- check if(size<0) return(false); //--- resize array new_size=m_step_resize*(1+size/m_step_resize); if(m_data_max!=new_size) { if((m_data_max=ArrayResize(m_data,new_size))==-1) { m_data_max=ArraySize(m_data); return(false); } } //if(m_data_total>size) if(m_data_total != size) m_data_total=size; //--- result return(m_data_max==new_size); }
I think this may be a bug, although I'm not sure if metaquotes did this by design...
I fixed the issue by making a change on line 169 in the ArrayInt.mqh
Total() returns the number of actual data element not the size of the array. Arrays classes reserve empty elements and resize automatically when needed.
You didn't fix anything you introduced a bug in the class, as the number of elements is only changed if requested size is lower than current elements count.
Use Max() if you want the size of inner array.
![Documentation on MQL5: Standard Library / Data Collections / CArray Documentation on MQL5: Standard Library / Data Collections / CArray](/i/community/logo_mql5_small.png)
- www.mql5.com
Total() returns the number of actual data element not the size of the array. Arrays classes reserve empty elements and resize automatically when needed.
You didn't fix anything you introduced a bug in the class, as the number of elements is only changed if requested size is lower than current elements count.
Use Max() if you want the size of inner array.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Example: