Close Open Sell1

Download script
Author: Copyright � 2007, GwadaTradeBoy
Close Open Sell1

This automated script is designed to streamline your trading workflow by instantly identifying and closing specific types of active positions in your portfolio. It acts as a "one-click" utility to clear out Sell orders without requiring you to manually select each trade one by one.

How the Logic Works

The script follows a straightforward, systematic process to manage your open trades:

  • Portfolio Scan: As soon as the script is activated, it performs an immediate audit of all currently active trading positions in your account. It calculates the total number of open trades to ensure no order is overlooked.
  • Targeted Identification: The program moves through the list of open trades and inspects each one individually. It is programmed specifically to look for "Sell" orders (positions where you are betting on the price decreasing).
  • Automated Execution: Once a Sell order is identified, the script automatically triggers a command to close that specific position at the current market price.
  • Sequential Processing: The logic processes the trades in a descending sequence. This ensures that even if multiple Sell orders are open simultaneously, the script will cycle through the entire list until every matching "Sell" trade has been successfully closed.

In summary, this tool serves as a safety or management shortcut: it allows you to instantly exit all short positions across your account while leaving any other types of trades (such as Buy orders) completely unaffected.

Orders Execution
Checks for the total of open ordersIt Closes Orders by itself
10 Views
0 Downloads
0 Favorites
Close Open Sell1
//+------------------------------------------------------------------+
//|                                              Close Open Sell.mq4 |
//|                                  Copyright © 2007, GwadaTradeBoy |
//|                                           gwadatradeboy@yahoo.fr |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, GwadaTradeBoy"
#property link      "gwadatradeboy@yahoo.fr"

int total = 0, cnt = 0;
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
   {
//----
      total = OrdersTotal();
      for (cnt = total ; cnt >=0 ; cnt--)
               {
                  OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
                  if(OrderType()==OP_SELL)
                     OrderClose(OrderTicket(),OrderLots(),Ask,5,Violet);
               }
//----
      return(0);
   }
//+------------------------------------------------------------------+

Comments