Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1314

 
ponochka:
to understand what's out there
bool VerifityToSchet()
  {
        Print((string)AccountNumber()+" = "+(string)account);
   if(AccountNumber() != account)
     {
      Print("На данном счете индикатор работать не будет, вы его приобрели незаконным путем!!!");   
     }else
     {
     Print("На данном счете индикатор авторизован");
     }
   return(false);
  } 
 
Pavel Kolchin:
to see what is there

when restarting the terminal, the consoleAccountNumber() receives 0, but the terminal itself loads under the account and works

 
ponochka:

when restarting the terminal, the consoleAccountNumber() receives 0, but the terminal itself loads under the account and works

Bolly, you're writing in the wrong place.

 
ponochka:

When restarting the terminal, the consoleAccountNumber() receives 0, but the terminal itself is loaded under the account and works

Account data, balance, etc. are not able to get actual information from the server -init() works before the terminal receives values from the server.

 
Vitaly Muzichenko:

Account data, balance, etc. do not have time to get up-to-date information from the server -init() works before the terminal receives values from the server.

Good! Fixed! It works! And here is another important question:

There is a check for the account on the indicator! It stands and works in the terminal, but at a certain moment the user manually changes the account, according to the rules of check the indicator should argue that the account is wrong, but it does nothing and can continue working until you change its settings, even after the restart of the terminal! How can I fight this?

 
ponochka:

All right! Fixed it! It's working! And here's another burning question:

There is an account check on the indicator! It stands and works in the terminal, but at a certain moment the user manually changes the account, according to the rules of check the indicator should argue that the account is wrong, but it does nothing and can continue working until you change its settings, even after the restart of the terminal! How do I fight this?

Something is not written correctly

P.S. Try unprinting Print( AccountNumber() ); what will it show when the account changes? But not in the iniit understandable
 

Hi there!

In the book on MT4 in one of the tasks is written: that to determine whether there is a new bar, compare the opening price of zero bar with a bar number 1 (ie, if the opening price has changed and a new bar appeared) used this method, but ran into a skip messages in the tester, started to understand, and remembered that - several bars may have the same opening price and therefore this method can lead not only to errors but losses respectively. Be careful and use not the opening price but time or other methods!!!

 
Roni Iron:

Hi there!

In the book on MT4 in one of the tasks is written: that to determine whether there is a new bar, compare the opening price of zero bar with bar number 1 (ie, if the opening price has changed and a new bar appeared) used this method, but ran into a skip messages in the tester, started to understand, and remembered that - several bars can have the same opening price and therefore this method can lead not only to errors but losses respectively. Be careful and use not the opening price but time or other ways!!!

iTime

 
Vitaly Muzichenko:

Something is not written correctly.

P.S. Try unprinting Print( AccountNumber() ); what will it show when the account changes? But not in the init understandable

shows the new (changed) account, but nothing else happens

 
ponochka:

All right! Fixed it! It's working! And here's another burning question:

There is an account check on the indicator! It stands and works in the terminal, but at a certain moment the user manually changes the account, according to the rules of check the indicator should argue that the account is wrong, but it does nothing and can continue working until you change its settings, even after the restart of the terminal! How do I fight this?

i have this problem in MT4, i don't know if when oninit triggers after account switching the account number has not had time to update in the environment or some other bug, i decided to use timer

void  OnTimer()

       {

        static long account=AccountNumber();

        if(AccountNumber()!=account)

         {
                
            Print(account," was");
            account=AccountNumber();
            Print(account," now");
		 Полундра и т.п. }}