Skip to content

micclly/mt4-script-caller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mt4-script-caller

This is script caller class library for MetaTrader4 (only for build 600 and later).

This library enables script calling from indicators and expert advisors.

Installation

  1. Copy MQL4\Libraries\ScriptCaller.dll to <MT4_DATA_FOLDER>\MQL4\Libraries\
  2. Copy MQL4\Include\ScriptCaller.class.mqh to <MT4_DATA_FOLDER>\MQL4\Include\

How to

  1. Add the following include line to your indicator or expert advisor

    #include <ScriptCaller.class.mqh>
  2. 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;
        }
    }
  3. Finally, put the following code to call script!

    g_scriptCaller.callScript("ScriptName"); // Do not end with .mq4
  4. 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.

Samples

Under MQL4\Indicators, 2 sample indicators, which calls scripts under MQL4\Scripts.

License

This software is licensed under GNU General Public License Version 3.

About

MT4 script calling library

Resources

License

Stars

Watchers

Forks

Packages

No packages published