[128] MT4 deletes GlobalVariables from other EAs

I found an old task addressing this issue  in the past that was fixed. Again, current build 128 deletes all GlobalVariables even from other software using following code:


void OnTimer(){    //clear unused variables    int deletedCount = 0;    VerboseLog("Clearing variables...");       for(int a=GlobalVariablesTotal() - 1; a>=0; a--){       string variableName = GlobalVariableName(a);       if(GlobalVariableCheck(variableName)){          int endPos = StringFind(variableName, "_");          if(endPos <= 0) continue;          int ticketNo = StrToInteger(StringSubstr(variableName, 0, endPos));          bool variableUsed = false;                   for(int i=0; i < OrdersTotal(); i++) {             if(OrderSelect(i, SELECT_BY_POS) == true) {                if(OrderTicket() == ticketNo){                   variableUsed = true;                   break;                }             }          }                ResetLastError();                   if(!variableUsed){             if(GlobalVariableDel(variableName)){                deletedCount++;             }             else {                VerboseLog("Cannot delete variable. Error code: ", GetLastError());             }          }       }    }    VerboseLog(IntegerToString(deletedCount), " variables cleared"); }



I suggest using this code for creating GV

//+------------------------------------------------------------------+ void sqSetGlobalVariable(int ticket, string name, double value) {    GlobalVariableSet(CustomComment+ (IsTesting()?"_test_":"_") + ticket+"_"+name, value); } //+------------------------------------------------------------------+



And the following code to delete them

GlobalVariablesDeleteAll(CustomComment + (IsTesting()?"_test":"_"));




Attachments
No attachments
  • Votes 0
  • Project StrategyQuant X
  • Type Bug
  • Status Fixed
  • Priority Normal

History

FM
#1

Aimak_Rokalno

01.06.2020 23:18

Task created

TB
#2

Tomas Brynda

12.06.2020 12:52

Status changed from New to Fixed


Votes: 0

Drop files to upload

or

choose files

Max size: 5MB

Not allowed: exe, msi, application, reg, php, js, htaccess, htpasswd, gitignore

...
Wait please