Pause pending orders during news

 
Hello, is there any way how I can pause all my pending orders (manually) before some news? I don't want always to delete pending orders before some news and then set new ones... thanks
 
vb2:
Hello, is there any way how I can pause all my pending orders (manually) before some news? I don't want always to delete pending orders before some news and then set new ones... thanks
No. You delete them and add them again later.
 
vb2:
Hello, is there any way how I can pause all my pending orders (manually) before some news? I don't want always to delete pending orders before some news and then set new ones... thanks


You can use an EA to automatically delete/store/place the orders. Here's a quick on I whipped together.

//+------------------------------------------------------------------+
//|                                            PendingOrderPause.mq4 |
//|                                                      nicholishen |
//|                                   www.reddit.com/u/nicholishenFX |
//+------------------------------------------------------------------+
#property copyright "nicholishen"
#property link      "www.reddit.com/u/nicholishenFX"
#property version   "1.00"
#property strict
#include <Controls\Button.mqh>
#include <Arrays\ArrayObj.mqh>
#include <Arrays\ArrayInt.mqh>
#include <stdlib.mqh>

class PendingOrder : public CObject
{
public:
   ulong             ticket;
   int               type;
   string            symbol;
   double            lots;
   double            price;
   double            stop;
   double            take;
   string            ToString()
                     {
                        int digits = (int)SymbolInfoInteger(symbol,SYMBOL_DIGITS);
                        return
                        symbol+" "+DoubleToStr(price,digits)+" SL= "+
                        DoubleToStr(stop,digits)+ " TP= "+
                        DoubleToStr(take,digits);
                     }
};

class PendingOrderList : public CArrayObj
{
public:
   PendingOrder   *operator[](const int index)const{return (PendingOrder*)At(index);}
};

input bool        PauseAllSymbolOrders = false;//Pause all orders regardless of symbol?
PendingOrderList  pending_orders;
CButton           button;
bool              bActive;
string op="\n\n\n\n\n\nPaused orders\n====================================\n";
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- create timer
   //EventSetTimer(60);
   button.Create(0,"button",0,5,20,300,75);
   button.Activate();
   button.ColorBackground(clrAliceBlue);
   button.Text("Click to Pause Orders");
   bActive = false;
   
   Comment(op);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
   //EventKillTimer();
      
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
//---
   
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
{
   if(id == CHARTEVENT_OBJECT_CLICK && sparam == "button")
   {
      if(!bActive)
      {
         if(!PauseOrders())
         {
            Print("An Error occured pausing orders");
         }
         bActive = !bActive;
         button.Deactivate();
         button.ColorBackground(clrRed);
         button.Text("Click to Resume Orders");
         string com = op;
         for(int i=0;i<pending_orders.Total();i++)
            com+=pending_orders[i].ToString()+"\n";
         Comment(com);
      }
      else
      {
         if(!ResumeOrders())
         {
            Print("An Error occured resuming orders");
         }
         bActive = !bActive;
         button.Activate();
         button.ColorBackground(clrAliceBlue);
         button.Text("Click to Pause Orders");
         string com = op;
         Comment(com);
      }
   }
   
}
//+------------------------------------------------------------------+

bool PauseOrders()
{
   CArrayInt tickets;
   bool res = true;
   pending_orders.Clear();
   for(int i=0;i<OrdersTotal();i++)
   {
      if(OrderSelect(i,SELECT_BY_POS))
      {
         if(PauseAllSymbolOrders||OrderSymbol() == Symbol())
         {
            if(OrderType() == OP_BUYLIMIT || OrderType() == OP_BUYSTOP || OrderType() == OP_SELLLIMIT || OrderType() == OP_SELLSTOP)
            {
               tickets.Add(OrderTicket());
            }
         }
      }
   }
   for(int i=0;i<tickets.Total();i++)
   {
      if(OrderSelect(tickets[i],SELECT_BY_TICKET))
      {
         PendingOrder *order = new PendingOrder();
         order.ticket   = OrderTicket();
         order.type     = OrderType();
         order.symbol   = OrderSymbol();
         order.price    = OrderOpenPrice();
         order.lots     = OrderLots();
         order.stop     = OrderStopLoss();
         order.take     = OrderTakeProfit();
         pending_orders.Add(order);
         if(!OrderDelete(OrderTicket()))
         {
            res = false;
            Print(__FUNCTION__," TRADE ERROR DELETE ORDER: ",ErrorDescription(GetLastError()));
         }
      }
   }
   return res;
}

bool ResumeOrders()
{
   bool res = true;
   for(int i=0;i<pending_orders.Total();i++)
   {
      bool order = OrderSend( pending_orders[i].symbol,
                              pending_orders[i].type,
                              pending_orders[i].lots,
                              pending_orders[i].price,
                              0,
                              pending_orders[i].stop,
                              pending_orders[i].take
                              );
      if(!order)
      {
         Print(__FUNCTION__," TRADE ERROR: ",ErrorDescription(GetLastError()));
         res = false;
      }
   }
   return res;
}
Reason: