You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi Guys
I have started creating an indicator with Email alert. Kind of stuck halfway. Is there anyone can complete this project. It will be a great help. Also happy to return the favor if coder can leave his details e.g email or contact along with address.
My file is attached. Below codes has to go in attached file along with email alert. Current code has email alert but as soon as the criteria met I kept getting email until as long as I dont close and delete the indicator from the MT4. Somehow require to code in a way that only get 1 alert once the criteria met. Indicator name is Money Flow Index, I would like this with email alert.
double ExtMFIBuffer[];
bool alreadyalerted=false;
string alertstr;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string sShortName;
//----
SetIndexBuffer(0,ExtMFIBuffer);
//---- indicator line
SetIndexStyle(0,DRAW_LINE);
//---- name for DataWindow and indicator subwindow label
sShortName="MFI("+ExtMFIPeriod+")";
IndicatorShortName(sShortName);
SetIndexLabel(0,sShortName);
//---- first values aren't drawn
SetIndexDrawBegin(0,ExtMFIPeriod);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Money Flow Index |
//+------------------------------------------------------------------+
int start()
{
int i,j,nCountedBars;
double dPositiveMF,dNegativeMF,dCurrentTP,dPreviousTP;
//---- insufficient data
if(Bars<=ExtMFIPeriod) return(0);
//---- bars count that does not changed after last indicator launch.
nCountedBars=IndicatorCounted();
//----
i=Bars-ExtMFIPeriod-1;
if(nCountedBars>ExtMFIPeriod)
i=Bars-nCountedBars-1;
while(i>=0)
{
dPositiveMF=0.0;
dNegativeMF=0.0;
dCurrentTP=(High[i]+Low[i]+Close[i])/3;
for(j=0; j<ExtMFIPeriod; j++)
{
dPreviousTP=(High[i+j+1]+Low[i+j+1]+Close[i+j+1])/3;
if(dCurrentTP>dPreviousTP)
dPositiveMF+=Volume[i+j]*dCurrentTP;
else
{
if(dCurrentTP<dPreviousTP)
dNegativeMF+=Volume[i+j]*dCurrentTP;
}
dCurrentTP=dPreviousTP;
}
//----
if(dNegativeMF!=0.0)
ExtMFIBuffer[i]=100-100/(1+dPositiveMF/dNegativeMF);
else
ExtMFIBuffer[i]=100;
//----
i--;
}
//----
if (ExtMFIBuffer[0] >= Overbought && alreadyalerted == false) {
alertstr = StringConcatenate("MFI is High for ", Symbol(), " M", Period());
if (alert == true)
Alert(alertstr);
if (emailAlert == true)
SendMail("MT4 Chart Alert", alertstr);
alreadyalerted = true;
}
else if (ExtMFIBuffer[0] <= Oversold && alreadyalerted == false) {
alertstr = StringConcatenate("MFI is Low for ", Symbol(), " M", Period());
if (alert == true)
Alert(alertstr);
if (emailAlert == true)
SendMail("MT4 Chart Alert", alertstr);
alreadyalerted = true;
}
else if (alreadyalerted == true) {
if (emailAlert == true) {
alertstr = StringConcatenate("MFI is back to Middle for ", Symbol(), " M", Period());
SendMail("MT4 Chart Alert", alertstr);
}
alreadyalerted = false;
}
return(0);
}
//+------------------------------------------------------------------+