I am trying my hand on making an EA that will alert and send email. Essentially, I have copied and pasted together various bits that satisfy the logic I have in mind. However, when I compile in MT4, it gives errors and warnings.
Please if you can, do help.
Cheers:
//+------------------------------------------------------------------+
//| WPR ALERT.mq4 |
//| Copyright 2009, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2009, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
//---- input parameters
extern int periodWPR=14;
extern int HFEhigh1=-20;
extern int HFElow2=-80;
double WPR1,WPR2;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int start()
{
WPR1=iWPR(NULL,0,periodWPR,0);
WPR2=iWPR(NULL,0,periodWPR,1);
Comment("WPR(",periodWPR,") = ",WPR1,"\n",
"TYPE1SELL =",HFEhigh1,"\n",
"TYPE3BUY =",HFElow2);
static int LastAlert = 0;
if( LastAlert == 0 || LastAlert_1 < Bars )
{
Alert(alert_msg);
LastAlert = Bars;
}
bool AlertOnce(string alert_msg, int ref)
{
static int LastAlert_1 = 0;
static int LastAlert_2 = 0;
switch(ref)
{
case 1:
if( LastAlert_1 == 0 || LastAlert_1 < Bars )
{
Alert(alert_msg);
LastAlert_1 = Bars;
return (1);
}
break;
case 2:
if( LastAlert_2 == 0 || LastAlert_2 < Bars )
{
Alert(alert_msg);
LastAlert_2 = Bars;
return (1);
}
break;
}
}
if(WPR2 >HFEhigh1 && WPR1 <HFEhigh1)
{
AlertOnce("WPR >",HFEhigh1,"...TYPE1SELL ", Symbol()); Sleep(100);
SendMail(Symbol()+" SELL", Symbol()+"SELL TIME ");
}
if(WPR2 < HFElow2 && WPR1 > HFElow2 )
{
AlertOnce("WPR <",HFElow2,"... TYPE3BUY ", Symbol());
Sleep(100);
SendMail(Symbol()+" BUY", Symbol()+" BUY TIME ");
}
}
return(0);
Please if you can, do help.
Cheers:
//+------------------------------------------------------------------+
//| WPR ALERT.mq4 |
//| Copyright 2009, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2009, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
//---- input parameters
extern int periodWPR=14;
extern int HFEhigh1=-20;
extern int HFElow2=-80;
double WPR1,WPR2;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int start()
{
WPR1=iWPR(NULL,0,periodWPR,0);
WPR2=iWPR(NULL,0,periodWPR,1);
Comment("WPR(",periodWPR,") = ",WPR1,"\n",
"TYPE1SELL =",HFEhigh1,"\n",
"TYPE3BUY =",HFElow2);
static int LastAlert = 0;
if( LastAlert == 0 || LastAlert_1 < Bars )
{
Alert(alert_msg);
LastAlert = Bars;
}
bool AlertOnce(string alert_msg, int ref)
{
static int LastAlert_1 = 0;
static int LastAlert_2 = 0;
switch(ref)
{
case 1:
if( LastAlert_1 == 0 || LastAlert_1 < Bars )
{
Alert(alert_msg);
LastAlert_1 = Bars;
return (1);
}
break;
case 2:
if( LastAlert_2 == 0 || LastAlert_2 < Bars )
{
Alert(alert_msg);
LastAlert_2 = Bars;
return (1);
}
break;
}
}
if(WPR2 >HFEhigh1 && WPR1 <HFEhigh1)
{
AlertOnce("WPR >",HFEhigh1,"...TYPE1SELL ", Symbol()); Sleep(100);
SendMail(Symbol()+" SELL", Symbol()+"SELL TIME ");
}
if(WPR2 < HFElow2 && WPR1 > HFElow2 )
{
AlertOnce("WPR <",HFElow2,"... TYPE3BUY ", Symbol());
Sleep(100);
SendMail(Symbol()+" BUY", Symbol()+" BUY TIME ");
}
}
return(0);