Pending Order comments

 
Hi.

I was thinking of making a indicator that plats the comment of pending orders on those buy/sell Limit/stop lines.

Is there any way of finding pending orders?

im using this for something eleas but this only gives me trades that have been open
for(int i=OrdersHistoryTotal() -1; i >= 0; i--)
     {
      if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true)
        {
         if(OrderSymbol()==Symbol() && (OrderMagicNumber()==MagicNumber) && UseMagicnumber)
           {
            countTrades+=1;
            if(OrderType() == OP_BUY)
              {
               countBuy+=1;
              }
            if(OrderType() == OP_BUYLIMIT)
              {
               countBuyLimit+=1;
              }
            if(OrderType() == OP_BUYSTOP)
              {
               countBuyStop+=1;
              }
            if(OrderType() == OP_SELL)
              {
               countSell+=1;
              }
            if(OrderType() == OP_SELLLIMIT)
              {
               countSellLimit+=1;
              }
            if(OrderType() == OP_SELLSTOP)
              {
               countSellStop+=1;
              }
 
Mathias Halen:
I was thinking of making a indicator that plats the comment of pending orders on those buy/sell Limit/stop lines.

Is there any way of finding pending orders?

im using this for something eleas but this only gives me trades that have been open
  1. Can't modify comments.
              Metaquotes language: OrderComment() is not able to be modified - Expert Advisors and Automated Trading - MQL5 programming forum 2013.08.10

    Not a good idea to use comments, brokers can change comments, including complete replacement.

  2. for(int i=OrdersHistoryTotal() -1; i >= 0; i--){
          if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true)
    Your code is looking at history and will only find deleted pending orders and closed orders. Look at the order pool.

  3.          if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber && UseMagicnumber)
    
    If UseMagicnumber is false, you will find nothing. What you meant is … && (OrderMagicNumber()==MagicNumber || !UseMagicNumber) Note the enclosing parentheses.

  4. if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true)
    You should be able to read your code out loud and have it make sense. You would never write if( (2+2 == 4) == true) would you? if(2+2 == 4) is sufficient. So don't write if(bool == true), just use if(bool) or if(!bool). Code becomes self documenting when you use meaningful variable names, like bool isLongEnabled where as Long_Entry sounds like a trigger price or a ticket number and "if long entry" is an incomplete sentence.

Reason: