I've been trying to figure this out for a while. I've boiled the code down to the following snippet. From what I can tell no matter what you change the value in the buffer to the "Average" stays the same.
#property indicator_chart_windowdouble Buffer[];int init(){SetIndexBuffer(0, Buffer);return(0);}int start(){double BeforeReal, BeforeRef, AfterReal, AfterRef;// Ensure a minimum history //if(Bars<=10)return(0);for(int iA =0; iA <ArraySize( Buffer ); iA++)
Buffer[iA]=10000+ iA*10;for(int iPos=10; iPos>=0; iPos--){// Record values before change //
BeforeReal = Buffer[iPos];
BeforeRef =iMAOnArray( Buffer,0,1,0,MODE_LWMA, iPos );// Make a change //
Buffer[iPos]=31337.0;// Record values after change //
AfterReal = Buffer[iPos];
AfterRef =iMAOnArray( Buffer,0,1,0,MODE_LWMA, iPos );Print("(", BeforeReal,", ", BeforeRef,") -> (", AfterReal,", ", AfterRef,")");}return(0);}
This doesn't seem to be an "Array/Series" problem. The output of the snippet SHOULD look like:
Sometimes I have found that you have to have a "write" loop, then after that is all done, do "read" loop, to get the expected values from index buffers.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I've been trying to figure this out for a while. I've boiled the code down to the following snippet. From what I can tell no matter what you change the value in the buffer to the "Average" stays the same.
This doesn't seem to be an "Array/Series" problem. The output of the snippet SHOULD look like:
(10000, 10000) -> (31337, 31337)
(10010, 10010) -> (31337, 31337)
...
Instead it looks like:
(10000, 10000) -> (31337, 10000)
(10010, 10010) -> (31337, 10010)
...
Can someone please explain this to me? Thanks.