Current price from open order by ticket

 
Hello traders!

I need help for my code.

I need to get the current order price on the market, according to the ticket ...

This price:

this price




I attach a function that returns the number of the ticket I found here:

https://www.mql5.com/en/forum/109180

int LastOpenTicket___(int magic_number )
{// Function return TICKET NUMBER
    datetime lastTime  = 0;
    int      lastTicket = -1; // None open.
    double Current_price = 0.0;// I need this price from order ticket
    int pos = 0;
    for( pos = 0; pos <= OrdersTotal()-1 ; pos++ )
      
      if (
         OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
         &&  OrderMagicNumber()  == magic_number             // my magic number
      // &&  OrderSymbol()       == Symbol()               // and my pair.
         &&  OrderOpenTime()     >  lastTime 
         )
      
      {
         lastTime   = OrderOpenTime();
         lastTicket = OrderTicket();
      }
    

    return(lastTicket);
}



Thank you very much for replies :)


Selecting last order opened
Selecting last order opened
  • 2008.06.14
  • www.mql5.com
Hi I am a novice in MQL4 How can I select the last order opened ( in terms of orderopentime() ) when there are multiple orders opened...
 
microhyd:
Hello traders!

I need help for my code.

I need to get the current order price on the market, according to the ticket ...

This price:





I attach a function that returns the number of the ticket I found here:

https://www.mql5.com/en/forum/109180



Thank you very much for replies :)



*******************************************************


OK, problem solved!!! With this code:

    if(OrderSelect(lastTicket, SELECT_BY_TICKET)==true)

    {

     Print("order #symbol is ", MarketInfo(OrderSymbol(),MODE_ASK) );

    }   



Thanks for your time :)


 
microhyd:


*******************************************************


OK, problem solved!!! With this code:



Thanks for your time :)


That would only be applicable for SELL positions. Instead you could use the function OrderClosePrice() which returns the appropriate price for either. 

 
Thank you very much nicholi shen , work it perfectly with "OrderClosePrice()"! :)