Command to create Alerts in the terminal window ?

 

Hi, I'm developing an EA that besides placing orders, create Alerts for take profit.

Is there a command to create the Alerts in the terminal window ?

 

Thanks. 

 

it tells you about  all of your trade operations.


//+------------------------------------------------------------------+
//|                                                     SendMail.mq4 |
//|                        Copyright 2014, MetaQuotes Software Corp. |
//|                                              https://www.mql5.com |
//+------------------------------------------------------------------+
#include <stdlib.mqh> 
//#property strict
#property indicator_chart_window
extern bool Ignore  = false;     // Ignore the fact of the opening of market orders and to send messages only about changing them tp and sl.
extern bool Market  = true;      // Send the notification for opened and closed orders.
extern bool Pending = true;      // Send the notification for pending and cancelled orders.

int h,g,r,t,v;
datetime DA[100],E[100],time;
double PR[100],SL[100],TP[100];
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----
   int L=OrdersTotal();
   int H=OrdersHistoryTotal();
   bool b=false;
   datetime date,today,expiry;
   int i,e,cmd,digits,c,f,error;
   double price,stop,take;
   string type[]={"buy","sell","buy limit","sell limit","buy stop","sell stop"};
   string symbol,q,p,sl,tp,ct,text,d,ex;

//--------------------------------------- for pending and opened orders 
   today=iTime(NULL,PERIOD_D1,0);
   ct=TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES|TIME_SECONDS);
   if(t==1)
     {
      for(i=0; i<v; i++)
        {
         for(e=0; e<L; e++)
           {
            if(OrderSelect(e,SELECT_BY_POS,MODE_TRADES)==true)
              {
               cmd=OrderType();
               date=OrderOpenTime();
               d=TimeToStr(date,TIME_DATE|TIME_MINUTES|TIME_SECONDS);
               expiry=OrderExpiration();
               ex="Expiry: No";
               if(expiry>today) ex="Expiry: "+TimeToStr(expiry,TIME_DATE|TIME_MINUTES);
               symbol=OrderSymbol();
               digits=(int)MarketInfo(symbol,MODE_DIGITS);
               price=OrderOpenPrice();
               p=DoubleToStr(price,digits);
               stop=OrderStopLoss();
               sl=DoubleToStr(stop,digits);
               take=OrderTakeProfit();
               tp=DoubleToStr(take,digits);
               //----
               if(Market==true && cmd<2)
                 {
                  c++;
                  if(DA[i]==date)
                    {
                     if(SL[i]!=stop || TP[i]!=take)
                       {
                        q="Order "+type[cmd]+" changed.";
                        text=ct+"   "+type[cmd]+"   "+symbol+"   at: "+p+"   sl: "+sl+"   tp: "+tp;
                        Comment(q,"\n",text);//b=SendMail(q,text);
                        if(b==false)
                          {
                          // error=GetLastError();
                          // Alert("The notification by an order "+text+" has not been sent!\nError: "+ErrorDescription(error)+"");
                          }
                       }
                    }
                  //----
                  if(c>g)
                    {
                     if(i==0 && Ignore==false)
                       {
                        q="Order "+type[cmd]+" opened.";
                        text=d+"   "+type[cmd]+"   "+symbol+"   at: "+p+"   sl: "+sl+"   tp: "+tp;
                        Comment(q,"\n",text);//b=SendMail(q,text);
                        if(b==false)
                          {
                          // error=GetLastError();
                          // Alert("The notification by an order "+text+" has not been sent!\nError: "+ErrorDescription(error)+"");
                          }
                       }
                    }
                 }
               else
                 {
                  if(Pending==true && cmd>1 && cmd<6)
                    {
                     f++;
                     if(DA[i]==date)
                       {
                        if(PR[i]!=price || SL[i]!=stop || TP[i]!=take || E[i]!=expiry)
                          {
                           q="Order "+type[cmd]+" changed.";
                           text=ct+"   "+type[cmd]+"   "+symbol+"   at: "+p+"   sl: "+sl+"   tp: "+tp+"   "+ex;
                           Comment(q,"\n",text);//b=SendMail(q,text);
                           if(b==false)
                             {
                             // error=GetLastError();
                             // Alert("The notification by an order "+text+" has not been sent!\nError: "+ErrorDescription(error)+"");
                             }
                          }
                       }
                     //----
                     if(f>r)
                       {
                        if(i==0)
                          {
                           q="Order "+type[cmd]+" opened.";
                           text=d+"   "+type[cmd]+"   "+symbol+"   at: "+p+"   sl: "+sl+"   tp: "+tp+"   "+ex;
                           Comment(q,"\n",text);//b=SendMail(q,text);
                           if(b==false)
                             {
                             // error=GetLastError();
                             // Alert("The notification by an order "+text+" has not been sent!\nError: "+ErrorDescription(error)+"");
                             }
                          }
                       }
                    }
                 }
              }
           }
        }
     }
