Author: Copyright � 2009, ������ ������� ����������
Profit factor:
0.00

This script is designed to automate trade management based on scheduled economic news events. It acts as a proactive system that identifies specific "news zones" (like currency pairs or regions) and executes actions automatically at pre-defined times.

Here is a breakdown of the logic in non-technical terms:

News Monitoring and Tracking

The script allows you to input a schedule of up to 10 different news events. For each event, you can specify:

  • The Zone: Which currency pairs or assets are affected by this news.
  • Importance: A numerical value that determines the size of the trades (higher importance results in larger positions).
  • Time and Duration: Exactly when the news occurs and how long the "active period" lasts after the news breaks.

The script provides a real-time visual update on your screen, displaying a countdown or a status message for upcoming news events based on this schedule.

Automated Order Execution

When the clock hits the specified news time, the script automatically scans all relevant instruments within your defined "zones." If no trades are already active for those instruments, it performs the following:

  • Pending Orders: It places "Buy Stop" and "Sell Stop" orders simultaneously. These are "waiting" orders that only trigger if the price moves significantly in either direction (up or down) immediately following the news release.
  • Dynamic Sizing: The volume of these trades is automatically adjusted based on the "Importance" level you assigned to that specific news event.

Smart Trade Cleanup

To manage risk, the script includes logic to clean up "hanging" orders:

  • Mutual Exclusion: If the price moves in one direction and a trade is triggered (e.g., a Buy position opens), the script automatically deletes the opposite waiting order (the Sell Stop). This prevents the system from opening multiple contradictory positions at once.

Profit Protection and Trail Logic

Once the news event has passed (after the "Life" duration expires), the script shifts into management mode:

  • Trailing Mechanism: It monitors the profit of the trades opened during the news event.
  • Automatic Closing: If the trade is in a profit position, the script can be configured to close the trade if it begins to drop significantly from its peak (based on a percentage you define). This helps "lock in" gains and prevents a winning trade from turning into a loss due to sudden market volatility.
  • Finalization: If a trade is closed or hits these criteria, the script resets itself to wait for the next scheduled news event.
Orders Execution
Checks for the total of open orders
14 Views
0 Downloads
0 Favorites
Multi-News
//+------------------------------------------------------------------+
//|                                                   Multi-News.mq4 |
//|                     Copyright © 2009, Äåì¸õèí Âèòàëèé Åâãåíüåâè÷ |
//|                                             Vitalya_1983@list.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Äåì¸õèí Âèòàëèé Åâãåíüåâè÷"
#property link      "Vitalya_1983@list.ru"

extern string     zone_1      = "";//Ñòðàíà (âàëþòà ñòðàíû) ãäå âûéäåò íîâîñòü
extern int        vazhnost_1  = 3; //Ñòåïåíü âàæíîñòè íîâîñòè. Âëèÿåò íà îáúåì ñäåëêè
extern datetime   time_news_1  ;   //Âðåìÿ âûõîäà íîâîñòè
extern int        life_news_1 = 10;//Âðåìÿ äåéñòâèÿ íîâîñòè â ìèíóòàõ, ïîñëå êîòîðîãî âêëþ÷èòñÿ òðàë, ëèáî çàêðîþòñÿ îðäåðà

extern string     zone_2      = "";
extern int        vazhnost_2  = 3;
extern datetime   time_news_2  ;
extern int        life_news_2 = 10;

extern string     zone_3 =  "";
extern int        vazhnost_3  = 3;
extern datetime   time_news_3  ;
extern int        life_news_3 = 10;

extern string     zone_4      = "";
extern int        vazhnost_4  = 3;
extern datetime   time_news_4  ;
extern int        life_news_4 = 10;

extern string     zone_5      = "";
extern int        vazhnost_5  = 3;
extern datetime   time_news_5  ;
extern int        life_news_5 = 10;

extern string     zone_6      = "";
extern int        vazhnost_6  = 3;
extern datetime   time_news_6  ;
extern int        life_news_6 = 10;

extern string     zone_7      =  "";
extern int        vazhnost_7  = 3;
extern datetime   time_news_7  ;
extern int        life_news_7 = 10;

extern string     zone_8      = "";
extern int        vazhnost_8  = 3;
extern datetime   time_news_8  ;
extern int        life_news_8 = 10;

extern string     zone_9      =  "";
extern int        vazhnost_9  = 3;
extern datetime   time_news_9  ;
extern int        life_news_9 = 10;

extern string     zone_10      = "";
extern int        vazhnost_10  = 3;
extern datetime   time_news_10  ;
extern int        life_news_10 = 10;

