Download MetaTrader 5
To add comments, please log in or register
Have you published a program in the Market? Place it in your blog as well - the widget will help!
gangsta1
1117
gangsta1 2016.06.25 17:24 

If I use my EA on a broker with a license number greater than 10 it will not work. The EA calculates the license number by multiplying the mt4 account number and this value is then entered into a "LicenseNumber" field of the inputs. For some reason, if the calculation is greater than 10 digits it wont work. Any ideas how to make this work if the license number needs to be ? 10 digits?

If account number = 15588 and is multiplied by 3 the LicenseNumber would be 31375, this works fine.

If account number = 12345678910 and is multiplied by 3 the LicenseNumber would be 37037036730, this does not work. 10 digits for the license seems to be the limitation.

int acc=AccountNumber()*3; 
if (LicenseNumber != acc) //change to the password you give the user!
{
Alert ("Incorrect license number entered");
return (0);
}
peter.MT4Web
158
peter.MT4Web 2016.06.25 17:37  

Hi gangsta1!

You are right. But why are you working with int if this data-type is to small for your needs?



whroeder1
13610
whroeder1 2016.06.25 18:44  
gangsta1: 37037036730, this does not work. 10 digits for the license seems to be the limitation.
No, the maximum value of an int (2147483647) is your limitation.
Fernando Carreiro
1451
Fernando Carreiro 2016.06.25 20:01  

If "int" is too limiting for you, then use a "long". Make sure that both the variables "acc" and "LicenseNumber" are both "long":

input long LicenseNumber = 37037036730;

long acc = long( AccountNumber() ) * 3;

if( LicenseNumber != acc ) //change to the password you give the user!
{
   Alert ("Incorrect license number entered");
   return (0);
}

Alternatively use the following which returns a "long" version of the account number:

long acc = AccountInfoInteger( ACCOUNT_LOGIN ) * 3;
whroeder1
13610
whroeder1 2016.06.26 12:52  
FMIC: Alternatively use the following which returns a "long" version of the account number:
long acc = AccountInfoInteger( ACCOUNT_LOGIN ) * 3;

This is wrong. A int * int is an int. Then the result is expanded to a long. Same as double=int/int: On MT4 v434, division quotient don't give floating point values(Bug??) - MQL4 forum

One or the other must be lengthened, the other will automatically be.

long acc = AccountInfoInteger( ACCOUNT_LOGIN ) * Long(3);
Fernando Carreiro
1451
Fernando Carreiro 2016.06.26 13:11  
WHRoeder:

This is wrong. A int * int is an int. Then the result is expanded to a long. Same as double=int/int: On MT4 v434, division quotient don't give floating point values(Bug??) - MQL4 forum

One or the other must be lengthened, the other will automatically be.

@WHRoeder: For your information the "AccountInfoInteger()" function is defined as returning a "long" and not a "int", as mentioned in my post. So a "long * int" is a "long"! That is the main reason why I suggested it as an alternative.


FMIC:

Alternatively use the following which returns a "long" version of the account number:

long acc = AccountInfoInteger( ACCOUNT_LOGIN ) * 3;
long  AccountInfoInteger(
   int  property_id      // Identifier of the property
   );

ENUM_ACCOUNT_INFO_INTEGER

Identifier

Description

Type

ACCOUNT_LOGIN

Account number

long

whroeder1
13610
whroeder1 2016.06.26 18:44  
My mistake.
/
To add comments, please log in or register