How select last order for one symbol in the history and get value of lots and profit?
Thank you
How select last order for one symbol in the history and get value of lots and profit?
Thank you
https://www.mql5.com/en/docs/trading/historyordergetinteger
https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties
https://www.mql5.com/en/docs/constants/tradingconstants/positionproperties
https://www.mql5.com/en/docs/trading/historyordergetdouble
ENUM_ORDER_PROPERTY_DOUBLE
Identifier |
Description |
Type |
ORDER_VOLUME_INITIAL |
Order initial volume |
double |
ORDER_VOLUME_CURRENT |
Order current volume |
double |
ORDER_PRICE_OPEN |
Price specified in the order |
double |
ORDER_SL |
Stop Loss value |
double |
ORDER_TP |
Take Profit value |
double |
ORDER_PRICE_CURRENT |
The current price of the order symbol |
double |
ORDER_PRICE_STOPLIMIT |
The Limit order price for the StopLimit order |
double |

- www.mql5.com
For example, a hedge account in MetaTrader 5:
How select last order for one symbol in the history and get value of lots and profit?
Thank you
Please specify which is your target language as i see most of your previous questions were MQL4.
In that case its
OrdersHistoryTotal()

- docs.mql4.com
Order? Deal or Position?
I did. It's working
void OnStart() { datetime dia=TimeCurrent(); MqlDateTime diamqldate; TimeToStruct(dia,diamqldate); datetime auxhora; MqlDateTime auxhoramqldate; double auxprofit,lot; diamqldate.mon=diamqldate.mon-1; if(diamqldate.mon==0){ diamqldate.mon=12; diamqldate.year=diamqldate.year-1; } diamqldate.hour=-1; diamqldate.min=-1; diamqldate.sec=-1; for(int i=OrdersHistoryTotal();i>=0;i--){ if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)){ if(OrderType()==OP_SELL || OrderType()==OP_BUY){ if(OrderSymbol()==Symbol()){ auxhora=OrderCloseTime(); TimeToStruct(auxhora,auxhoramqldate); if(auxhoramqldate.year > diamqldate.year || auxhoramqldate.year==diamqldate.year ){ if(auxhoramqldate.mon > diamqldate.mon || auxhoramqldate.mon == diamqldate.mon){ if(auxhoramqldate.day > diamqldate.day || auxhoramqldate.day== diamqldate.day){ if(auxhoramqldate.hour > diamqldate.hour || auxhoramqldate.hour==diamqldate.hour){ if(auxhoramqldate.min > diamqldate.min || auxhoramqldate.min == diamqldate.min){ if(auxhoramqldate.sec > diamqldate.sec || auxhoramqldate.sec ==diamqldate.sec){ auxprofit=OrderProfit(); lot=OrderLots(); diamqldate.year=auxhoramqldate.year; diamqldate.mon=auxhoramqldate.mon; diamqldate.day= auxhoramqldate.day; diamqldate.hour=auxhoramqldate.hour; diamqldate.min=auxhoramqldate.min; diamqldate.sec=auxhoramqldate.sec; } } } } } } } } } } Alert("profit",auxprofit); //TEST Alert("lot",lot); //TEST
I did. It's working


- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
How select last order for one symbol in the history and get value of lots and profit?
Thank you