I can confirmt he same bug. Simply modifying the condition to `if(m_tail > m_head)` solves it for me. But each MT5 upgrade wants to overwrite this back, so please fix it.
Also, it is quite misleading that the the declaration of `m_tail` says this: "last valid element in the queue". This is obviously not true because it always points to an element after.
Thank you all
Fixed
template<typename T> int CQueue::CopyTo(T &dst_array[],const int dst_start=0) { //--- resize array if((dst_start+m_size)>ArraySize(dst_array)) if(ArrayResize(dst_array,dst_start+m_size)<0) return(0); //--- copy queue elements from head to tail if(m_tail>m_head) return(ArrayCopy(dst_array,m_array,dst_start,m_head,m_size)); //--- copy queue elements from head to end int num_copied=ArrayCopy(dst_array,m_array,dst_start,m_head,m_array.Size()-m_head); //--- copy queue elements from beginning to tail num_copied+=ArrayCopy(dst_array,m_array,dst_start+num_copied,0,m_tail); //--- return number of copied elements return(num_copied); }

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
Hi,
I've found that CopyTo method has a mistake
Original code is :
template<typename T>
int CQueue::CopyTo(T &dst_array[],const int dst_start=0)
{
//--- resize array
if((dst_start+m_size)>ArraySize(dst_array))
if(ArrayResize(dst_array,dst_start+m_size)<0)
return(0);
//--- copy queue elements from head to tail
if(m_tail >= m_head)
return(ArrayCopy(dst_array,m_array,dst_start,m_head,m_size));
//--- copy queue elements from head to end
int num_copied=ArrayCopy(dst_array,m_array,dst_start,m_head,m_size-m_head);
//--- copy queue elements from beginning to tail
num_copied+=ArrayCopy(dst_array,m_array,dst_start+num_copied,0,m_tail);
//--- return number of copied elements
return(num_copied);
}
When CQueue is full it returns less elements than it actually has:
Error is in
Changing it to