can I run an external scrtipt from EA?

 
for example OrderClose. instead of closing the order in the EA I want it to run an external script that closes the order (by giving some parameters to it). In this case if the trade closes slowly it doesnt slow down the EA, it still executes on next tick but the script loops until the trade is closed. Is this possible?

Second question about Init(), could it be that if I even use return(-1) the init still executes OK and EA runs? How can I kill the EA if something is wrong and exit it for good? So that it wouldn't execute on next tick again..
 
Try doing "Inter-process" communication between EA and scripts.

the simplest way to achieving this is via isuing the commands/parameters onto a file and the slave process to fetch the parameters there.

Just have those scripts running all over on another chart (any charts). and each script homed for a particular filename.

ie, script ABCDE.mq4 looks for file ABCDE.txt file for commands
ie, script XYZ.mq4 looks for XYZ.txt file for commands.

.
.
.
.
.
its that simple!
 
thanks for your response, but that's not what I want. :(

here is a quote from another forum how to do a workaround:
quoting "jhernandez": You can assign a hotkey to your script, and then have your EA simulate 'pressing' the hotkey which will trigger your script to run as a process outside of your EA. That way the EA and the script are independent of each other.

This should give you a 'poor mans' version of multi threading in Metatrader.


Is this the only way? Slawa, what do you think about it?
 
Ahh yes, the "HOT KEY" approach.

I personally would not recommend doing this. You need to have your MT4 focused all the time. AND secondly, the Script will execute only on the highlighted/focused Chart. IF you have your EA running on 5 pairs, and you want to delegate some commands to another script, how do you think your EA running on EURUSD, invoke an external script to run for EURUSD too when the focused chart is GBPUSD? Your EA will invoke the script to run on GBPUSD! Likewise, you dont even have any "parameters" to pass to this script.

Buttom line, this will be a wrong way to doing it. Of course you can go on with this suggestion and dig up on kernel32.dll for ways to "PUSH KEYS" into the keyboard buffer.

Again, this hotkey solution SUCK. While there is no formal way given by Metaquotes to solve your problem, the "file solution" *IS* the best way to go.
 
OK, thanks man. :)
Reason: