HiArt99:
Read this thread: https://www.mql5.com/en/forum/147625 and check that you are resizing your Series arrayss correctly
Hello folks,
I am attempting to code an Custom Indicator but to arrive and the final value for putting into the IndexBuffers I need very much more than 8 indicator_buffers.
I have created a set of Arrays and in the Init code:
My question is this.
When a new bar is created, the IndexBuffers must add 1 to the array size so that there is a node for the new data to be written to. As "bufferVolgv" has not been assigned to an IndexBuffer, do I need to trap an event when a new bar is created, and manually execute an ArrayResize? My thinking is that if I don't add a new node, the data for the new bar (bufferVolgv[0]) will overwrite the data for the previous bar.
ArrayResize(bufferVolgv, Bars); ArraySetAsSeries(bufferVolgv, true);Will not work because you are not moving elements left as you add more bars. Use this (from my polyline code):
bool ResizeBuffer(double& buffer[], int size){ // buffer can be 1D or 2D if(ArrayRange(buffer,0) != size){ // ArrayRange allows 1D or 2D arrays ArraySetAsSeries(buffer, false); // Shift values B[2]=B[1]; B[1]=B[0] if( !MyArrayResize(buffer, size, "ResizeBuffer") ) return(false); ArraySetAsSeries(buffer, true); } return(true); } bool MyArrayResize(double& arr[], int nRows, string msg){ if( ArrayResize(arr, nRows) >= nRows) return(true); DisableTrading( "ArrayResize("+nRows+") Failed: "+GetLastError() +" "+msg); return(false); }and remember that new elements have not been set to EMPTY_VALUE
Thanks
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
Hello folks,
I am attempting to code an Custom Indicator but to arrive and the final value for putting into the IndexBuffers I need very much more than 8 indicator_buffers.
I have created a set of Arrays and in the Init code:
My question is this.
When a new bar is created, the IndexBuffers must add 1 to the array size so that there is a node for the new data to be written to. As "bufferVolgv" has not been assigned to an IndexBuffer, do I need to trap an event when a new bar is created, and manually execute an ArrayResize? My thinking is that if I don't add a new node, the data for the new bar (bufferVolgv[0]) will overwrite the data for the previous bar.
When an array is assigned to an IndexBuffer, MT4 must handle this automatically.
Or am I over thinking all this?
Thanks
Art