I would like to cutting the array to keep fresh 1,000 elements and discard old 1,000 elements. The following code works in MT4, but it seems not to be work in MT5.
Is there any method? Thanks.
If the resize does not works, then find out what error did you get and read the doc about ArrayResize , there you can read that you have to declare your array as a dynamic array.
And you don't have to set - reset the array to timeseries just to resize it.
if (ArrayResize (my_arr, 100)) == -1) { Print (GetLastError()); }
If the resize does notworks, then find out what ArrayResize do, there you can read that you have to declare your array as a dynamic array.
And you don't have to set - reset the array to timeseries.
Thanks, phi.nuts.
The array declared as dynamic array. In MT4, above code keeps the last added 1,000 elements after ArrayResize(...) statement. But in MT5, after ArrayResize(...) statement, there is old elements in the array and newly added elements deleted. Anyway, forget the code. Is there any method to keep the last added elements when contracting the array?
Many thanks codersguru,
solved :
int ArrayCutting() { int size_limit=2000,size_new=1000; int size=ArraySize(m_wavePr_pt); double tempPr[]; if(size>size_limit) { ArrayCopy(tempPr,m_wavePr_pt,0,size_new+1,size_new); ArrayResize(m_wavePr_pt,size_new); ArrayCopy(m_wavePr_pt,tempPr,0,0,size_new); } return(0); }
Many thanks codersguru,
solved :
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I would like to cutting the array to keep fresh 1,000 elements and discard old 1,000 elements. The following code works in MT4, but it seems not to be work in MT5.
Is there any method? Thanks.