Download MetaTrader 5

please helpe me find remaining order after closeby orders

To add comments, please log in or register
mehdi khoshbakhtvash
3353
mehdi khoshbakhtvash  

hi my firends

how do close only remaing order after closeBy Buy and sell orders

I want code it in mql4  

Mohammad Soubra
31999
Mohammad Soubra  
mehdi khoshbakhtvash:

hi my firends

how do close only remaing order after closeBy Buy and sell orders

I want code it in mql4  

I hope this link below could help:

https://www.mql5.com/en/search#!keyword=close%20all&module=mql5_module_codebase

mehdi khoshbakhtvash
3353
mehdi khoshbakhtvash  

thank you my firend

but I want to find and close only  remaining order after CloseBy() function .

whroeder1
16336
whroeder1  
  1. Show us your OrderSelect loop to find the remaining order.
    Using OrdersTotal directly and/or no Magic number filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.) Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 forum
  2. learn to code it, or pay (Freelance) someone to code it. We're not going to code it for you. We are willing to help you when you post your attempt (using SRC) and the nature of your problem.
    mehdi khoshbakhtvash
    3353
    mehdi khoshbakhtvash  
    whroeder1:
    1. Show us your OrderSelect loop to find the remaining order.
    2. learn to code it, or pay (Freelance) someone to code it. We're not going to code it for you. We are willing to help you when you post your attempt (using SRC) and the nature of your problem.
      int CloseByLastStep()
      {
              CheckOrders(MagicNumber);
      int SellTicket , BuyTicket ;
              for(int L=0;L<OrdersTotal();L++)
              {
                      if(OrderSelect(L,SELECT_BY_POS,MODE_TRADES)==false)
                              break;
                      if(OrderSymbol()==Symbol() || OrderMagicNumber()==MagicNumber)
                      if(OrderType()==OP_SELL && OrderLots()==MaxSLot)
                      {
                      SellTicket=OrderTicket();
                      }
                      if(OrderType()==OP_BUY && OrderLots()==MaxBLot)
                      {
                      BuyTicket=OrderTicket();
                      }
              }
              if (MaxSLot>MaxBLot)
              {
              if(OrderCloseBy(SellTicket,BuyTicket,White))
              {
              for(int LSell=0;LSell<OrdersTotal();LSell++)
              {
              if(OrderSelect(LSell,SELECT_BY_POS,MODE_TRADES)==true)
              if (StringFind(OrderComment(),IntegerToString(SellTicket),0)&&OrderType()==OP_SELL)CloseOrder(LSell,OrderLots(),Ask,Slippage,clrLime);
              }
              }
              }
              if (MaxSLot<MaxBLot)
              {
              if(OrderCloseBy(SellTicket,BuyTicket,White))
              {
              for(int LBuy=0;LBuy<OrdersTotal();LBuy++)
              {
              if(OrderSelect(LBuy,SELECT_BY_TICKET,MODE_TRADES)==true)
              if (StringFind(OrderComment(),IntegerToString(BuyTicket),0)&&OrderType()==OP_BUY)CloseOrder(LBuy,OrderLots(),Ask,Slippage,clrLime);
              }
              }
              }
              return(1);
      }
      mehdi khoshbakhtvash
      3353
      mehdi khoshbakhtvash  
      Buy_ID = OrderGetInteger(ORDER_POSITION_ID);
      hi my firend please help me for used this function in mql4
      whroeder1
      16336
      whroeder1  
      mehdi khoshbakhtvash: please help me for used this function in mql4
      Buy_ID = OrderGetInteger(ORDER_POSITION_ID);
      1. Does not exist in MQL4
      2. Don't double post

      mehdi khoshbakhtvash
      3353
      mehdi khoshbakhtvash  
      whroeder1:
      1. Does not exist in MQL4
      2. Don't double post

      thank you sir
      To add comments, please log in or register