sqx EA deleting other EA Global Variables

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! 

Attachments
No attachments
  • Votes +2
  • Project StrategyQuant X
  • Type Bug
  • Status Fixed
  • Priority High

History

b
#1

bentra

12.07.2019 03:39

Task created

b
#2

bentra

12.07.2019 03:39
Voted for this task.
b
#3

bentra

12.07.2019 03:55
This means you can't run two or more sqx generated EA on the same account without being effected by this bug btw!


b
#4

bentra

13.07.2019 03:36

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!

b
#5

bentra

13.07.2019 14:33
To be clear this bug will cause an EA back-test to behave differently from the same EA on a live account. If you happen to have more than one EA on one account, they interfere with each other. Many of the sqx ea functions seem to be reliant on global variables but when you have more than one EA on an account then they (occasionally – once randomly every 20+ hours per EA) delete each others GV. GV seem to be used for important functions such as trailing stop and timed exits! How frequently such interference happens depends on how many EA you have on one account…
b
#6

bentra

13.07.2019 14:47
Temporarily, I suggest we remove this:



   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.

b
#7

bentra

13.07.2019 17:05
It seems to make more sense to reverse the  "!IsTesting() && !IsOptimization()" logic in this condition. Maybe SQ team meant to clean GV during testing to reduce memory usage during testing. Maybe the SQ team didn't mean to clean GV on a live account because they will expire naturally on a live account anyways. Maybe the SQ team didn't mean to clean the GV on a live account because the cleaning function is deleting all the other EA GV. If all this is true then that logic should be reversed. As it is right now we ONLY clean GV during live usage and not during testing....
m
#8

mabi

13.07.2019 17:14
Voted for this task.
b
#9

bentra

13.07.2019 17:30
oops false alarm!


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 "_" .

b
#10

bentra

13.07.2019 17:32

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

b
#11

bentra

14.07.2019 22:42
It does seem resource intensive to cycle through all the potential 1000's of orders of the entire terminal WITHIN another loop that is cycling through potentially hundreds of GV...

Why not use static GV names like for instance if magicnumber is 1234:
SQX_1234_01_ticket=0031
could store a ticket number of a current tracked order
SQX_1234_01_ExitAfterBars=16
could store variables of the order this way.
SQX_1234_02_ticket=0032
could store a second ticket number for a second tracked order etc. etc.

We can avoid the giant loop inside the giant loop, avoid potentially accidentally deleting other GV because of bugs.
TB
#12

Tomas Brynda

05.08.2019 16:05

Status changed from New to Fixed

I modified the global variables checking. Random 8 character string ID is generated into strategy's MQL code and this ID prefixed with "sq" is then checked when looping through variables.

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.


Votes: +2

Drop files to upload

or

choose files

Max size: 5MB

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

...
Wait please