extern double     Lots = 0.01; //óìíîæàåòñÿ íà âàæíîñòü íîâîñòè
extern bool       delete_stop_orders = true,
                  trail_orders       = true;

extern int        percent_for_trail  = 15;

//ìàññèâû:

string instrument [29];
string zone [11];
int vazhnost [11];
datetime time_news[11];
int life_news[11];
double profits [11];
bool delete_orders[11];
int orders [11];
bool stop_orders_buy = false,stop_orders_sell = false,orders_buy =false,orders_sell =false;
double price,profit;

string TEXT;
int i,n,m;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
// Çàïîëíåíèå ìàññèâîâ
   zone [1] =  zone_1;  vazhnost [1] = vazhnost_1;    time_news[1] = time_news_1;   life_news[1] = life_news_1;
   zone [2] =  zone_2;  vazhnost [2] = vazhnost_2;    time_news[2] = time_news_2;   life_news[2] = life_news_2;
   zone [3] =  zone_3;  vazhnost [3] = vazhnost_3;    time_news[3] = time_news_3;   life_news[3] = life_news_3;
   zone [4] =  zone_4;  vazhnost [4] = vazhnost_4;    time_news[4] = time_news_4;   life_news[4] = life_news_4;
   zone [5] =  zone_5;  vazhnost [5] = vazhnost_5;    time_news[5] = time_news_5;   life_news[5] = life_news_5;
   zone [6] =  zone_6;  vazhnost [6] = vazhnost_6;    time_news[6] = time_news_6;   life_news[6] = life_news_6;
   zone [7] =  zone_7;  vazhnost [7] = vazhnost_7;    time_news[7] = time_news_7;   life_news[7] = life_news_7;
   zone [8] =  zone_8;  vazhnost [8] = vazhnost_8;    time_news[8] = time_news_8;   life_news[8] = life_news_8;
   zone [9] =  zone_9;  vazhnost [9] = vazhnost_9;    time_news[9] = time_news_9;   life_news[9] = life_news_9;
   zone [10] = zone_10; vazhnost [10] = vazhnost_10;  time_news[10] = time_news_10; life_news[10] = life_news_10;
   
   instrument [1] =  "EURUSD";  /* instrument [2] =  "GBPUSD";   instrument [3] =  "USDCHF";   instrument [4] =  "USDJPY";
   instrument [5] =  "USDCAD";   instrument [6] =  "AUDUSD";   instrument [7] =  "NZDUSD";   instrument [8] =  "EURAUD";
   instrument [9] =  "EURCHF";   instrument [11] = "EURGBP";   instrument [12] = "EURJPY";   instrument [13] = "EURCAD";
   instrument [14] = "GBPCHF";   instrument [15] = "GBPJPY";   instrument [16] = "AUDCHF";   instrument [17] = "AUDNZD";
   instrument [18] = "AUDJPY";   instrument [19] = "AUDCAD";   instrument [20] = "CADCHF";   instrument [21] = "CADJPY";
   instrument [22] = "NZDJPY";   instrument [23] = "CHFJPY";   instrument [24] = "EURNZD";   instrument [25] = "GBPAUD";
   instrument [26] = "GBPCAD";   instrument [27] = "NZDCHF";   instrument [28] = "NZDCAD";*/
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
   {
   TEXT="òåêóùåå âðåìÿ "+TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES);
