Hello there!tell me how to write it correctly) so that if the account number does not match when dragging the expert Advisor to the chart,then it gives an error and is not placed on the chart?)
void OnTick()
{
int Number = AccountNumber(); / / get the account number
if (Number != 602202) / / compare it with the given one, and if not equal,
{
Comment("work on the account ", Number," prohibited!"); / / display a comment about the work ban
}
return(INIT_FAILED);
}
/ / ... further code of the expert Advisor
malishko89
Thanks).I will understand)
iks_
//+--------------------------------------------------------------------------------+ EXTERNAL INPUTS +---------------+
//| Expert Check Account owner function |
//+------------------------------------------------------------------+
bool ExpCheckUser(void)
{
if((long)AccountInfoInteger(ACCOUNT_TRADE_MODE) != ACCOUNT_TRADE_MODE_REAL)
return false;
if((int)AccountInfoInteger(ACCOUNT_LOGIN) != 123456)
return false;
if(AccountInfoString(ACCOUNT_NAME) != "Xxxx Xxxxx Xxxx")
return false;
return true;
}
//--- Add "extern " before each parameter to get them in the inputs tab
void OnInit(void)
{
if(!ExpCheckUser())
ExpertRemove();
}
malishko89
did exactly the same, the expert Advisor is dragged to the chart.. and smiles)
why?if acc_login I don’t have 123456…
prostotrader
Raise return(INIT_FAILED);
on the line above (immediately after the Comment)
I would also add the account owner (I still have a demo or real) MT5
//| Expert Check Account owner function |
//+------------------------------------------------------------------+
bool ExpCheckUser()
{
long acc_login = long(AccountInfoInteger(ACCOUNT_LOGIN));
string acc_user = AccountInfoString(ACCOUNT_NAME);
long acc_real = AccountInfoInteger(ACCOUNT_TRADE_MODE);
if(acc_real == ACCOUNT_TRADE_MODE_REAL)
{
if ((acc_login == 123456) && ( acc_user == "Xxxx Xxxxx Xxxx")) return(true);
}
return(false);
}