dingmaotu / mql4-lib

MQL4/5 Foundation Library For Professional Developers
Apache License 2.0
544 stars 251 forks source link

Array out of range error while iterating over elements in the Vector #51

Closed vklevko closed 5 years ago

vklevko commented 5 years ago
for (int i = fractalData.size()-1; i >= 0; i--)
  {
    Print(__FUNCTION__, " Current i: ", i, " fractal data size: ", fractalData.size());
    if (fractalData.get(i).GetFractalType() == fractalType || fractalData.get(i).GetFractalType() == BIDIRECTIONAL) //
    {
      return fractalData.get(i);
    }
  }
2019.10.11 15:28:43.155 2017.04.21 12:05:16  FSharp EURUSD,H1: array out of range in 'Vector.mqh' (134,61)
2019.10.11 15:28:43.155 2017.04.21 12:05:16  FSharp EURUSD,H1: Vector<Fractal*>::get current element trying to fetch is: 4 array size: 6
2019.10.11 15:28:43.155 2017.04.21 12:05:16  FSharp EURUSD,H1: Vector<Fractal*>::get current element trying to fetch is: 4 array size: 6
2019.10.11 15:28:43.155 2017.04.21 12:05:16  FSharp EURUSD,H1: GetLatestFractal Current i: 4 fractal data size: 6
2019.10.11 15:28:43.155 2017.04.21 12:05:16  FSharp EURUSD,H1: Vector<Fractal*>::get current element trying to fetch is: 5 array size: 6
2019.10.11 15:28:43.155 2017.04.21 12:05:16  FSharp EURUSD,H1: Vector<Fractal*>::get current element trying to fetch is: 5 array size: 6

Unexpected behavior trying to get the same object multiple times like in the if above.

vklevko commented 5 years ago

It was fixed in the upstream code. Wrong interation implementation.