Script to Send Emails

 

Hi GUys,

How can I add script in EA so that it sends an email when ever there is a signal to BUY or SELL....

Thanks

Babar

 

This should get you started.

Maji

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

//| EMailSignals.mq4 |

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

#property copyright "Sample"

#property link "Sample"

extern int RSIPeriod=14;

extern int RSIPrice=PRICE_CLOSE;

extern int MAFastPeriod=5;

extern int MAFastShift=0;

extern int MAFastMethod=MODE_SMA;

extern int MAFastPrice=PRICE_CLOSE;

extern int MASlowPeriod=10;

extern int MASlowShift=0;

extern int MASlowMethod=MODE_SMA;

extern int MASlowPrice=PRICE_CLOSE;

bool runnable=true;

bool initialize=true;

datetime timeprev=0;

int init()

{

return(0);

}

int deinit()

{

return(0);

}

int start()

{

//Runnable

if(runnable!=true)

return(-1);

//

//New Bar

//

if(timeprev==Time[0])

return(0);

timeprev=Time[0];

//

//Calculation

//

double fast01=iMA(NULL,0,MAFastPeriod,MAFastShift,MAFastMethod,MAFastPrice,1);

double fast02=iMA(NULL,0,MAFastPeriod,MAFastShift,MAFastMethod,MAFastPrice,2);

double slow01=iMA(NULL,0,MASlowPeriod,MASlowShift,MASlowMethod,MASlowPrice,1);

double slow02=iMA(NULL,0,MASlowPeriod,MASlowShift,MASlowMethod,MASlowPrice,2);

double rsi01=iRSI(NULL,0,RSIPeriod,RSIPrice,1);

double rsi02=iRSI(NULL,0,RSIPeriod,RSIPrice,2);

//Long

if(fast01>slow01&&fast02<slow02)

SendMail("MA Cross Long","MA crossed UP");

if(rsi01>50&&rsi02<50)

SendMail("RSI Cross Long","RSI crossed long 50");

//Shrt

if(fast01slow02)

SendMail("MA Cross Shrt","MA crossed DN");

if(rsi0150)

SendMail("RSI Cross Shrt","RSI crossed shrt 50");

return(0);

}

 
 

Thanks for your reply guys....still its not clear that what line do I have to enter in the EA for sending emails.....

Thanks

Babar

 

I Have tried sending email but in journalit say......

550 you are not allowed to send mail

can someone tell me why ?????

Thanks

Babar

 
babarmughal:
I Have tried sending email but in journalit say......

550 you are not allowed to send mail

can someone tell me why ?????

Thanks

Babar

Set email setting in Tools / Options / Email, make sure email setting are ok, like smtp server, account name and password, and make sure youe email service provider allow you to send email. Like we cann't use hotmail and yahoo accounts.

Also test if eveything is ok by press test.

 

Hi

I have tried everything ...but no luck....I am using North Finance...it could be that they dont support this option in DEMO...

Thanks

Babar

 
babarmughal:
Hi

I have tried everything ...but no luck....I am using North Finance...it could be that they dont support this option in DEMO...

Thanks

Babar

Hi Babar, check this thread https://www.mql5.com/en/forum/173821 maybe the problem is on your email setting. Hope this help

 

Dear all,

Hope I put my request in appropriate place. I'm not a programmer and need your help. Below is part of indicator (focused on e-mail notification) I started to use which I'd like you to help me to modify. I'm using different timeframes and need this info in alert very much.

What to change in the script to have:

1. e-mail title as follows:

"name" "timeframe" word word "direction"

eg.

EURUSD H1 ma cross UPTREND

Currently e-mail title is:

EURUSD ma cross

2. e-mail content as follows

"name" "timeframe" word word "direction" word "time" word "price"

EURUSD M30 ma cross UPTREND at 13:23 on 1,39245

HOW TO MODIFY IT ? PLS HELP

rgds

bqb

------------------------------------------------------------

message = StringConcatenate(Symbol()," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," ma cross ",doWhat);

if (alertsMessage) Alert(message);

if (alertsEmail) SendMail(StringConcatenate(Symbol()," ma cross "),message);