This is script caller class library for MetaTrader4 (only for build 600 and later).
This library enables script calling from indicators and expert advisors.
- Copy
MQL4\Libraries\ScriptCaller.dll
to<MT4_DATA_FOLDER>\MQL4\Libraries\
- Copy
MQL4\Include\ScriptCaller.class.mqh
to<MT4_DATA_FOLDER>\MQL4\Include\
-
Add the following include line to your indicator or expert advisor
#include <ScriptCaller.class.mqh>
-
Add the following code to initialize/deinitialize class instance.
ScriptCaller* g_scriptCaller = NULL; int OnInit() { g_scriptCaller = new ScriptCaller(); return INIT_SUCCEEDED; } void OnDeinit(const int reason) { if (g_scriptCaller) { delete g_scriptCaller; } }
-
Finally, put the following code to call script!
g_scriptCaller.callScript("ScriptName"); // Do not end with .mq4
-
If the script shows input dialog, and you want to close it automatically, call as follows.
g_scriptCaller.callScript("ScriptName", true); // if the 2nd parameter is true, dialog will be closed automatically.
Under MQL4\Indicators
, 2 sample indicators, which calls scripts under MQL4\Scripts
.
This software is licensed under GNU General Public License Version 3.