MQL4 EA |为什么我的字符串变量没有包含在我的电子邮件正文中?
MQL4 EA | Why are my string variables not included in my email body?
好的,我收到了一封电子邮件,其中包含有关我的 EA 初始化状态的信息。
尽管声明了所有字符串变量,为什么我的字符串变量没有包含在我的电子邮件正文中?
int hourOfDay = Hour();
int startingHour = 12;
bool BarTime;
string eaName = WindowExpertName();
bool InitOrders;
bool InitTime;
string symbol = OrderSymbol();
int OnInit()
{
/*lastStamp = 0;
GetMarketInfo_PerSymbol(Symbol(), true);
fEvents(MODE_INIT);*/ /*Unrelated Code*/
InitOrders = OrdersTotal();
if(InitOrders == 0){
InitOrders = true;
Print("EA has been initialised to true");
}else{
InitOrders = false;
Print("EA has been initialised to false");
}
InitTime = (hourOfDay >= startingHour && hourOfDay < 20);
if(InitTime = true){
Print("Trades will be placed");
SendMail("Initialisation confirmation: "+(eaName),"Initialised by: User\n\nEA Name: "+(eaName)+"\n\nAsset: Forex CFD "+(symbol)+"\n\nDate of Initialisation "+TimeToString(TimeCurrent(),TIME_DATE | TIME_MINUTES)+" (This may differ from GMT)\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\n\nIf you feel this is incorrect, please email us at xxx","| Important Notification",MB_OK|MB_ICONINFORMATION|MB_TOPMOST);
SendMail("Initialisation confirmation: "+(eaName),"Initialised by: User\n\nEA Name: "+(eaName)+"\n\nAsset: Forex CFD "+(symbol)+"\n\nDate of Initialisation "+TimeToString(TimeCurrent(),TIME_DATE | TIME_MINUTES)+" (This may differ from GMT)\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);
}
你不应该在 header 中分配变量,它应该在 init 块中正确执行(这是你初始化的地方,可以正确分配变量)。您还在使用 OrderSymbol() 而未选择订单,因此它始终为空。
int hourOfDay;
int startingHour;
bool BarTime;
string eaName;
bool InitOrders;
bool InitTime;
string symbol;
int OnInit()
{
hourOfDay = Hour();
startingHour = 12;
eaName = WindowExpertName();
symbol = Symbol();
/*lastStamp = 0;
GetMarketInfo_PerSymbol(Symbol(), true);
fEvents(MODE_INIT);*/ /*Unrelated Code*/
InitOrders = OrdersTotal();
if(InitOrders == 0){
InitOrders = true;
Print("EA has been initialised to true");
}else{
InitOrders = false;
Print("EA has been initialised to false");
}
InitTime = (hourOfDay >= startingHour && hourOfDay < 20);
if(InitTime = true){
Print("Trades will be placed");
SendMail("Initialisation confirmation: "+(eaName),"Initialised by: User\n\nEA Name: "+(eaName)+"\n\nAsset: Forex CFD "+(symbol)+"\n\nDate of Initialisation "+TimeToString(TimeCurrent(),TIME_DATE | TIME_MINUTES)+" (This may differ from GMT)\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\n\nIf you feel this is incorrect, please email us at xxx","| Important Notification",MB_OK|MB_ICONINFORMATION|MB_TOPMOST);
SendMail("Initialisation confirmation: "+(eaName),"Initialised by: User\n\nEA Name:"+(eaName)+"\n\nAsset: Forex CFD "+(symbol)+"\n\nDate of Initialisation "+TimeToString(TimeCurrent(),TIME_DATE | TIME_MINUTES)+" (This may differ from GMT)\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);
}
好的,我收到了一封电子邮件,其中包含有关我的 EA 初始化状态的信息。
尽管声明了所有字符串变量,为什么我的字符串变量没有包含在我的电子邮件正文中?
int hourOfDay = Hour();
int startingHour = 12;
bool BarTime;
string eaName = WindowExpertName();
bool InitOrders;
bool InitTime;
string symbol = OrderSymbol();
int OnInit()
{
/*lastStamp = 0;
GetMarketInfo_PerSymbol(Symbol(), true);
fEvents(MODE_INIT);*/ /*Unrelated Code*/
InitOrders = OrdersTotal();
if(InitOrders == 0){
InitOrders = true;
Print("EA has been initialised to true");
}else{
InitOrders = false;
Print("EA has been initialised to false");
}
InitTime = (hourOfDay >= startingHour && hourOfDay < 20);
if(InitTime = true){
Print("Trades will be placed");
SendMail("Initialisation confirmation: "+(eaName),"Initialised by: User\n\nEA Name: "+(eaName)+"\n\nAsset: Forex CFD "+(symbol)+"\n\nDate of Initialisation "+TimeToString(TimeCurrent(),TIME_DATE | TIME_MINUTES)+" (This may differ from GMT)\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\n\nIf you feel this is incorrect, please email us at xxx","| Important Notification",MB_OK|MB_ICONINFORMATION|MB_TOPMOST);
SendMail("Initialisation confirmation: "+(eaName),"Initialised by: User\n\nEA Name: "+(eaName)+"\n\nAsset: Forex CFD "+(symbol)+"\n\nDate of Initialisation "+TimeToString(TimeCurrent(),TIME_DATE | TIME_MINUTES)+" (This may differ from GMT)\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);
}
你不应该在 header 中分配变量,它应该在 init 块中正确执行(这是你初始化的地方,可以正确分配变量)。您还在使用 OrderSymbol() 而未选择订单,因此它始终为空。
int hourOfDay;
int startingHour;
bool BarTime;
string eaName;
bool InitOrders;
bool InitTime;
string symbol;
int OnInit()
{
hourOfDay = Hour();
startingHour = 12;
eaName = WindowExpertName();
symbol = Symbol();
/*lastStamp = 0;
GetMarketInfo_PerSymbol(Symbol(), true);
fEvents(MODE_INIT);*/ /*Unrelated Code*/
InitOrders = OrdersTotal();
if(InitOrders == 0){
InitOrders = true;
Print("EA has been initialised to true");
}else{
InitOrders = false;
Print("EA has been initialised to false");
}
InitTime = (hourOfDay >= startingHour && hourOfDay < 20);
if(InitTime = true){
Print("Trades will be placed");
SendMail("Initialisation confirmation: "+(eaName),"Initialised by: User\n\nEA Name: "+(eaName)+"\n\nAsset: Forex CFD "+(symbol)+"\n\nDate of Initialisation "+TimeToString(TimeCurrent(),TIME_DATE | TIME_MINUTES)+" (This may differ from GMT)\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\n\nIf you feel this is incorrect, please email us at xxx","| Important Notification",MB_OK|MB_ICONINFORMATION|MB_TOPMOST);
SendMail("Initialisation confirmation: "+(eaName),"Initialised by: User\n\nEA Name:"+(eaName)+"\n\nAsset: Forex CFD "+(symbol)+"\n\nDate of Initialisation "+TimeToString(TimeCurrent(),TIME_DATE | TIME_MINUTES)+" (This may differ from GMT)\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);
}