You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
so doubletostring(1) now means the accountbalance at the end of the last trade?
no, you need to use OrderSelect() specified MODE_HISTORY on parameter in order to access the history pool. Then you can use as :
double my_balance_history = StringToDouble( OrderComment() );
no, you need to use OrderSelect() specified MODE_HISTORY on parameter in order to access the history pool. Then you can use as :
double my_balance_history = StringToDouble( OrderComment())
My code so far
does parameter 1 in OrderSelect()mean AccountBalance of the last trade
My code so far
does parameter 1 in OrderSelect()mean AccountBalance of the last trade
my idea is to differentiate between program for open the trades and read the history.
something like that for open the trades:
ones you have x trades, ex: 10 trades opened and closed, and stored in history automatically, use this script to read the history, and the accountBalance() when the trade were opened:
index, it depends on second parameter. https://docs.mql4.com/trading/orderselect
my idea is to differentiate between program for open the trades and read the history.
something like that for open the trades:
ones you have x trades, ex: 10 trades opened and closed, and stored in history automatically, use this script to read the history, and the accountBalance() when the trade were opened:
index, it depends on second parameter. https://docs.mql4.com/trading/orderselect
when I look in the journal when running the code it prints out that my_balance_history is 0
what is my_balance_history if it prints out 0?
thank you
Now how can I add the numbers stored in my_balance_history togheter?
thanks
Storing data in comments is bad practice, since comments can be overwritten by broker. I use this code to calculate historical balance - you can adopt it to work with x last trades instead of given date.
Storing data in comments is bad practice, since comments can be overwritten by broker. I use this code to calculate historical balance - you can adopt it to work with x last trades instead of given date.
I second this. Anything to do with order comments is almost guaranteed to fail. In order to track the account balance you just have to sort the orders by close time and then do the math backwards from the current balance.
how to get the account balance of the last 10 trades?
thank you
I appreciate this is an old post but I was looking for an account balance rollback function - I ended up writing this, so I am posting it in case it helps someone in future.
For the original query, It is easy to modify to rollback for the last 10 trades - just use the same approach and loop back by 10 tickets.
e.g. for(int i = dealEndPoint; i > (dealEndPoint-10); i--)
Your code is for MQL5, but you are posting it on a thread in the MQL4 section. Your code will be useless for MetaTrader 4 users and coders.
Thanks for pointing that out - I was not able to see it was a MQL4 thread, is there a way to identify this?
I can delete my post if you prefer