EMA Alert help !!!!!!!!!!

 

Hi all,

Can someone help me with the below EMA crossover alert ?

I used it on a 5 mins chart and it is generating alot of email alerts. How can i reduce it ?? Please help !!!!!! Thanks...

=========================================================

//---- input parameters

extern int FastEMA=3;

extern int SlowEMA=34;

extern int SlowEM2=89;

double FASTEMACURRENT,FASTEMAPREVIOUS,SLOWEMACURRENT,SLOWEMAPREVIOUS;

double SLOWEMACURRENT2,SLOWEMAPREVIOUS2;

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

int start()

{

FASTEMACURRENT=iMA(NULL,0,3,0,MODE_EMA,PRICE_CLOSE,0);

FASTEMAPREVIOUS=iMA(NULL,0,3,0,MODE_EMA,PRICE_CLOSE,1);

SLOWEMACURRENT=iMA(NULL,0,34,0,MODE_EMA,PRICE_CLOSE,0);

SLOWEMAPREVIOUS=iMA(NULL,0,34,0,MODE_EMA,PRICE_CLOSE,1);

SLOWEMACURRENT2=iMA(NULL,0,89,0,MODE_EMA,PRICE_CLOSE,0);

SLOWEMAPREVIOUS2=iMA(NULL,0,89,0,MODE_EMA,PRICE_CLOSE,1);

// EMA34 Crossover

if (FASTEMACURRENT > SLOWEMACURRENT && FASTEMAPREVIOUS < SLOWEMAPREVIOUS)

{

SendMail(Symbol()+" 34EMA Bullish",Symbol()+" 34EMA Cross Up");

}

if (FASTEMACURRENT SLOWEMAPREVIOUS)

{

SendMail(Symbol()+" 34EMA Bearish",Symbol()+" 34EMA Cross Down");

}

// EMA89 Crossover

if (FASTEMACURRENT > SLOWEMACURRENT2 && FASTEMAPREVIOUS < SLOWEMAPREVIOUS2)

{

SendMail(Symbol()+" 89EMA Bullish",Symbol()+" 89EMA Cross Up");

}

if (FASTEMACURRENT SLOWEMAPREVIOUS2)

{

SendMail(Symbol()+" 89EMA Bearish",Symbol()+" 89EMA Cross Down");

}

}

return (0);

=========================================================

 
compro99:
Hi all,

Can someone help me with the below EMA crossover alert ?

I used it on a 5 mins chart and it is generating alot of email alerts. How can i reduce it ?? Please help !!!!!! Thanks...

=========================================================

//---- input parameters

extern int FastEMA=3;

extern int SlowEMA=34;

extern int SlowEM2=89;

double FASTEMACURRENT,FASTEMAPREVIOUS,SLOWEMACURRENT,SLOWEMAPREVIOUS;

double SLOWEMACURRENT2,SLOWEMAPREVIOUS2;

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

int start()

{

FASTEMACURRENT=iMA(NULL,0,3,0,MODE_EMA,PRICE_CLOSE,0);

FASTEMAPREVIOUS=iMA(NULL,0,3,0,MODE_EMA,PRICE_CLOSE,1);

SLOWEMACURRENT=iMA(NULL,0,34,0,MODE_EMA,PRICE_CLOSE,0);

SLOWEMAPREVIOUS=iMA(NULL,0,34,0,MODE_EMA,PRICE_CLOSE,1);

SLOWEMACURRENT2=iMA(NULL,0,89,0,MODE_EMA,PRICE_CLOSE,0);

SLOWEMAPREVIOUS2=iMA(NULL,0,89,0,MODE_EMA,PRICE_CLOSE,1);

// EMA34 Crossover

if (FASTEMACURRENT > SLOWEMACURRENT && FASTEMAPREVIOUS < SLOWEMAPREVIOUS)

{

SendMail(Symbol()+" 34EMA Bullish",Symbol()+" 34EMA Cross Up");

}

if (FASTEMACURRENT SLOWEMAPREVIOUS)

{

SendMail(Symbol()+" 34EMA Bearish",Symbol()+" 34EMA Cross Down");

}

// EMA89 Crossover

if (FASTEMACURRENT > SLOWEMACURRENT2 && FASTEMAPREVIOUS < SLOWEMAPREVIOUS2)

{

SendMail(Symbol()+" 89EMA Bullish",Symbol()+" 89EMA Cross Up");

}

if (FASTEMACURRENT SLOWEMAPREVIOUS2)

{

SendMail(Symbol()+" 89EMA Bearish",Symbol()+" 89EMA Cross Down");

}

}

return (0);

=========================================================

Add this at the end of your indicator

bool NewBar()

{

static datetime dt = 0;

if (dt != Time[0])

{

dt = Time[0]; Sleep(100); // wait for tick

return(true);

}

return(false);

}

and change SendMail to this if (NewBar()) SendMail .........

 

Elihayun,

How do i do that ? I am not so good in programming.

Kinda confused with the new add on. Will it works in 1hr chart too ?

Please help to piece up. Thanks you.

 
compro99:
Elihayun,

How do i do that ? I am not so good in programming.

Kinda confused with the new add on. Will it works in 1hr chart too ?

Please help to piece up. Thanks you.

post it here as an attachment, I will correct it for u

 

Elihayun,

I appreciate your kind help. For your information, i would be using this EA for 30mins and 1 hour chart.

I would like to get email alert when EMA3 crossover EMA34 and EMA3 crossover EMA89. I would not want any repeated alert. I know the repeated alerts was due to current bar moving up/down when price increases/decreases.

Thanks for the help again.

Files:
emaalert.mq4  2 kb
 
compro99:
Elihayun,

I appreciate your kind help. For your information, i would be using this EA for 30mins and 1 hour chart.

I would like to get email alert when EMA3 crossover EMA34 and EMA3 crossover EMA89. I would not want any repeated alert. I know the repeated alerts was due to current bar moving up/down when price increases/decreases.

Thanks for the help again.

I just aded the code to prevent multiple alert/email. I didn't change the rest

Files:
 

Will there be any implication if the ema crossup and then quick reverse crossdown ?

Will it affect the alert ? Jus curious... based on yr programming experience.

 
compro99:
Will there be any implication if the ema crossup and then quick reverse crossdown ? Will it affect the alert ? Jus curious... based on yr programming experience.

if this will be in the same bar ( I mean if the cross up will start u will get an alert. If the bar will not close and a reverse apears, u will not get another alert. U right then.

 

Elihayun,

I still got alot of repeated alerts within the same bar. Could u please help to see if there is any logic errors ? Thanks alot

 
compro99:
Elihayun, I still got alot of repeated alerts within the same bar. Could u please help to see if there is any logic errors ? Thanks alot

Did u compile my version?

I noticed that this is not an indicator, its EA. I put it in my demo account and I will see what will be

 

Yes, it is an EA. I did compile it and get lot of alerts.

I made some indication in the outputs to show it is a new compiled version.

Reason: