How Get all pending orders price value ?

 

Hi

I want to get all orders prices (double values) into array or string...

I searched all topic 2 days!

but not found any way in MQ5.

please help.

 

You have to code it yourself (there are many examples of how to access what you need you just have to search) or ask a freelancer to do it for you.

For this read this first:
rules: https://www.mql5.com/en/job/rules
EA   requirements specification:  https://www.mql5.com/en/articles/4368
Indicator requirements specification: https://www.mql5.com/en/articles/4304
How to Order a Trading Robot in MQL5 and MQL4:  https://www.mql5.com/en/articles/117

Trading applications for MetaTrader 5 to order
Trading applications for MetaTrader 5 to order
  • 2025.03.10
  • www.mql5.com
The largest freelance service with MQL5 application developers
 
hamedham65 TürkOğlu:

Hi

I want to get all orders prices (double values) into array or string...

I searched all topic 2 days!

but not found any way in MQ5.

please help.

Try this , note it works for stop and limit orders not for stoplimit orders.

int OnInit()
  {
  double put_prices_in_here[];
  int collected_total=collect_all_pendings(put_prices_in_here);
  Print("Collected "+IntegerToString(collected_total)+" prices");
  for(int i=0;i<ArraySize(put_prices_in_here);i++){
     Print("---price ["+IntegerToString(i)+"] "+put_prices_in_here[i]);
     }
  return(INIT_SUCCEEDED);
  }

int collect_all_pendings(double &array_result[],
                         string for_symbol_or_null=NULL){
int orders=OrdersTotal();
/*
loop into the orders
*/
for(int i=0;i<orders;i++){
//select the order by getting it's ticket (it also auto selects it)
  ulong ticket=OrderGetTicket(i);//we are calling for the ticket of the 3rd order in the list for instance
  //if the order symbol matches the symbol we are looking for OR 
  //                    we have an empty symbol (which means we accept them all)
  if(OrderGetString(ORDER_SYMBOL)==for_symbol_or_null||for_symbol_or_null==NULL){
    //get it's price
      double the_orders_price=OrderGetDouble(ORDER_PRICE_OPEN);
    //grow your list by one
      ArrayResize(array_result,ArraySize(array_result)+1,100);
    //add the price to the list
      array_result[ArraySize(array_result)-1]=the_orders_price;
    }  
}
//return the amount of prices collected
return(ArraySize(array_result));                         
}