Best way to modify lot size of pending orders

 

Hi Guys

Since there is no built in function to modify lot size of pending orders, I suppose the only way to do it is to delete the current pending orders and resend them with the increased lot size.  I am storing the BUYSTOP and SELLSTOP price of the original order as a variable so that the same price can be reused when the new order get send with the higher lot size.  My main problem is that there also does not seem to be a built in function to indicate when pending orders are converted to market orders.  I suppose one would have to count the market orders and the pending orders based on OrderType and then detect a rise and fall in numbers.

So my question is what is the best and simplest way to determine when a pending order is converted to a market order when there are multiple potential pending orders that can be converted?  Basically, I want to say that if BUYSTOP converts to market order, then do this and if SELLSTOP order is converted to market order, then do that.  And the next time this happens, then do that.  How do you determine through a rise and fall in OrderType count that a pending order got converted?  This is how far I got:

int Buymarket=0,Sellmarket=0,BuyStop=0,SellStop=0;
   
   for(int i=OrdersTotal()-1; i>=0; i--){
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){
         if(OrderSymbol()==Symbol()){
               if(OrderType()==OP_BUY){
                  Buymarket++;
                 }
               if(OrderType()==OP_SELL){
                  Sellmarket++;
                 }
               if(OrderType()==OP_BUYSTOP){
                  BuyStop++;
                 }
               if(OrderType()==OP_SELLSTOP){
                  SellStop++;
                 }
               }
             }
           }
        //if(Buymarket increase by 1 and Sellstop decrease by 1) then do this
        //the next time that Sellmarket increase by 1 and Buystop decrease by 1) then do that
        //this is the part that I do not know how to code

Will someone please help me with how to code increases and decreases?  Thank you

 
There is no need to create pending orders in code.
  1. The pending has the slight advantage, A) you are closer to the top of the queue (filled quicker,) B) there's no round trip network delay (filled quicker.)
  2. Don't worry about it unless you're scalping M1 or trading news.
  3. Humans can't watch the screen 24/7, so they use pending orders; EAs can, so no need for pending orders, have it wait until the market reaches the trigger price and just open an order.
Reason: