All my global variables of my other non SQX EA that had a "_" in the title disappeared and I think I see why....
if(GlobalVariableCheck(variableName)){ int endPos = StringFind(variableName, "_"); if(endPos <= 0) continue;
Any global with a _ in the name will not do the continue so it will carry on...
bool variableUsed = false; for(int i=0; i < OrdersTotal(); i++) { if(OrderSelect(i, SELECT_BY_POS) == true) { if(OrderTicket() == ticketNo){ variableUsed = true; break; } } }
Only if the name matches the ticket will variableUsed be true.
if(!variableUsed){ if(GlobalVariableDel(variableName)){ deletedCount++; }
This will delete any global variables at all unless they are for an open position of only this EA!!!
Do we really need to delete them? They expire after a couple weeks I believe. If we really need to keep them clean then you will have to incorporate the magic number in to the title and check for that instead of just checking for the _ character!
Subject changed from Global Variables of other EA being deleted by the sqx mql4 code to sqx EA deleting each others Global Variables if running more than one sqx EA on one account. Looks like GV are critical for many functions!
if(!IsTesting() && !IsOptimization()) { initTimer(); }
This will prevent the timer from being set which in turn will prevent the GV from being deleted of other EA. The GV will eventually expire anyways.
for(int i=0; i < OrdersTotal(); i++)
We are checking the entire account for open orders, not just the EA orders. Therefore we aren't deleting other sqx ea GV after all.
We are deleting other non sqx EA GV though if they contain a "_" .
Subject changed from sqx EA deleting each others Global Variables if running more than one sqx EA on one account. Looks like GV are critical for many functions! to sqx EA deleting other EA Global Variables
Status changed from New to Fixed
So other EA's variables will remain untouched and each SQ EA will delete only old variables of its own.
Looping should not be very resource intensive as we are checking only pending orders and active positions and the checking interval is approximately 1 day.