Trade Alerts - I need to run an executable whenever a trade is opened or closed, any ideas

 
I'm running a system, I went to events and enabled them, then I enabled expert advisor and entered an executable file
that runs an alert that notifies me when a trade has taken place. It works when I close a position but it does not work when a position
is open. Is there anyway to run the executable in the main EA code or fix the events to run the alert whenever a trade is opened or closed.
Any help would be appreciated.
 
eliaslor:
I'm running a system, I went to events and enabled them, then I enabled expert advisor and entered an executable file
that runs an alert that notifies me when a trade has taken place. It works when I close a position but it does not work when a position
is open. Is there anyway to run the executable in the main EA code or fix the events to run the alert whenever a trade is opened or closed.
Any help would be appreciated.

Configure the 'Alert' event to run the executable file (via Tools > Options > Events Tab > ...). Then add Alert() statements (https://docs.mql4.com/common/Alert) when opening/closing trades in the code. The problem with this method is that the executable file will be launched for all Alert() statements (in any expert). Additionally, the Terminal has to be configured for this to work.


An alternative method is to launch the executable file via ShellExecuteA():

#import "shell32.dll"                                               
   int  ShellExecuteA(int hwnd, string Operation, string File, string Parameters, string Directory, int ShowCmd);
#import

//example of calling ShellExecuteA() to launch whatever.exe that resides in the MT4 folder  
int exec = ShellExecuteA(0, "open", "whatever.exe", "", TerminalPath(), 7);
if (exec <= 32) {
   //execution failed... do something
} 
 
gordon:

Configure the 'Alert' event to run the executable file (via Tools > Options > Events Tab > ...). Then add Alert() statements (https://docs.mql4.com/common/Alert) when opening/closing trades in the code. The problem with this method is that the executable file will be launched for all Alert() statements (in any expert). Additionally, the Terminal has to be configured for this to work.


An alternative method is to launch the executable file via ShellExecuteA():


Thanks Gordon,

Actually I finally figured out how to get it to work(I think). I put the executable in the Alert under options and events. Then I put brackets around
all open position and close position statements. So that if the condition was true it would open the position and then I put the alert on the next line and finally the end bracket. Its working good so far. Whenever the program opens or closes a position, my vb alert program, that plays a sound over and over again until you press the exit button - plays. This is good because I am manually trading another platform from metatrader signals, I don't want to have to continually watch the charts. This way when anything happens the alert will play until I turn it off and then I can make the trade on the other platform. Thanks for taking the time to comment.... Elias.
 
eliaslor:

[...] This is good because I am manually trading another platform from metatrader signals, I don't want to have to continually watch the charts. This way when anything happens the alert will play until I turn it off and then I can make the trade on the other platform.

We're currently testing a signal service which allows one or more subscribers to trade automatically when a broadcaster account trades (without needing to have access to the broadcaster's account via the MT4 "investor" password). Send me a PM if interested in testing this.

Reason: