I can send a test email fine from mt4.
But I would like an email once an Expert Advisor places a trade. Is there a little line of code I could include in the EA. I would just like the subject of the email to be the pair traded, buy or sell and price traded.
Then another email would go when the EA closes with the pair traded and exit price.
I have looked here and elsewhere before posting this but I can't find the answer. Most focus on how to send email in mt4 generally. I've managed that.
Thanks in anticipation
You can check the return value of OrderSend() function and if it is true, you call the SendMail() Function to send out the email.
The same can be done with the OrderClose() function, but not if the SL/TP levels are hit in that case you did not use OrderClose() function,
But in that case you can still detect those closed orders by monitoring OrdersTotal() function and whenever something changes still send out the message.

- www.mql5.com
MT4 platform have an option for you to input your email server.
It should send you an email whenever a trade is made on your account.
You don't need to make an EA to send you email.
You can check the return value of OrderSend() function and if it is true, you call the SendMail() Function to send out the email.
The same can be done with the OrderClose() function, but not if the SL/TP levels are hit in that case you did not use OrderClose() function,
But in that case you can still detect those closed orders by monitoring OrdersTotal() function and whenever something changes still send out the message.
MT4 platform have an option for you to input your email server.
It should send you an email whenever a trade is made on your account.
You don't need to make an EA to send you email.
after I put the above functions, do I have the setting to serve email
What do you mean?
You check the return value of OrderSend() function if it was successful it returns the ticket number.
int ticket=OrderSend(.... if(ticket>0) { SendMail(.... }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
But I would like an email once an Expert Advisor places a trade. Is there a little line of code I could include in the EA. I would just like the subject of the email to be the pair traded, buy or sell and price traded.
Then another email would go when the EA closes with the pair traded and exit price.
I have looked here and elsewhere before posting this but I can't find the answer. Most focus on how to send email in mt4 generally. I've managed that.
Thanks in anticipation