CloseMall_Hour_Input Bee-otch-666

Download script
Author: Copyright � 2005, MetaQuotes Software Corp.
CloseMall_Hour_Input Bee-otch-666

This script is designed as an automated safety tool for traders using the MetaTrader platform. Its primary purpose is to automatically manage your active positions by closing all open trades at a specific time of day, ensuring that you are not exposed to market fluctuations during periods when you are away from your terminal or during high-risk hours.

How the Logic Works

The script operates based on two main components: a Time Trigger and an Action Sequence.

1. The Time Trigger

The script constantly monitors the current time on your trading platform. It looks for two specific conditions to determine if it should execute its command:

  • Specific Hour: You can set a designated hour (for example, 11:00 PM). When the clock hits this hour, the script activates.
  • Manual Override: There is an option to force the script to stay active at all times, regardless of the hour.

2. The Action Sequence

Once the time trigger is met, the script performs a comprehensive sweep of your trading account. It follows these steps:

  • Scanning: It looks through every single open trade and pending order currently in your account.
  • Liquidation: For every active position found, it immediately executes a "Close" command to exit the trade at the current market price.
  • Cleanup: After closing the trades, it removes the remaining order data from your platform to ensure a clean slate.

Summary for the User

Think of this tool as an automated "Off Switch." Instead of manually monitoring the markets and closing your positions yourself before going to bed or leaving your desk, this script monitors the clock for you. When your predefined time arrives, it automatically secures your capital by shutting down all active trading activities instantly.

Orders Execution
Checks for the total of open ordersIt Closes Orders by itself
13 Views
0 Downloads
0 Favorites
CloseMall_Hour_Input Bee-otch-666
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                         CloseMall_Hour_Input.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

extern int CloseHour   =    23;
extern int CloseNow    =     1;
int    i;
bool   CloseMAll;

int start()
{

  ////////////////////////////////
  // initial data checks
  ////////////////////////////////

  if (Hour()!=CloseHour)   { CloseMAll = false;  }
  if ((Hour()==CloseHour) || (CloseNow==1))   { CloseMAll = true;   }

  ///////////////////////////////////
  // Determine trades/orders and close/delete all trades/orders
  ///////////////////////////////////

  if (CloseMAll == true)
   {
    for(i = OrdersTotal()-1; i >=0 ; i--)
     {
      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
       if (OrdersTotal() != 0)
        {
         OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),0,White);
         OrderDelete( OrderTicket() );
         CloseMAll = true;
        }
     }
   }
 return(0);
}

Comments