AlertCloseOrderEN

Download script
Author: Copyright � 2010, Vladimir Hlystov
AlertCloseOrderEN

This tool is designed to act as an automated notification system for traders using the MetaTrader platform. Its primary purpose is to provide instant visual alerts whenever a trading position is finalized, specifically identifying how that trade concluded and detailing the financial outcome.

How the Logic Works

The script operates by constantly monitoring the status of your active trades in real-time. It keeps a "memory" of how many orders you currently have open. Every time the market updates, the tool performs a quick check: if the number of open orders decreases, it understands that a trade has been closed and triggers its reporting sequence.

Key Features of the Notification

When a trade is closed, the script automatically retrieves the following information to provide a comprehensive summary:

  • Closure Method: It determines exactly why the trade ended. It checks if the position was closed because it hit your Stop Loss (limiting your losses) or your Take Profit (securing your gains).
  • Identification: It provides the specific ticket number of the order so you can easily identify which trade is being referenced in your history.
  • Price Details: It displays the exact price at which the trade was finalized.
  • Profit Tracking: It calculates and displays the final profit or loss amount for that specific trade, rounded to two decimal places.

User Experience

Instead of requiring you to manually scan your trade history to see how your positions performed, this script "pushes" that information to you via a pop-up alert. This allows you to stay informed about your trading performance immediately as it happens, making it easier to track your successes and losses throughout the trading day.

Orders Execution
Checks for the total of open ordersChecks for the total of closed orders
Miscellaneous
It issuies visual alerts to the screen
2 Views
0 Downloads
0 Favorites
AlertCloseOrderEN
//+------------------------------------------------------------------+
//|                                              AlertCloseOrder.mq4 |
//|                               Copyright © 2010, Vladimir Hlystov |
//|                                         http://cmillion.narod.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Vladimir Hlystov"
#property link      "http://cmillion.narod.ru"
#property indicator_chart_window
int Orders;
//+------------------------------------------------------------------+
int start()
  {
   if (Orders>OrdersTotal()) AlertOrder();
   Orders=OrdersTotal();
   return(0);
  }
//+------------------------------------------------------------------+
void AlertOrder()
{
   string txt;
   double OCP;
   int i=OrdersHistoryTotal()-1;
   if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true)
   {                                     
      OCP=OrderClosePrice();
      if (OCP==OrderStopLoss()  ) txt="SL";
      if (OCP==OrderTakeProfit()) txt="TP";
      Alert("Order N ",OrderTicket()," close in ",txt," ",
      DoubleToStr(OCP,Digits)," profit ",DoubleToStr(OrderProfit(),2));
}  }
//+------------------------------------------------------------------+

Comments