//----
   c=0;
   f=0;
   for(i=0; i<L; i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
        {
         DA[i]=OrderOpenTime();
         E[i]=OrderExpiration();
         PR[i]=OrderOpenPrice();
         SL[i]=OrderStopLoss();
         TP[i]=OrderTakeProfit();
         cmd=OrderType();
         if(cmd<2)
           {
            c++;
           }
         else
           {
            if(cmd>1 && cmd<6)
              {
               f++;
              }
           }
        }
     }
   g=c;
   r=f;
   v=i;
   if(i==0) v=1;
//--------------------------------------------------------------- for closed and cancelled orders
   if(h!=H)
     {
      if(t==1)
        {
         for(i=H-1; i>H-20; i--)
           {
            if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true)
              {
               date=OrderCloseTime();
               if(time<date)
                 {
                  cmd=OrderType();
                  d=TimeToStr(date,TIME_DATE|TIME_MINUTES|TIME_SECONDS);
                  symbol=OrderSymbol();
                  digits=(int)MarketInfo(symbol,MODE_DIGITS);
                  price=OrderClosePrice();
                  p=DoubleToStr(price,digits);
                  stop=OrderStopLoss();
                  sl=DoubleToStr(stop,digits);
                  take=OrderTakeProfit();
                  tp=DoubleToStr(take,digits);
                  if(Market==true && cmd<2)
                    {
                     q="Order "+type[cmd]+" closed.";
                     text=type[cmd]+"   "+symbol+"   sl: "+sl+"   tp: "+tp+"    "+d+"    at: "+p;
                     Comment(q,"\n",text);//b=SendMail(q,text);
                     if(b==false)
                       {
                       // error=GetLastError();
                       // Alert("The notification by an order "+text+" has not been sent!\nError: "+ErrorDescription(error)+"");
                       }
                    }
                  else
                    {
                     if(Pending==true && cmd>1 && cmd<6)
                       {
                        q="Order "+type[cmd]+" cancelled.";
                        price=OrderOpenPrice();
                        p=DoubleToStr(price,digits);
                        text=type[cmd]+"   "+symbol+"   at: "+p+"   sl: "+sl+"   tp: "+tp+"    "+d;
                        Comment(q,"\n",text);//b=SendMail(q,text);
                        if(b==false)
                          {
                          // error=GetLastError();
                          // Alert("The notification by an order "+text+" has not been sent!\nError: "+ErrorDescription(error)+"");
                          }
                       }
                    }
                 }
              }
           }
        }
      //----
      for(i=H-1; i>H-20; i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true)
           {
            date=OrderCloseTime();
            if(time<date) time=date;
           }
        }
     }
   t=1;
   return(0);
  }
//+------------------------------------------------------------------+
 
jfortes: Is there a command to create the Alerts in the terminal window ?
  1. Alert - MQL4 Documentation
  2. Alphabetic Index of MQL4 Functions (600+) - MQL4 forum
 

Thanks. But none of the examples creates conditional Alerts in the terminal windows.

How can I code a function for this ? 

 
jfortes: none of the examples creates conditional Alerts in the terminal windows.
if(condition) Alert(...);
 

Press Ctrl-T to access Terminal, click on tab "Alerts", in "Alerts" window right click for menu,

select "Create" and set up your condition.

Alternatively you could use push notification for messages between your expert and your

iphone/android mobile, see SendNotification() for limitations, you will require a MetaQuotes ID,

the messages are also notified in the Journal log. 

 
Thanks everyone. Will look in to the SendNotification() .
Reason: