Current price from open order by ticket

To add comments, please log in or register
microhyd
35
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:

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
35
microhyd  
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 :)


nicholi shen
1880
nicholi shen  
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. 

microhyd
35
microhyd  
Thank you very much nicholi shen , work it perfectly with "OrderClosePrice()"! :)
To add comments, please log in or register