Serious MT4 Bug Re GlobalVariables ??!!

 
While backtesting an EA on a real live (not demo) account using an EA reading/writing to the same Gobalvariables as the live EA....had the REAL account pick up the backtest globalvariables and trade based on backtesting values..instead of current actual values.... NOT GOOD!!
 
Check http://www.fx1.net/permvar.php in case you search alternatives. Can store strings and stores realtime systemwide. Means you can share variables among different terminals too.
 
n8937g:
While backtesting an EA on a real live (not demo) account using an EA reading/writing to the same Gobalvariables as the live EA....had the REAL account pick up the backtest globalvariables and trade based on backtesting values..instead of current actual values.... NOT GOOD!!

What portion of GLOBAL don't you understand. Global's allow mutlitple EA's to share, not a bug, it's by design.

Why are you using global variable if you do NOT want to share?

 

No, he is right... He meant that Global means "across EAs" but not "across EAs and backtester too".

There is a unique set of global variables, which is being accessed including from the Strategy Tester

I talked to Stanislav Starikov and he confirmed that MT5 will have a different set of global variables for the Strategy Tester, separate from the real global variables.

 

It's an issue that is easy to solve. See:


//inc the counter...

double counter=GlobalVariableGet("counter"+IsTesting());

counter=counter+1;

GlobalVariableSet("counter"+IsTesting(), counter);


So,

name of the variable in real trade is "counter0", but "counter1" for strategy tester... they do not overlap.


Even more, if you need a distinct set of variables for each currency, then...


double counter=GlobalVariableGet("counter"+Symbol()+IsTesting());

 
TheEconomist:

No, he is right... He meant that Global means "across EAs" but not "across EAs and backtester too".

There is a unique set of global variables, which is being accessed including from the Strategy Tester.

I talked to Stanislav Starikov and he confirmed that MT5 will have a different set of global variables for the Strategy Tester, separate from the real global variables.

Yes, Economist you are correct...actually the EA running in the backtester changed the GlobalVariables to values from a different day and the REAL LIVE EA picked them up and started placing trades (REAL TRADES)...when it should not.....Backtest GlobalVariables are not kept separately safely in a testing only environment ..




AbstractMind thank you.... yes I can write the code to have different Globalvariables if (Istesting()) ....It was just a real shock when all of a sudden my EA isn't acting like it should with real money....and

in the moment you don't understand where the problem could be. I had worked most of the weekend writing/re writing it and it backtested just fine on the weekend because no actual tics were on the real side.

Actually the Sunday start was very good but then I casually started backtesting and notice something wasn't right....

I think for the week I'll only test on Demo accounts that aren't forward testing too.

Thank you...

Reason: