I need help to put temporary stop on new orders " during " the loop completing close order.

 

I need help to put temporary stop on new order " during " the loop completing close order. Once loop closed all existing orders then new trade can start when possible.

Please correct the code given below..



void neworder()

 {
 

   if (looking condition here until "bool closeall()" copmplete the job.........)

    { if (sellsignal()) sendsellorder(); }
        
 
 }
   
//-----------------------------//

bool closeall()
 
{
   if(closesignal()) 
    {  
     for(int i=OrdersTotal()-1;i >= 0; i--)
      {
        if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && (OrderType()==OP_BUY || OP_SELL))
         {
           int ticket = OrderClose (OrderTicket(), OrderLots(), OrderClosePrice(), 5, CLR_NONE);
         }
       }
     } return(true);
 }
 
  1. There is no stop. There is no need. Your code closes all orders. Only then do you call sendSellOrder.

    How To Ask Questions The Smart Way. (2004)
              The XY Problem

  2. Magic number only allows an EA to identify its trades from all others. Using OrdersTotal/OrdersHistoryTotal (MT4) or PositionsTotal (MT5), directly and/or no Magic number/symbol filtering on your OrderSelect / Position select 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 programming forum (2013)
              PositionClose is not working - MQL5 programming forum (2020.02.21)
              MagicNumber: "Magic" Identifier of the Order - MQL4 Articles (2006)
              Orders, Positions and Deals in MetaTrader 5 - MQL5 Articles (1 February 2011)

    You need one Magic Number for each symbol/timeframe/strategy. Trade current timeframe, one strategy, and filter by symbol requires one MN.

  3. Zero is false and non-zero is true.
    (OrderType()==OP_BUY || OP_SELL))
    OP_SELL is one.
    (OrderType()==OP_BUY || true))
    
    
    Anything or true is always true.
    (true)
 
William Roeder #:
  1. There is no stop. There is no need. Your code closes all orders. Only then do you call sendSellOrder.

    How To Ask Questions The Smart Way. (2004)
              The XY Problem

  2. Magic number only allows an EA to identify its trades from all others. Using OrdersTotal/OrdersHistoryTotal (MT4) or PositionsTotal (MT5), directly and/or no Magic number/symbol filtering on your OrderSelect / Position select 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 programming forum (2013)
              PositionClose is not working - MQL5 programming forum (2020.02.21)
              MagicNumber: "Magic" Identifier of the Order - MQL4 Articles (2006)
              Orders, Positions and Deals in MetaTrader 5 - MQL5 Articles (1 February 2011)

    You need one Magic Number for each symbol/timeframe/strategy. Trade current timeframe, one strategy, and filter by symbol requires one MN.

  3. Zero is false and non-zero is true.
    OP_SELL is one.
    Anything or true is always true.


Thank you.