Given the following, hypothetically of course:
//+------------------------------------------------------------------+
//| ALERT.mq4 |
//| Copyright 2006, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2006, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double Near = iMA(NULL,0,15,0,MODE_EMA,PRICE_CLOSE,0);
double PriceNow = Bid;
if (PriceNow > Near)
{
SendMail("From FX Data","Price > 15EMA!!!");
}
else if (PriceNow < Near)
{
SendMail("From FX Data","Price < 15EMA!!!");
}
return(0);
}
This will send an alert email when the price is greater than the 15EMA. This isn't the actual code of course it's just an example. I'm guessing I need an array in here somewhere to count how many times that alert will be sent when the condition(s) is met. I'm still not up the array mql chapter...This leads to another question, if the email is to be sent only once, would the indicator have to be loaded on the chart again to be active again? What I'd really like is the email to be sent once and a message box come up prompting me to 'Click OK to reload indicator" without having to drag it back on the chart window again...
//+------------------------------------------------------------------+
//| ALERT.mq4 |
//| Copyright 2006, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2006, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double Near = iMA(NULL,0,15,0,MODE_EMA,PRICE_CLOSE,0);
double PriceNow = Bid;
if (PriceNow > Near)
{
SendMail("From FX Data","Price > 15EMA!!!");
}
else if (PriceNow < Near)
{
SendMail("From FX Data","Price < 15EMA!!!");
}
return(0);
}
This will send an alert email when the price is greater than the 15EMA. This isn't the actual code of course it's just an example. I'm guessing I need an array in here somewhere to count how many times that alert will be sent when the condition(s) is met. I'm still not up the array mql chapter...This leads to another question, if the email is to be sent only once, would the indicator have to be loaded on the chart again to be active again? What I'd really like is the email to be sent once and a message box come up prompting me to 'Click OK to reload indicator" without having to drag it back on the chart window again...