//----
   for (i=1; i<=10; i++)
      {
      if (zone[i]!="")
         {
         if (TimeCurrent()<time_news[i])
            {
            TEXT=TEXT+"\n"+"íîâîñòü íîìåð " +i+ " ñ âàæíîñòüþ " + vazhnost [i] + " áàëëà ïî âàëþòå "+ zone[i]+ " âûéäåò "+ TimeToStr(time_news[i],TIME_DATE|TIME_MINUTES);
            }
         else 
            {
            }
         //ïðîâåðêà âðåìåíè âûõîäà íîâîñòè ïî äàííîé çîíå èíñòðóìåíòîâ, óñòàíîâêà îòëîæåííûõ îðäåðîâ
         if (TimeCurrent()>=time_news[i]&&TimeCurrent()<=time_news[i]+life_news[i]*60)
            {
            delete_orders [i]=false;
            profit =0;
            for (n=1; n<=28; n++)
               {
               if (StringFind (instrument [n], zone[i],0)>-1)
                  {
                  stop_orders_buy   = false; // ôëàãè òåêóùèõ èíñòðóìåíòîâ
                  stop_orders_sell  = false;
                  orders_buy        = false;
                  orders_sell       = false;
                  for (m=OrdersTotal()-1;m>=0; m--)
                     {
                     OrderSelect (m,SELECT_BY_POS,MODE_TRADES);
                     if (OrderMagicNumber() == i && OrderSymbol()==instrument [n])
                        {
                        if (OrderType ()==OP_BUY)
                           {
                           orders_buy = true;
                           profit = profit+OrderProfit();
                           }
                        if (OrderType ()==OP_SELL)
                           {
                           profit = profit+OrderProfit();
                           orders_sell= true;
                           }
                        if (OrderType ()==OP_BUYSTOP)
                           {
                           stop_orders_buy = true;
                           }
                        if (OrderType ()==OP_SELLSTOP)
                           {
                           stop_orders_sell = true;
                           }
                        }
                     }
                  if (!stop_orders_buy&&!orders_buy&&!orders_sell)
                     {
                     RefreshRates ();
                     price = NormalizeDouble((MarketInfo (instrument [n], MODE_ASK)+MarketInfo (instrument [n], MODE_STOPLEVEL)*MarketInfo (instrument [n], MODE_POINT)*2),MarketInfo (instrument [n], MODE_DIGITS));
                     OrderSend (instrument [n], OP_BUYSTOP, Lots*vazhnost [i], price,10,0,0,0,i,0,Blue);
                     }
                  if (!stop_orders_sell&&!orders_buy&&!orders_sell)
                     {
                     RefreshRates ();
                     price = NormalizeDouble((MarketInfo (instrument [n], MODE_BID)-MarketInfo (instrument [n], MODE_STOPLEVEL)*MarketInfo (instrument [n], MODE_POINT)*2),MarketInfo (instrument [n], MODE_DIGITS));
                     OrderSend (instrument [n], OP_SELLSTOP, Lots*vazhnost [i], price,10,0,0,0,i,0,Red);
                     }
                  if (delete_stop_orders)//åñëè îäèí èç îòëîæåííûõ îðäåðîâ ñðàáîòàë, óäàëÿåì íåñðàáîòàâøèé
                     {
                     if (orders_buy||orders_sell)
                        {
                        for (m=OrdersTotal()-1;m>=0; m--)
                           {
                           OrderSelect (m,SELECT_BY_POS,MODE_TRADES);
                              {
                              if (OrderMagicNumber() == i&&OrderSymbol()==instrument [n]&&(OrderType () == OP_SELLSTOP||OrderType () == OP_BUYSTOP))
                                 {
                                 OrderDelete (OrderTicket());
                                 }
                              }
                           }
                        }
                     }
                  }
               }
            }
         }
      
      if (TimeCurrent()>time_news[i]+life_news[i]*60&&time_news[i]!=0)
         {
         profit=0;
         for (m=OrdersTotal()-1;m>=0; m--)
            {
            OrderSelect (m,SELECT_BY_POS,MODE_TRADES);
               {
               if (OrderMagicNumber() == i)
                  {
                  profit = profit+OrderProfit();
                  }
               }
            }
         if (profits [i]<profit)
            {
            profits [i]=profit;
            }
         if (profits [i]-(percent_for_trail/100)*profits [i]>profit||profit<0||!trail_orders)
            {
            delete_orders [i] = true;
            }
         if (delete_orders [i])
            {
            orders [i]=0;
            for (m=OrdersTotal()-1;m>=0; m--)
               {
               OrderSelect (m,SELECT_BY_POS,MODE_TRADES);
                  {
                  if (OrderMagicNumber() == i)
                     {
                     orders [i] ++;
                     if (OrderType () == OP_SELLSTOP||OrderType () == OP_BUYSTOP)
                        {
                        OrderDelete (OrderTicket());
                        }
                     if (OrderType () == OP_BUY)
                        {
                        price = MarketInfo (OrderSymbol (), MODE_BID);
                        OrderClose (OrderTicket(),OrderLots(),price,10, Blue);
                        }
                     if (OrderType () == OP_SELL)
                        {
                        price = MarketInfo (OrderSymbol (), MODE_ASK);
                        OrderClose (OrderTicket(),OrderLots(),price,10, Red);
                        }
                     }
                  }
               }
            if (orders [i] !=0)
               {
               }
            if (orders [i] ==0)
               {
               delete_orders [i] = false;
               }
            }
         }
      }
         
   Comment (TEXT);
//----
   return(0);
   }
//+------------------------------------------------------------------+

Profitability Reports

PERFORMANCE BY SYMBOL

Expected payoff

Average expected payoff across the available backtests for each symbol.

Positive Negative
4 reports
AUD/USD Oct 2024 - Jan 2025
0.00
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.00
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.00
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.00
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%

Comments