Dear friends/comrades,
I have the following line of code to show my equity balance at the present moment (live). But I would like to have the equity balance from point of time in the past (example: yesterday's close). How can I get the equity balance with a parameter such as a date and time ?
Do you want to capture it in real-time and re-use it later, or are you saying you want to derive what it was at a prior datetime?
Dear friends/comrades,
I have the following line of code to show my equity balance at the present moment (live). But I would like to have the equity balance from point of time in the past (example: yesterday's close). How can I get the equity balance with a parameter such as a date and time ?
You have to understand the difference between balance and equity (balance +/- open positions) and - why not - the meaning of the margin.
The historical balances are not recorded by the terminal, so you have to take the actual balance and loop through all deals and subtract amounts that increase the balance and add amounts that reduced the balance from now back to the moment you'd like to know.
You have to understand the difference between balance and equity (balance +/- open positions) and - why not - the meaning of the margin.
The historical balances are not recorded by the terminal, so you have to take the actual balance and loop through all deals and subtract amounts that increase the balance and add amounts that reduced the balance from now back to the moment you'd like to know.
Yes, exactly why I wanted to know what the OP was after.
Nevertheless if they are after historic balance, there is some code here which may help - not sure if it can be modified for equity... have not tried
https://www.mql5.com/en/forum/302805/page2#comment_23774890
![accoount balance history - How can I read the account balance of your last 10 trades? accoount balance history - How can I read the account balance of your last 10 trades?](https://c.mql5.com/36/57/accoount-balance-history-how-can.jpg)
- 2019.02.17
- www.mql5.com
Capture it when you will need it, or compute it. Balance(at time t) equals Balance(now) minus all closed orders profits(from t to now).
MT5:
Retrieving History Positions - General - MQL5 programming forum #3 (2020)MT4:
Do not assume history has only closed orders.
OrderType() == 6, 7 in the history pool? - MQL4 programming forum (2017)Do not assume history is ordered by date, it's not.
Could EA Really Live By Order_History Alone? (ubzen) - MQL4 programming forum (2012)
Taking the last profit and storing it in a variable | MQL4 - MQL4 programming forum #3 (2020)Total Profit is OrderProfit() + OrderSwap() + OrderCommission(). Some brokers don't use the Commission/Swap fields. Instead, they add balance entries. (Maybe related to Government required accounting/tax laws.)
"balance" orders in account history - Day Trading Techniques - MQL4 programming forum (2017)
Broker History FXCM Commission - <TICKET>
Rollover - <TICKET>>R/O - 1,000 EUR/USD @0.52 #<ticket> N/A OANDA Balance update
Financing (Swap: One entry for all open orders.)
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Dear friends/comrades,
I have the following line of code to show my equity balance at the present moment (live). But I would like to have the equity balance from point of time in the past (example: yesterday's close). How can I get the equity balance with a parameter such as a date and time ?