Why are my string variable not showing in my email body of a SendMessage() function?

 

Morning all,

I have an email function whereby an email is to be send with the initialisation status pertaining to certain variables in the email body.

Here is the code below, which is in the OnInit() section, why is the name of the EA not showing in the email?

The result is in the attached.

int      hourOfDay = Hour();
int      startingHour = 12;
bool     BarTime;
string   eaName = WindowExpertName();
bool     InitOrders;
bool     InitTime;


int OnInit()
{
   lastStamp = 0;
   GetMarketInfo_PerSymbol(Symbol(), true);
   fEvents(MODE_INIT);
   
   InitOrders = OrdersTotal();
   
   if(InitOrders == 0){
   
      InitOrders = true;
      Print("EA has been initialised to true");
   
   }else{
   
      InitOrders = false;
      Print("EA has been initialised to false");
   
   }
         
   if(InitTime = hourOfDay >= startingHour && hourOfDay < 20){
   
      InitTime = true;
      Print("Trades will be placed");
      SendMail("Initialisation confirmation: "+(eaName),"EA Name: "+(eaName)+"\n\nInitTime Status: Trades will be placed\n\nInitOrders: "+(InitOrders == True? "You have no open positions" : "You have an open position"));   
   
   }else{
   
      InitTime = false;
      Print("Trades will not be placed.");
      MessageBox("Trades will not be placed until "+IntegerToString(startingHour - 2,0)+"AM GMT","Important Information",MB_OK|MB_ICONINFORMATION|MB_TOPMOST);
      SendMail("Initialisation confirmation: "+(eaName),"EA Name: "+(eaName)+"\n\nInitTime Status: Trades will not be placed\n\nInitOrders: "+(InitOrders == True? "You have no open positions" : "You have an open position"));
   }
   
   BarTime=Time[0];
   
return(INIT_SUCCEEDED);

} 
Files:
 
int      hourOfDay = Hour();int OnInit(){
⋮
   GetMarketInfo_PerSymbol(Symbol(), true);
   InitOrders = OrdersTotal();

That is not an assignment; it's initialization of a common (globally declared), or static variable with a constant. They work exactly the same way in MT4/MT5/C/C++.

  1. They are initialized once on program load.

  2. They don't update unless you assign to them.

  3. In C/C++ you can only initialize them with constants, and they default to zero. In MTx you should only initialize them with constants. There is no default in MT5, or MT4 with strict (which you should always use).

    MT4/MT5 actually compiles with non-constants, but the order that they are initialized is unspecified and

    Don't try to use any price or server related functions in OnInit (or on load), as there may be no connection/chart yet:

    1. Terminal starts.
    2. Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
    3. OnInit is called.
    4. For indicators OnCalculate is called with any existing history.
    5. Human may have to enter password, connection to server begins.
    6. New history is received, OnCalculate called again.
    7. New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
 
William Roeder:

That is not an assignment; it's initialization of a common (globally declared), or static variable with a constant. They work exactly the same way in MT4/MT5/C/C++.

  1. They are initialized once on program load.

  2. They don't update unless you assign to them.

  3. In C/C++ you can only initialize them with constants, and they default to zero. In MTx you should only initialize them with constants. There is no default in MT5, or MT4 with strict (which you should always use).

    MT4/MT5 actually compiles with non-constants, but the order that they are initialized is unspecified and

    Don't try to use any price or server related functions in OnInit (or on load), as there may be no connection/chart yet:

    1. Terminal starts.
    2. Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
    3. OnInit is called.
    4. For indicators OnCalculate is called with any existing history.
    5. Human may have to enter password, connection to server begins.
    6. New history is received, OnCalculate called again.
    7. New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.

Hello.

Thanks for your comment but "eaName" is a globally declared variable. All other information is sent without a hitch to my email except strong formatted-variables. For some reason, my EA is not liking only string-formatted variables. 

Reason: