_______ ___ ______

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

This script is a utility designed for traders using the MetaTrader 4 platform to quickly manage active positions. Its primary purpose is to provide a "panic button" or a manual override to clear all current market activities instantly.

How it Works

When you run this script, it initiates an interactive prompt on your screen asking whether you would like to close your current "BUY" and "SELL" positions. This serves as a confirmation step to ensure the action is intentional before any trades are affected.

Key Functionalities

  • User Confirmation: The script does not execute automatically upon launch. It waits for the user to click "Yes" on a pop-up message box, providing a layer of safety against accidental clicks.
  • Comprehensive Sweep: Once confirmed, the script scans your entire trading account. It looks through every open position currently active in the market.
  • Automated Liquidation: For every open trade it finds, it identifies whether it is a "Buy" or a "Sell." It then automatically sends a command to close those positions at the current market price.
  • Precision Handling: The script includes a built-in allowance for "slippage," which ensures that the orders are processed even if the market price fluctuates slightly by a tiny margin during the millisecond the closing command is sent.

Summary for the User

Think of this tool as a "Close All" shortcut. Instead of manually right-clicking and closing every single open trade one by one—which can be time-consuming during fast-moving market conditions—this script performs that entire task in a single click, allowing you to reset your trading screen instantly.

Orders Execution
Checks for the total of open orders
Miscellaneous
It opens Message Boxes to the user
7 Views
0 Downloads
0 Favorites
_______ ___ ______
// Çàêðûòü âñå îðäåðà.mq4
// Ñêðèïò
#property copyright "mandorr@gmail.com"
#include <WinUser32.mqh>
void start()
{
   string title="Ñêðèïò";
   string msg="Çàêðûòü âñå îðäåðà BUY è SELL?    ";
   if (MessageBox(msg,title,MB_YESNO|MB_ICONQUESTION)!=IDYES) return;
   int slippage=2;
   for (int i=OrdersTotal()-1; i>=0; i--)
   {
      if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) break;
      if (OrderType()==OP_BUY ) OrderClose (OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),slippage);
      if (OrderType()==OP_SELL) OrderClose (OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),slippage);
   }
}
// End

Comments