Do index of HistoryDealGetTicket(index) is sort by HistoryDeal open time?
or close time?
if i use HistoryDealGetTicket(0) , then it will select the latest one or oldest deal?
what the rules with the index , it is descenting with the deal open time ?
if I want to get last 5 deals' profit, how to obtain them?
THANKS
HistoryDealsGetTicket(index) should not be used as a stand alone call. As used in this example https://www.mql5.com/en/docs/trading/historydealgetticket , the index is sorted by ascending deals.
Here is example to find elapsed open deal time of last deal in an open position.
//+------------------------------------------------------------------+ //| return elapsed time for last deal in current open position | //+------------------------------------------------------------------+ datetime LastDealElapsedTime() { uint pos_total=0; uint total=0; long pos_id=0; ulong HTicket=0; datetime ETime=LONG_MAX; pos_total=PositionsTotal(); if(pos_total>0) { // continue if current open position if(PositionSelect(Symbol())) // continue if open position is for chart symbol { pos_id=(ENUM_POSITION_PROPERTY_INTEGER)PositionGetInteger(POSITION_IDENTIFIER); HistorySelectByPosition(pos_id); total=HistoryDealsTotal(); HTicket=HistoryDealGetTicket(total-1); // get ticket number for last deal in position if(HTicket>0) ETime=TimeCurrent()-HistoryDealGetInteger(HTicket,DEAL_TIME); return(ETime); } } return(0); }
- www.mql5.com
HI, wackena
DO U MEAN THAT
FOR HistoryDealGetTicket (index)
THE BIGGER OF IN DEX IS , THE SMALLER OF ORDER SETUP TIME IS ?
SMALLER OF ORDER SETUP TIME = older ORDER
- www.mql5.com
HI, wackena
DO U MEAN THAT
FOR HistoryDealGetTicket (index)
THE BIGGER OF IN DEX IS , THE SMALLER OF ORDER SETUP TIME IS ?
SMALLER OF ORDER SETUP TIME = older ORDER
![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
Do index of HistoryDealGetTicket(index) is sort by HistoryDeal open time?
or close time?
if i use HistoryDealGetTicket(0) , then it will select the latest one or oldest deal?
what the rules with the index , it is descenting with the deal open time ?
if I want to get last 5 deals' profit, how to obtain them?
THANKS