dolar:
Hi Guys,
Do you have any idea how to check profit for all closed EURUSD positions from current day?
Loop through all the closed positions, OrderSelect() them one by one, check their OrderSymbol() if it matches EURUSD and their OrderOpenTime() is from today keep a running total of OrderProfit(), DONE.
Hi Guys,
Do you have any idea how to check profit for all closed EURUSD positions from current day?
The code below returns only last closed order profit.
I make deals on EURUSD and EURJPY, but need only calculate profit for one instrument (EURUSD).
something like this?
for(int i=(OrdersHistoryTotal()-1);i>=0;i--) { OrderSelect(i, SELECT_BY_POS,MODE_HISTORY); if(OrderSymbol()==Symbol() && (TimeToStr(OrderCloseTime(),TIME_DATE))==(TimeToStr(TimeCurrent(),TIME_DATE))) { Print(OrderProfit()); break; } }
OrderSelect(i, SELECT_BY_POS,MODE_HISTORY);
What are Function return values ? How do I use them ? - MQL4 forum(TimeToStr(OrderCloseTime(),TIME_DATE))==(TimeToStr(TimeCurrent(),TIME_DATE)
Do you really think you must convert datetimes to strings in order to compare them? Do you really think that the last order will always have the same hour:minute was current time? What if the order closed 12:01:59 and now is 12:02:00?
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
Do you have any idea how to check profit for all closed EURUSD positions from current day?
The code below returns only last closed order profit.
I make deals on EURUSD and EURJPY, but need only calculate profit for one instrument (EURUSD).