Keith Watford:
No, you will need to loop through all history orders and check for the one with the latest OrderCloseTime() and get its profit.
No, you will need to loop through all history orders and check for the one with the latest OrderCloseTime() and get its profit.
Oh, really? Thanks. Need to use loos.
Do I need to use OrderCloseTime? How can I know the newest one?
OrderSelect(var *****
This var number's biggest one is the newest closed order?? Not true?
kajironpu:
Oh, really? Thanks. Need to use loos.
Do I need to use OrderCloseTime? How can I know the newest one?
This var number's biggest one is the newest closed order?? Not true?the one with the latest (largest) OrderCloseTime()
This function give you the last profit/loss. Optionally you can filter by a Magic Number and/or a Symbol.
double LastProfit(const int magicNumber=EMPTY,const string symbol=NULL) { datetime lastTradeClose=0; double lastProfit=0.0; int count=OrdersHistoryTotal(); for(int i=0;i<count;i++) { if(!OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) continue; if((magicNumber==EMPTY || magicNumber==OrderMagicNumber()) && (symbol==NULL || symbol=="" || StringCompare(symbol,OrderSymbol(),false)==0) && OrderType()<OP_BUYLIMIT && OrderCloseTime()>lastTradeClose) { lastTradeClose=OrderCloseTime(); lastProfit=OrderProfit()+OrderCommission()+OrderSwap(); } } return(lastProfit); }

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
I want to know the profit for the last order.
The last (newest) closed order number is
Is this correct?
So, I coded like; I think I don't need to use FOR function because I just want to know the last (newest order information only).
It this true?