"global initialization failed"

 

Does anyone know what could cause the "global initialization failed" error message

 
James Cater: Does anyone know what could cause the "global initialization failed" error message
Likely bad parameter settings, but could be anything the code checks for. Post your code (using SRC)
 
whroeder1:
Likely bad parameter settings, but could be anything the code checks for. Post your code (using SRC)

Thanks for the response.

The code doesn't produce this error when built locally or when the ex4 was submitted to the Marketplace and tested by the validation team.

It only stated happening on Sunday 20th March 2017 to the ex4 that the Marketplace creates when you download the demo or purchase the product. Users that downloaded the identical product before Sunday are not affected.

We can't put the entire source code here, we just wanted to know what can cause these errors so we can look around for anything suspicious in our codebases

(Yes this issue has been raised with the service desk, but I wanted to get ahead of the game if there is a hidden coding issue)

 

It was a bug, which is reportedly fixed (see russian forum).

Solution: Delete the downloaded file and download it again.

Forum on trading, automatic trading systems and testing trading strategies

880 MT4: global initialization failed RESOLVED

Vladislav Andrushchenko , 2015.09.24 10:48

and what to do? just run the expert?

Simply restart the terminal - is not working.

zanogo plotted - does not work

I found a solution:

  • Removed from the list of the market expert.
  • Transferred in the Market tab in the terminal -
  • knitted and updated version of all the app worked. Thank you.



 
James Cater:

Does anyone know what could cause the "global initialization failed" error message

"global initialization failed" is related to all what is initialized BEFORE OnInit(), so global and static variables or constants.
 
whroeder1:
  1. Didn't ask you to.
  2. What part of "the code checks for" was unclear? Those are in OnInit.
  3. Why aren't you Printing the reason you return INIT_FAILED

It doesn't even get to the OnInit() method. I think you are confusing "init failed" with "global initialization failed"

INIT_FAILED  produces the following messages

   2017.03.21 15:26:24.478 Blahtech Supply Demand EURAUD,M30: uninit reason 8

   2017.03.21 15:26:24.478 Blahtech Supply Demand EURAUD,M30: initialization failed (1)"

Whereas we are seeing

  2017.03.21 15:30:13.972 Blahtech Supply Demand EURAUD,M30: global initialization failed


As Alain states, I think this is happening during the initialisation of global variables before any processing starts

Here are the only global variables that get initialised ....

double
GetDesktopScaling()
{
   int    desktopScreenDpi = TerminalInfoInteger(TERMINAL_SCREEN_DPI);
   double ret = desktopScreenDpi > 96.0 ? desktopScreenDpi / 96.0 : 1.0;

   //Print("Hello TERMINAL_SCREEN_DPI=", TERMINAL_SCREEN_DPI, " TerminalInfoInteger(TERMINAL_SCREEN_DPI)=", TerminalInfoInteger(TERMINAL_SCREEN_DPI), " ret=", ret);
   
   return ret;
}

int       ExtChartWindowId = ChartWindowFind();
int       ExtChartScale = (int)ChartGetInteger(0, CHART_SCALE);
color     ExtBackgroundColour = (color)ChartGetInteger(0, CHART_COLOR_BACKGROUND);
long      ExtChartWidthPixels = ChartGetInteger(0, CHART_WIDTH_IN_PIXELS);
long      ExtChartHeightPixels = ChartGetInteger(0, CHART_HEIGHT_IN_PIXELS);
double    ExtDesktopScaling = GetDesktopScaling();
datetime  ExtBacktestLastEventTime = TimeLocal();
 
James Cater:

It doesn't even get to the OnInit() method. I think you are confusing "init failed" with "global initialization failed"

INIT_FAILED  produces the following messages

   2017.03.21 15:26:24.478 Blahtech Supply Demand EURAUD,M30: uninit reason 8

   2017.03.21 15:26:24.478 Blahtech Supply Demand EURAUD,M30: initialization failed (1)"

Whereas we are seeing

  2017.03.21 15:30:13.972 Blahtech Supply Demand EURAUD,M30: global initialization failed


As Alain states, I think this is happening during the initialisation of global variables before any processing starts

Here are the only global variables that get initialised ....

Perhaps because you are using TimeLocal(), so it does not match with the Server Time or TimeCurrent() on Sunday.
 
Stanislav Korotky:

It was a bug, which is reportedly fixed (see russian forum).

Solution: Delete the downloaded file and download it again.


This workaround no longer works. The ex4 created by MetaTrader 4 from 20th March 2017 are now failing whereas the same ex4 downloaded last week work as expected.

They must have made a change to the ex4 delivery process over the weekend

 
Roberto Jacobs:
Perhaps because you are using TimeLocal(), so it does not match with the Server Time or TimeCurrent() on Sunday.

I wouldn't expect to get anything sensible from TimeCurrent but TimeLocal is a system call and should be available at startup.

However in the future I can delay the initialisation of these variables (but this shouldn't really be necessary)

 
James Cater:

I wouldn't expect to get anything sensible from TimeCurrent but TimeLocal is a system call and should be available at startup.

However in the future I can delay the initialisation of these variables (but this shouldn't really be necessary)

Whatever the TimeLocal(), when trading should be adjusted and followed with a time server.
 
Roberto Jacobs:
Whatever the TimeLocal(), when trading should be adjusted and followed with a time server.

I'm using TimeLocal to measure the exact time from startup. I'm not interested in the Server time and it really doesn't need to be adjusted.