Search code examples
mt4

Can MT4 send an email, when a trade S/L is triggered, as an example?


Morning all,

Just wanting to ask, is it possible to be able to send an email with the outcome of your trade details ( i.e. your loss, trade number and account number ) when your S/L is triggered?

I know this will need to be achieved through the OrderSelect() function with the MODE_HISTORY.

Also, I want to be clear, I'm not asking anybody to write the code for me, I know this isn't a "charity site" but just wanted to now if it were possible?


Solution

  • Yes, that is perfectly possible.

    1. ENABLE sending emails in MetaTrader Terminal 4 settings, incl. target ( constant ) address enter image description here

    2. CLICK Test to send a testing-message, to have an End-to-End email PASS / FAIL proof

    3. DESIGN a "sender"-factory as void notifyByEMAIL( const string InfSTRING ){...} as flexible as you wish to have, using SendMail( aSubjectSTR, aBodySTR );

    4. DESIGN a "scanner"-utility function, embedding the XTO-domain event-scans ( with some built-in self-integrity and persistence tools, not to report the same XTO-event next time etc. ), re-using the sender-factory:
      void scanRecentXtoEventsToNOTIFY(){... /*notifyByEMAIL( anEventDETAILs );*/ ... }