GlobalVariables disappear?

 

Hi,

I just have recognized that a list of global variables (GlobalVariableSet(..)) disappear?

At least as soon as I start the debugger the whole list is wiped out - before my code tries to request the variables or their values?

Does anybody what I can do??

Thanks in advance!

Gooly

 
Shouldn't be:
When testing and optimizing the Expert Advisors that use global variables, keep in mind that client terminal and the Strategy Tester share common global variables. Therefore, the names of the global variables must be different from the names of the global variables used by other mql4 programs. Otherwise, it may lead to incorrect work of mql4 programs and inaccurate testing results. -- Global Variables of the Client Terminal - MQL4 Documentation
 

Well I now found out it is not the debugger!

Just requesting one variable wipes out all - useful feature!

This is set by my script:


Now my EA wants to request the first two variables like:

   globNameRiskAcct = "PTC Risk Acct:"+(string)AccountNumber();
   globNameRiskMagi = "PTC Risk Magi:-548436835";
   
   bool a = GlobalVariableCheck(globNameRiskAcct),
        b = GlobalVariableCheck(globNameRiskMagi),
        c = (a) ? GlobalVariableGet(globNameRiskAcct,AccWeight) : false,
        d = (b) ? GlobalVariableGet(globNameRiskMagi,MagWeight): false;
..


After this little bit of code the List of global variables looks like:



Does this happen to anybody else?

Gooly

 
gooly: Does this happen to anybody else?

  1. I ran this script and had no problem. You must be deleting variables elsewhere.
    void OnStart(){  
    string   globNameRiskAcct = "A1";   double AccWeight;
    string   globNameRiskMagi = "B2";   double MagWeight;
       
       bool a = GlobalVariableCheck(globNameRiskAcct),
            b = GlobalVariableCheck(globNameRiskMagi),
            c = (a) ? GlobalVariableGet(globNameRiskAcct,AccWeight) : false,
            d = (b) ? GlobalVariableGet(globNameRiskMagi,MagWeight): false;
    PrintFormat("a=%i, b=%i c=%i, d=%i, aw=%f, mw=%f", a,b,c,d, AccWeight, MagWeight);
    
    2015.07.14 13:16:17.404    tests EURUSD,H1: uninit reason 0
    2015.07.14 13:16:17.404    tests EURUSD,H1: a=1, b=1 c=1, d=1, aw=1.000000, mw=2.000000
  2. Build 840
 

I found it:

A function called in OnDeInit() contains GlobalVariablesDeleteAll() that deletes all global variables.

But now I don't understand why the global variables were deleted at the start of this EA and before OnInit() was executed?

OnDeInit() shouldn't have been touched at all at this moment!

Thank you!

Gooly

Reason: