Hi, I have a simple EA and I would like to add the email alert function to it so that the EA can send me notification email once a trade is opened or closed. I have read several posts and used some codes provided by Nicholi Shen in my codes, however, things didn't work out the way I would it like to. For example, I tried to add SendMail function to my open position logic so that an email would be sent to me every time a trade is opened, but the EA fails to do so. And oftentimes I only see many error messages in my journal for either trade opening or trade close--"Mail: not enough space for ' ' ". I don't understand why this happened, was it due to my syntax or something else? I would appreciate if anyone could take a look at my codes and tell me how I can fix it so I can receive Email notification properly.
P.S. I have greyed out some of my attempts at it in the codes, none of my attempts has worked so far. Please help!
I looks like you have the args mixed up. The first arg is the subject and should be a short string e.g. "MyEA new order", and then you put the rest of the info into the body of the email (2nd param).
SendMail(subject, message_body);
I looks like you have the args mixed up. The first arg is the subject and should be a short string e.g. "MyEA new order", and then you put the rest of the info into the body of the email (2nd param).
Hi, Shen, nice to hear from you, you mean I should just edit the SendMail function in my OPSELL() and OPBUY()? All I need to do it just to make the subject shorter? I have been scratching my head over it for a week now. It always comes with a "Mail: not enough space for 'Email subject here' " error in my journal, I would really appreciate if you can give me more detailed advice here.
I looks like you have the args mixed up. The first arg is the subject and should be a short string e.g. "MyEA new order", and then you put the rest of the info into the body of the email (2nd param).
Hi Shen, I made the Subject in my SendMail very short per your advice, only "My new order", but when I run it, I keep getting the error message "Mail: not enough space for 'My new order' ", do you know what may cause this? Thanks!
I looks like you have the args mixed up. The first arg is the subject and should be a short string e.g. "MyEA new order", and then you put the rest of the info into the body of the email (2nd param).
Hi Shen, I tested it again, and found that the email alert in OPBUY() and OPSELL() works fine. What seems to be causing the problem is the email alert in your old codes, during my trial, the EA only opened two buy orders, but I keep receiving tons of emails with subjects ""CLOSE pr: "+DoubleToStr(OrderProfit(),2)+", bal: "+DoubleToStr(AccountBalance(),2)+", eq: "+DoubleToStr(AccountEquity(),2)+"" from your old codes. Could you instruct me on how I should set it up so that it only sends me one email alert once a position is closed instead of keeping updating my trades even when there aren't any orders closed? Thanks very much!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, I have a simple EA and I would like to add the email alert function to it so that the EA can send me notification email once a trade is opened or closed. I have read several posts and used some codes provided by Nicholi Shen in my codes, however, things didn't work out the way I would it like to. For example, I tried to add SendMail function to my open position logic so that an email would be sent to me every time a trade is opened, but the EA fails to do so. And oftentimes I only see many error messages in my journal for either trade opening or trade close--"Mail: not enough space for ' ' ". I don't understand why this happened, was it due to my syntax or something else? I would appreciate if anyone could take a look at my codes and tell me how I can fix it so I can receive Email notification properly.
P.S. I have greyed out some of my attempts at it in the codes, none of my attempts has worked so far. Please help!