let's say the value 100 in a variable and that variable is tied to the account number. is that possible?
the reason why i want to do that is because if my mt4 crashed and i need to restart my ea, all the variable value are gone
so if i can somehow store this value that is tied to my account number, then this issue is resolved
To obtain information about the current account there are several functions: AccountInfoInteger(), AccountInfoDouble() and AccountInfoString(). The function parameter values can accept values from the corresponding ENUM_ACCOUNT_INFO enumerations.
For the function AccountInfoInteger()
Account trade mode
Maximum allowed number of active pending orders
Mode for setting the minimal allowed margin
Allowed trade for the current account
Allowed trade for an Expert Advisor
Margin calculation mode
For the function AccountInfoDouble()
Account balance in the deposit currency
Account credit in the deposit currency
Current profit of an account in the deposit currency
Account equity in the deposit currency
Account margin used in the deposit currency
Free margin of an account in the deposit currency
Account margin level in percents
Margin call level. Depending on the set ACCOUNT_MARGIN_SO_MODE is expressed in percents or in the deposit currency
Margin stop out level. Depending on the set ACCOUNT_MARGIN_SO_MODE is expressed in percents or in the deposit currency
Initial margin. The amount reserved on an account to cover the margin of all pending orders
Maintenance margin. The minimum equity reserved on an account to cover the minimum amount of all open positions
The current assets of an account
The current liabilities on an account
The current blocked commission amount on an account
For function AccountInfoString()
Trade server name
Name of a company that serves the account
There are several types of
accounts that can be opened on a trade server. The type of account on
which an MQL5 program is running can be found out using the
In case equity is not enough for
maintaining open positions, the Stop Out situation, i.e. forced closing
occurs. The minimum margin level at which Stop Out occurs can be set in
percentage or in monetary terms. To find out the mode set for the
account use the ENUM_ACCOUNT_STOPOUT_MODE enumeration.
Account stop out mode in percents
Account stop out mode in money
for the OTC markets to interpret positions in the "netting" mode (only
one position can exist for one symbol). The margin is calculated based
on the symbol type (SYMBOL_TRADE_CALC_MODE).
for the exchange markets. Margin is calculated based on the discounts
specified in symbol settings. Discounts are set by the broker, but not
less than the values set by the exchange.
for the exchange markets where individual positions are possible
(hedging, multiple positions can exist for one symbol). The margin is
calculated based on the symbol type (SYMBOL_TRADE_CALC_MODE) taking into account the hedged margin (SYMBOL_MARGIN_HEDGED).
i am aware of those but they are predefined variable with predefined value. and you can only read them, can't write to it
what i need is the ability to store a value that is tied to the account
For the OP question this would be sufficient. But there could be situations when a client trades from different PCs and wants to have a centralized storage of some data (did you hear about synchronization between devices, which is very common today?). In case of MetaTrader the answer is no. The only shared storage is trading history.
Not sure it's a responsibility of Metaquotes to provide such storage. There is a lot of techniques already available and that can be used from MT4/MT5.