Hi adamuu,
No error reported ?
int e = GetLastError(); if(!e && inds_copied == 1)
Insignificant maybe, but could you re-run the test again using this ?
int e = GetLastError(); if(e == 0 && inds_copied == 1) // -->> no error reported
http://www.mql5.com/en/docs/constants/errorswarnings/errorcodes
Interesting though :)
:D
40
This time hopefully I have checked all possible ways CopyBuffer can return something invalid. (unlike last time, when I neglected to GetLastError). Still, in rare cases, CopyBuffer sometimes writes rogue values to its destination array.
This little script, though pointless on its own, proves it.
1. Set debugger options to use specified symbol and period: EURUSD, M1.
2. Set max bars per chart at 500k.
3. Pre-load chart data for EURUSD and AUDJPY.
4. Set breakpoint at the "return 1" statement.
5. Start debugger.
I find this script stops at the breakpoint after some number of iterations. (be patient). At this point, the local variables are
e = 0
previous = 87.3505777829597 (the correct value according to the chart)
tmp[0] = 87.3517034067397 (consistently, when wrong)
random_starting_point = 203.45 (for example)
I've run this a few times. It always encounters the return 1 line eventually.
count = 68463501, random_starting_point = 228.85
count = 19735884, random_starting_point = 15.54
count = 37069616, random_starting_point = 53.04
count = 358285678, random_starting_point = 205.87The strange thing is, I'm always using the same seed (123). So, sometimes the loop works fine through places where it previously hit the breakpoint. So, it is not the case that the value of tmp[0] depends on the value of random_starting_point after CopyBuffer has been executed without error. Still, there is non-determinism, somehow.
Any ideas where the 87.3517034067397 come from?
I can get this to happen at other data points and with other symbols and indicators. This is just an example. I discovered this problem when tracking down inconsistencies in the output of a much more complex indicator. This is a simplified example of a problem that really happens.