Indis compiled against build 890 throwing bizarre errors

 

I've got a bunch of indis I wrote, not recompiled since my MT4 auto updated to 890, all working fine.

I needed to make some minor changes today, and recompiled against 890, and suddenly strange things are happening.

For one, an ArrayResize statement in a section of code is now completely failing to work. Debug statements confirm the array is the same size before and after the ArrayResize command is executed. This is code I haven't touched for months.

Additionally, during the process of trying to chop code around to find out what the issue was, I kept getting Access Violation write to 0x00000000 errors coming up in the Experts tab.

I use a include file of common functions for all my indis, which reference some of the Win32 DLLs - I half suspect the issues lies with this.

Has anyone else had similar problems?

It's going to be a nightmare to try and unpick all my code to try and find what specifically is causing the error - it seems completely non-deterministic. When I comment out a line simply declaring an integer variable after the ArrayResize command for instance, it works - when I put the line back in, the command fails.

Cheers

 
Alternatively, is it possible to roll back to a previous version, say 840?
 

Ok I've managed to hack down the code to almost nothing to try to isolate the issue, and remove the reference to the common function include file.

 

#property copyright "Copyright 2014, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window

int OnInit() {   
   int t = GetCustomPeriodMovingAverageTrend(Symbol(), 1, 1, 21, MODE_LWMA);   
   
   return(INIT_SUCCEEDED);
}

int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) {
   return(rates_total);
} 

void OnChartEvent(const int id, const long& lparam, const double& dparam, const string& sparam) {   
}

void OnDeinit(const int reason) {   
}

struct PriceTime {
   double price;
   datetime time;
};

void GetCustomPeriodMovingAverage(string symbol, ENUM_TIMEFRAMES period, int periodMultiplier, int maPeriod, ENUM_MA_METHOD maMethod, PriceTime& values[], int startAt = 0, int count = 0) {
   if (count != 0) count += maPeriod;
   MqlRates rates[];
   //GetCustomPeriodData(symbol, period, periodMultiplier, rates, startAt, count);
   CopyRates(symbol, period, startAt, count, rates);
   double tempValues[];
   PrintFormat("Before resize - AsRates: %i, AsTemp: %i", ArraySize(rates), ArraySize(tempValues));
   ArrayResize(tempValues, ArraySize(rates));
   PrintFormat("After resize - AsRates: %i, AsTemp: %i", ArraySize(rates), ArraySize(tempValues));
   for (int i = 0; i < ArraySize(rates); i++) tempValues[i] = (rates[i].high + rates[i].low) / 2;
   ArraySetAsSeries(tempValues, true);
   ArrayResize(values, ArraySize(rates) - maPeriod);
   for (int i = 0; i < ArraySize(rates) - maPeriod; i++) {      
      values[i].price = iMAOnArray(tempValues, 0, maPeriod, 0, maMethod, i);
      values[i].time = rates[ArraySize(rates) - 1 - i].time;
   }
}

int GetCustomPeriodMovingAverageTrend(string symbol, ENUM_TIMEFRAMES period, int periodMultiplier, int maPeriod, ENUM_MA_METHOD maMethod, int startAt = 0) {
   int count = maPeriod * 2;
   PriceTime values[];   
   GetCustomPeriodMovingAverage(symbol, period, periodMultiplier, maPeriod, maMethod, values, startAt, count);
   if (ArraySize(values) == 0) return 0;
   if (values[0].price == values[1].price) return 0;
   else if (values[0].price > values[1].price) return 1;
   else return -1;
   return 0;
}

 

As you can see, I've added Print statements to debug the ArrayResize issue. The output is as follows:

ArrayResize issue 

ArrayResize statement just has no effect. This was code that has been working for months prior to the latest update.

It's late and I'm tired, so hopefully I'm just missing something stupid here. 

 
   for (int i = 0; i < ArraySize(rates) - maPeriod; i++) {      
      //values[i].price = iMAOnArray(tempValues, 0, maPeriod, 0, maMethod, i);
      values[i].time = rates[ArraySize(rates) - 1 - i].time;
   }

I don't know anything about structs.

If you comment out the line as above, then the array will be resized.

I don't know if that gives you a clue to the problem. 

 

Thanks GumRai - isn't it strange though that commenting out a line of code after the resize statement can cause it to start working?

I also noticed the same myself when I commented out the last If statement in the GetCustomPeriodMovingAverageTrend method - the ArrayResize would suddenly work.

This makes me think this is some sort of compiler issue - I can't think of any other logical reason why commenting out code after the ArrayResize would have an effect on it.

 
This is a total pain in the ass. Even rewriting the method using the simplest code possible, with no includes, no structs - the code will work fine until some random point where I introduce a totally innocuous line of code, and then the ArrayResize command stops working. This has only started happening as of 890.
 
Ok will do, thanks for the links.
 

Excuse me for bringing this back up, but does anyone have any experience dealing with the helpdesk?

I raised the issue on Friday, no response, hasn't been picked up.

Thanks 

 

Similar bug here.

Gooly said he reported it too. 

 
Hoodlum:

Excuse me for bringing this back up, but does anyone have any experience dealing with the helpdesk?

I raised the issue on Friday, no response, hasn't been picked up.

Thanks 

Sometimes it takes over a year for them to react.
Reason: