Libraries: MT4Orders - page 2

fxsaber
20826
fxsaber  
HotFix! Please download the latest version.
Gad Benisty
1716
Gad Benisty  

This library is amazing!! So easy to run MT4 code in MT5. Thanks a lot

I have one issue the OrderTicket() function doesn't not return the right number when the trade is closed. This is a real problem to follow a trade when is closed.

For example a trade # 4584849 will become # 38484939 when closed.

Thanks in advance for your help

This is my code in a script:

#include <MT4Orders1.mqh>
void OnStart()
  {
int n=OrdersTotal();
//pLog(StringConcatenateV4("detectCloseTrade n=",n," ticket=",ticket));
   for(int i=n-1; i>=0; i--)
     {
      //---
      //if((ticket=HistoryOrderGetTicket(i))>0 && isMagic())
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderType()>=OP_BUY && OrderSymbol()==Symbol())
        {
         Print("MOH ",i, " ",OrderTicket());
        }
     }
  Print("History");
  n=OrdersHistoryTotal();
//pLog(StringConcatenateV4("detectCloseTrade n=",n," ticket=",ticket));
   for(int i=n-1; i>=0; i--)
     {
      //---
      //if((ticket=HistoryOrderGetTicket(i))>0 && isMagic())
      if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY) && OrderType()>=OP_BUY && OrderSymbol()==Symbol())
        {
         Print("MOH ",i, " ",OrderTicket());
        }
     }
}
fxsaber
20826
fxsaber  
It's not a issue. A closed position in MT5 has several tickets. They will all work through SELECT_BY_TICKET.
Perhaps you need OrderTicketID().
sisz1688
9
sisz1688  

for(int dfz_in_29=0 ; dfz_in_29<OrdersTotal() ; dfz_in_29 = dfz_in_29 + 1)

     {

      if(OrderSelect(dfz_in_29,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==Symbol())   

        {


         if(OrderType()==0)

           {

            dfz_in_12 = OrderTicket() ;  // the   OrderTicket() is no return value,  in demo , the value is  Error 4003 //    -2045194504  ? 



}}}



what about are this ...   please tell me  too :thanx very much ...

Keith Watford
Moderator
30433
Keith Watford  
sisz1688:

Please edit your post and use the code button (Alt+S) when pasting code.

EDIT your original post, please do not just post the code correctly in a new post.