Help Modifying pending orders

 

Hi there! I´m coding an EA which uses pending orders - i know that some people find that EAs shouldn´t use pending orders but it makes sense for my logic - and i want to modify its price depending on the last high/low. Im having trouble with the trade.orderModify parameters count. I´m using it the same way i use for PositionModify to change only the parameters I need to be changed, but i get the "wrong parameter count" error. How do I specify the parameters that I do not want to change?

Can anybody tell me what am I doing wrong here, please?

here´s the function:

void ModifyPending ()
 {
   for(int i=OrdersTotal(); i>=0; i--)
     {
      ulong    ticket = OrderGetTicket(i);
      string   symbol = OrderGetString(ORDER_SYMBOL);
      ulong    magic  = OrderGetInteger(ORDER_MAGIC);
      
      if(symbol==_Symbol && magic==magicNum)
        {
                 
       ////////////////// BUY STOP          
          
       if(OrderGetInteger(ORDER_TYPE) == ORDER_TYPE_BUY_STOP)
         { if(rates[1].high<rates[2].high)
           {
            trade.OrderModify(ticket,rates[1].high);
           }
         } 
       
       /////////////// SELL STOP
    
       else if(OrderGetInteger(ORDER_TYPE)== ORDER_TYPE_SELL_STOP)
              {
               if(rates[1].low>rates[2].low)
                 {
                  trade.OrderModify(ticket, rates[1].low);
                 }
               }
              
        }
       }
      }
 

Please check the documentation page.

Bruno Chimenti:
   for(int i=OrdersTotal(); i>=0; i--)
for(int i=OrdersTotal()-1; i>=0; i--)
Documentation on MQL5: Standard Library / Trade Classes / CTrade / OrderModify
Documentation on MQL5: Standard Library / Trade Classes / CTrade / OrderModify
  • www.mql5.com
Modifies the pending order parameters. Parameters ticket [in]  Order ticket. price [in] The new price by which the order must be executed (or...
 
Yashar Seyyedin #:
for(int i=OrdersTotal()-1; i>=0; i--)

thanks, i missed that -1.


I´ve read the documentation, but I´m still not sure how do I specify the parameters that i don´t want to be changed - in this case i just want to change the price, and all the rest stays the same.

 
Bruno Chimenti #:

how do I specify the parameters that i don´t want to be changed

OK. Enter everything the same as their previous values except those you want to modify.

Reason: