Navigation:Home > Content >

b-SendMail.mqh

Time: 2010-04-10 | Download file:b-SendMail.mqh

extern string _P_b_SendMail = "---------- Parameters of module b-SendMail";
extern bool UseSendMail       = False;    
extern bool SendAccountNumber = True;    
extern bool SendAccountServer = True;    
extern bool SendNameExpert    = True;    
extern bool SendDateTime      = True;   
extern bool UseTimeLocal      = True;   
extern bool SendTicket        = False; 
extern bool SendMagic         = True;   
extern bool SendComment       = True;   


int    bsmOTI[];             // тикет   OrderTicket()
int    bsmOTY[];             // тип     OrderType()
double bsmOOP[];             // цена    OrderOpenPrice()
double bsmOSL[];             // стоп    OrderStopLoss()
double bsmOTP[];             // тейк    OrderTakeProfit()
bool   bsmFirstRun=True;     // Флаг первого прогона


void AccountState() {
  double p;                
  int    d;               
  int    i;                
  int    in;               
  int    k=OrdersTotal();  
  int    ot;               
  int    oti[];             
  string sh="";             
  string st;                

  if (bsmFirstRun) { MemCurrOP(); bsmFirstRun=False; }
  if (SendAccountNumber) sh=DoubleToStr(AccountNumber(), 0)+" ";
  if (SendAccountServer) sh=sh+AccountServer();
  if (StringLen(sh)>0) sh=sh+"\n";
  if (SendDateTime) {
    if (UseTimeLocal) sh=sh+TimeToStr(TimeLocal(), TIME_DATE|TIME_MINUTES)+" ";
    else sh=sh+TimeToStr(TimeCurrent(), TIME_DATE|TIME_SECONDS)+" ";
  }
  if (SendNameExpert) sh=sh+WindowExpertName()+" ";
  if (StringLen(sh)>0) sh=sh+"\n";
  
  ArrayResize(oti, k);
  for (i=0; i=p) {
            st=st+" PR="+DoubleToStr(bsmOOP[in], d)+"->"+DoubleToStr(OrderOpenPrice(), d);
          }
          if (MathAbs(OrderStopLoss()-bsmOSL[in])>=p) {
            st=st+" SL="+DoubleToStr(bsmOSL[in], d)+"->"+DoubleToStr(OrderStopLoss(), d);
          }
          if (MathAbs(OrderTakeProfit()-bsmOTP[in])>=p) {
            st=st+" TP="+DoubleToStr(bsmOTP[in], d)+"->"+DoubleToStr(OrderTakeProfit(), d);
          }
          st=st+IIFs(SendMagic || SendComment, "\n", "")
               +IIFs(SendMagic, "Magic="+DoubleToStr(OrderMagicNumber(), 0), "")
               +IIFs(SendMagic && SendComment, " ", "")
               +IIFs(SendComment, "Comment=\""+OrderComment()+"\"", "")
               +IIFs(SendMagic || SendComment, "\n", "");
          if (StringLen(sh)>0) st=sh+st;
          SendMail(WindowExpertName(), st);
        }
      }
    }
  }

  k=ArraySize(bsmOTI);
  for (i=0; i        

Recommend