Exec1
Download scriptThis script serves as a bridge between the MetaTrader trading platform and your computer's external operating system. Instead of performing internal trading calculations or analyzing market charts, its primary purpose is to trigger an external command or file automatically when executed.
Core Functionality
The logic follows a simple "trigger and launch" sequence:
- External Communication: The script utilizes a specialized library (a Dynamic Link Library, or DLL) that allows MetaTrader to communicate with your Windows environment. This enables the platform to perform actions it normally cannot do on its own, such as opening files or running system programs.
- Command Execution: When you run this script, it is specifically programmed to locate and launch a batch file (
.bat) located at a specific path on your hard drive. - Automation Bridge: By using this script, the user can create an automated workflow where a manual action within MetaTrader (clicking "Run") immediately initiates a secondary process outside of the trading software. This is commonly used to launch auxiliary tools, specialized utilities, or pre-configured system scripts that support the trading environment.
Summary of Operation
In short, this script acts as a "remote control" button. When activated, it sends a signal to your computer to open a specific external file at a predefined location, allowing for seamless integration between your trading software and your local workspace.
//+------------------------------------------------------------------+
//| Exec1.mq4 |
//| Copyright © 2008, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#import "runapp4.dll"
bool Exec2(string exename,string params);
bool Exec2a(string exename,string params);
bool Exec2b(string exename,string params);
#import
//#import "Shell32.dll"
//int ShellExecuteA(int Handle, string Operation, string filename, string parametr, string dir, int ShowCmd);
//#import "bgexec.dll"
// bool ExecCmd(string lpCmdLine, int& lpExitCode[], int dwTimeOut, bool bTerminate);
// bool App2(string lpCmdLine,string lpParam);
//#import
//bool rv=ExecCmd("C:\\Program Files\\Far\\far.exe",RetCode,-1,false);
/*
#import "bgexec.dll"
bool ExecCmd(string lpCmdLine, int& lpExitCode, int dwTimeOut, bool bTerminate);
#import
int start(){
int RetCode;
bool rv=ExecCmd("C:\\Program Files\\Winamp\\winamp.exe",RetCode,-1,false);
return(0);
}
*/
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
//----
// Exec1("notepad.exe","");
// ShowForm();
//ShellExecuteA(0, "", "Notepad", "c:/1.txt", "", 1);
//ShellExecuteA(0, "", "R:\svmlib1 b4_dd_3.bat", "", "", 1);
int RetCode[1];
//bool rv=ExecCmd("C:\\Program Files\\Far\\far.exe",RetCode,-1,false);
//bool rv=ExecCmd("R:\svmlib1 b4_dd_3.bat",RetCode,-1,false);
//App2("R:/svmlib1/b4_dd_3.bat","");
Exec2b("R:/svmlib1/b4_dd_3.bat","");
//----
return(0);
}
//+------------------------------------------------------------------+
Comments