Code needed to send an email detailing the last closed order in Order History - MT4

Back to topics list To post a new topic, please log in or register
avatar
6
thecody1000 2015.09.16 10:24
 
Hi all.

I'm wondering how to code my EA so an E-mail will be sent detailing items such as the close price and the Order# from the Trade History, everytime an Open Order is closed (and therefore goes into the History ledger).

I will not be having multiple trades open either.

Am I correct in thinking this can be from the Order Select function?

Any help much appreciated

Regards

Todd
avatar
106
4x_Gypsy 2015.09.16 12:22 #
 
   if(Hour()==0)
     {
      SendMail(Subject,
               "------------------------------------------"+"\n"+
               PrevCandle+"\n"+
               "Previous Daily Candle OHLC"+"\n"+
               "------------------------------------------"+"\n"+
               previousOpen+"\n"+
               previousHigh+"\n"+
               previousLow+"\n"+
               previousClose+"\n"+
               "------------------------------------------"+"\n"+
               "Pivot Points"+"\n"+
               "------------------------------------------"+"\n"+
               Res3+"\n"+
               Res2+"\n"+
               Res1+"\n"+
               ""+"\n"+
               Pivot+"\n"+
               ""+"\n"+
               Sup1+"\n"+
               Sup2+"\n"+
               Sup3+"\n"+
               "------------------------------------------"+"\n"+
               "Moving Average Values"+"\n"+
               "------------------------------------------"+"\n"+
               FastMA+"\n"+
               SlowMA+"\n"+
               "------------------------------------------"+"\n"+
               "Trend Information"+"\n"+
               "------------------------------------------"+"\n"+
               Trend
               );
     }

https://www.mql5.com/en/docs/common/sendmail


above is a example of what i use.

avatar
6
thecody1000 2015.09.16 15:04 #
 
OK great, thanks

Would this also be acceptable?


//if functions to be satisfied//
  {
   OpenShort = LotSize > MarketInfo(Symbol(),MODE_MINLOT) &&AccountFreeMarginCheck(Symbol(),OP_SELL,LotSize)>0;
   if(OpenShort == true) OpenShort = OrderSend(Symbol(),1,LotSize,Ask,3,0,0,NULL,MagicNumber,0,sellcolor);
   if(OpenShort == false) Sleep(__SLEEP_AFTER_EXECUTION_FAIL);
   if(OpenShort == true)
      {
      if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==true)
         {
         if(Digits == 5)
         if(ctm == 0)
         if(OrderMagicNumber() == MagicNumber)
         SendMail("Trade Notification Email (TNE)","Order# "+DoubleToStr(Ticket,0)+" has been placed on the account "+AccountName()+
         "\n"+
         "\nThe order entry price for this trade is "+DoubleToStr(OpenPrice,5)+
         "\n"+
         "\nThe spread charge for this position will be determined on the close of this trade"+
         "\n"+
         "This is an Autmated Message from Blue City Asset Management Limited");
        
         else if (Digits == 3)
         if(ctm == 0)
         if(OrderMagicNumber() == MagicNumber)
         SendMail("Trade Notification Email (TNE)","Order# "+DoubleToStr(Ticket,0)+" has been placed on the account "+AccountName()+
         "\n"+
         "\nThe order entry price for this trade is "+DoubleToStr(OpenPrice,3)+
         "\n"+
         "\nThe spread charge for this position will be determined on the close of this trade"+
         "\n"+
         "This is an Autmated Message from Blue City Asset Management Limited");
         }
      }
    }          
Back to topics list  

To add comments, please log in or register