Hi all,
Is it possible to run a script outside metatrader, eg from vba?
Of course, you can run a VBA script in Windows . . . what does this have to do with MT4 or mql4 ? if you want to run a script written in mql4 you need to run it in MT4.
My apologies i wasnt very clear, can i run a mt4 script from vba?
#include <WinUser32.mqh> #import "user32.dll" int GetAncestor(int, int); #import bool Shell(string file, string parameters=""){ #define DEFDIRECTORY NULL #define OPERATION "open" // or print #define SW_SHOWNORMAL 1 int r=ShellExecuteA(0, OPERATION, file, parameters, DEFDIRECTORY, SW_SHOWNORMAL); if (r <= 32){ Alert("Shell failed: ", r); return(false); } return(true); }
Figure out when it has completed is up to you.
Such as A DLL-free solution to communicate between MetaTrader 5 terminals using Named Pipes - MQL5 Articles and Named Pipes Client in MQL4 and Server in C++ - MQL4 forum
There was also a post/article about create process call and reading the result from the pipe.
Start the script.
Figure out when it has completed is up to you.
Such as A DLL-free solution to communicate between MetaTrader 5 terminals using Named Pipes - MQL5 Articles and Named Pipes Client in MQL4 and Server in C++ - MQL4 forum
There was also a post/article about create process call and reading the result from the pipe.
Hi,
I'm trying to get mt4 Data into Excel,
& i have a mt4 Script that writes the CSV files i need. (see attached)
- But i'm wanting to run the script from a vba excel command.
( i'm to new to it right now for deep troubleshooting and trying to get the basic functionality running.)
I'm wondering if you (or someone else with insight) can provide some direction.
- If i add this code at the beginning of the mt4 script, how do i call it with VBA/ CMD prompt?
Regards,
Read the documentation on launching a Script in MetaTrader 4 via the command line configuration file.
- MetaTrader 4 Help → Tools → Configuration at Startup → The Expert and/or Script Single-Launch Settings

- www.metatrader4.com
Thank you
You are welcome!
Read the documentation on launching a Script in MetaTrader 4 via the command line configuration file.
- MetaTrader 4 Help → Tools → Configuration at Startup → The Expert and/or Script Single-Launch Settings
Hi,
I can get this process to open the terminal, and run the script on start up.
but that it, i can only get it to run once once.
(without closing the terminal manually & repeating the cmd process)
Do you have any ideas on how i can run the script multiple times (with the cmd prompt), while the terminal remains open?
*My Plan B, is to run the script on timed loop, but i'd rather call it manually with the vba / cmd process
- i am researching the named pipe solution solution also, but not clear on it yet
any ideas appreciated,
thx
There is no perfect solution.
- Either have the Script close the MetaTrader terminal via WinAPI calls.
- Or instead of a Script, make an Expert that constantly monitors an external source to serve as a signal to proceed with exporting the data. In other words use IPC - Inter Process Communications (e.g. responding to Windows Messaging with the OnChartEvent handler, or monitor for file existence on regular interval with the OnTimer handler, or other forms of IPC).
thx, i will work towards it.

- 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 all,
Is it possible to run a script outside metatrader, eg from vba?
Rgds