_______ ___ __________ ______

Download script
Author: mandorr@gmail.com
_______ ___ __________ ______

This script is a utility designed for the MetaTrader 4 trading platform to help traders quickly manage their active pending orders. It acts as an automated "cleanup" tool for your trading terminal, specifically targeting orders that have been placed but not yet executed.

How the Logic Works:

1. User Confirmation When you run the script, it doesn't perform any actions immediately. Instead, it triggers a pop-up notification on your screen asking for confirmation. It displays a clear question: "Do you want to delete all pending orders?" The script will only proceed if you click "Yes." If you click "No" or close the window, the script stops instantly, ensuring no accidental deletions occur.

2. Identifying Pending Orders Once confirmed, the script scans through your entire list of active trades and open requests. It is programmed to distinguish between two different types of market activity:

  • Executed Trades: These are positions that are already open (e.g., you are currently in a profit or loss position). The script ignores these completely.
  • Pending Orders: These are "limit" or "stop" orders—prices set for future entry that have not been triggered yet.

3. Targeted Deletion The script specifically looks for four types of pending orders:

  • Buy Stops and Sell Stops: Orders waiting to be triggered above or below the current price.
  • Buy Limits and Sell Limits: Orders waiting to be triggered at a specific target price.

4. Automated Execution The script moves through your list from the most recent order back to the first one. For every pending order it identifies, it automatically removes it from the platform. This allows you to clear your "order book" of all remaining requests in a single click without having to manually delete each one individually.

Orders Execution
Checks for the total of open orders
Miscellaneous
It opens Message Boxes to the user
13 Views
0 Downloads
0 Favorites
_______ ___ __________ ______
// Óäàëèòü âñå îòëîæåííûå îðäåðà.mq4
// Ñêðèïò
#property copyright "mandorr@gmail.com"
#include <WinUser32.mqh>
void start()
{
   string title="Ñêðèïò";
   string msg="Óäàëèòü âñå îòëîæåííûå îðäåðà?    ";
   if (MessageBox(msg,title,MB_YESNO|MB_ICONQUESTION)!=IDYES) return;
   int slippage=3;
   for (int i=OrdersTotal()-1; i>=0; i--)
   {
      if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) break;
      if (OrderType()==OP_BUYSTOP  ) OrderDelete(OrderTicket());
      if (OrderType()==OP_SELLSTOP ) OrderDelete(OrderTicket());
      if (OrderType()==OP_BUYLIMIT ) OrderDelete(OrderTicket());
      if (OrderType()==OP_SELLLIMIT) OrderDelete(OrderTicket());
   }
}
// End

Comments