Features of the mql5 language, subtleties and tricks - page 179

 
Konstantin Nikitin:

As an option.

Not working.

 
fxsaber:

Not working.

Seems to have reloaded the terminal expert remained. When I changed the account I deleted it from the chart. The only thing I have to play with the global name for each variant of the Expert Advisor. It is possible to add it to the name of char. I have not bothered with it.

 
Konstantin Nikitin:

I think I overloaded the terminal and the expert stayed. When I changed the account I deleted it from the chart... The only thing I have to play with the global name for each variant of the Expert Advisor. I can add it to the name of char. I have not bothered with it.

It needs the Expert Advisor to work on a non-working chart. And we offer options with working schedule.

 
Konstantin Nikitin:

I think I overloaded the terminal and the expert stayed. When I changed the account I deleted it from the chart... The only thing I have to play with the global name for each variant of the Expert Advisor. I can add it to the name of char. I have not bothered with it.

  1. Open demo on ForexTimeFXTM-Demo01.
  2. Run the Expert Advisor on Brent symbol.
  3. Switch to MQ-Demo.
  4. Use PKM in Experts menu to see if Expert Advisor is running or not.
 
fxsaber:

  1. Open demo on ForexTimeFXTM-Demo01.
  2. Run the Expert Advisor on Brent symbol.
  3. Switch to MQ-Demo.
  4. Use the PCM in the Experts menu to see if the Expert Advisor is hanging or not.


fxsaber:

In general, calling ExpertRemove on REASON_ACCOUNT is an absolutely meaningless thing.


Checked it, I think it's even sadder, even critical errors don't unload my EA

const long login = AccountInfoInteger(ACCOUNT_LOGIN);
//+------------------------------------------------------------------+
int OnInit()
{
   Print(__FUNCTION__);
   Print("_StopFlag = ",_StopFlag);
   Print("_UninitReason = ",_UninitReason);
   Print("login = ",login);
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
   Print(__FUNCTION__);
   Print("_StopFlag = ",_StopFlag);
   Print("_UninitReason = ",_UninitReason);
   Print("login = ",login);
   if(_StopFlag && _UninitReason == 6) {int i=1; int j = 10/--i;}
}
//+------------------------------------------------------------------+

but the global scope is completely wiped when the account is changed

2020.05.21 14:30:17.303 tst1 (EURUSD,H1) OnDeinit

2020.05.21 14:30:17.303 tst1 (EURUSD,H1) _StopFlag = 1

2020.05.21 14:30:17.303 tst1 (EURUSD,H1) _UninitReason = 6

2020.05.21 14:30:17.303 tst1 (EURUSD,H1) login = 21796970

2020.05.21 14:30:17.303 tst1 (EURUSD,H1) zero divide in 'tst1.mq5' (25,60)

2020.05.21 14:30:17.373 Experts automated trading is disabled because the account has been changed

2020.05.21 14:30:17.797 tst1 (EURUSD,H1) OnInit

2020.05.21 14:30:17.797 tst1 (EURUSD,H1) _StopFlag = 0

2020.05.21 14:30:17.797 tst1 (EURUSD,H1) _UninitReason = 0

2020.05.21 14:30:17.797 tst1 (EURUSD,H1) login = 500030706

2020.05.21 14:30:24.492 Experts automated trading is enabled

 
Igor Makanu:

Checked it, I think it's even sadder, even the critical errors don't unload my EA

but the global scope gets completely wiped when I change the account

Everything works logically there (but awkward in places). You just need to understand the mechanism.

 
fxsaber:

Everything works logically there (but awkwardly in places). You just need to understand the mechanism.

Well, the mechanism is in the help, but the help does not take into account all cases in work - this information was given by the administrator, but then the moderator was involved and the two of them came to the verdict - you are delusionalhttps://www.mql5.com/ru/forum/334269/page53#comment_16412120


give the mechanism, the help was powerless ;)

 
Igor Makanu:

give mechanism, help was powerless ;)

WhenREASON_ACCOUNT(even if the account is not changed, just re-logged), the EA is completely unloaded and a new copy is loaded.

For this reason, ExpertRemove in OnDeinit has no effect on the new copy, as it concerns the unloaded one.


If the symbol is missing, the new copy is loaded without any execution.

And the problem was to unload a new copy which is hanging, but not running.


A hanging copy means that if there is a switch to another account where there is a symbol, the EA will start.

 
fxsaber:

Why unload it if it doesn't work at all?

 
Andrey Khatimlianskii:

And why unload it if it doesn't work at all?

There should be full control.