ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Meta​Quotes (MQL4) Language Package

by currencysecrets ST2/ST3

MQL4 Snippets & Syntax for Sublime Text

Details

  • 2017.12.11.12.30.07
  • github.​com
  • github.​com
  • 2 years ago
  • 3 hours ago
  • 6 years ago

Installs

  • Total 5K
  • Win 4K
  • OS X 1K
  • Linux 610
Jul 21 Jul 20 Jul 19 Jul 18 Jul 17 Jul 16 Jul 15 Jul 14 Jul 13 Jul 12 Jul 11 Jul 10 Jul 9 Jul 8 Jul 7 Jul 6 Jul 5 Jul 4 Jul 3 Jul 2 Jul 1 Jun 30 Jun 29 Jun 28 Jun 27 Jun 26 Jun 25 Jun 24 Jun 23 Jun 22 Jun 21 Jun 20 Jun 19 Jun 18 Jun 17 Jun 16 Jun 15 Jun 14 Jun 13 Jun 12 Jun 11 Jun 10 Jun 9 Jun 8 Jun 7 Jun 6
Windows 1 1 0 1 3 3 3 1 2 3 1 3 0 0 1 5 0 2 3 1 4 0 2 3 2 6 6 0 2 3 1 3 2 3 3 2 2 0 4 1 1 0 1 2 1 2
OS X 2 0 1 1 0 1 0 2 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 2 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
Linux 1 1 0 0 0 1 0 0 1 0 1 0 0 0 0 1 0 2 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 1 0 1

Readme

Source
raw.​githubusercontent.​com

MetaQuotes Language Package (MQL4)

If you've been coding using MetaTrader for quite some time you've no doubt come across those times where you've experienced problems such as:

  • An unbalanced parentheses
  • Code that's too long which won't collapse
  • Renaming of variable and parameter names
  • Styling of the look and feel of the editor
  • Code hints not working or disappearing after selecting a function
  • Not enough detail and going to the MQL4 site to read the documentation only to find their site is down for maintenance

Yes, I've been there too.

I like MetaTrader though, but coding on their platform can be a real nightmare.

So, I decided to couple the best text editor in the world with the best automated forex trading language in the world. And you now have before you the result of a couple of weeks work in getting all aspects of the MQL4 language into a Sublime Text snippet package.

Installation/Updates

Package Control

The easiest way to install this package in Sublime Text is to use WBond's Package Control - https://sublime.wbond.net/

Once you have this installed, simply run Install Package and select MetaQuotes (MQL4) Language Package in the prompt.

Bang. You're done!

Manually

To install the package by ZIP file do:

  • Download the zip file either in GitHub (click on Zip button above) or on the website at http://www.currencysecrets.com/mql4-language-package
  • Unzip the file into Sublime Text's “Packages” folder (found by clicking “Preferences” menu then “Browse Packages…”)
  • Restart Sublime Text

To install the package using the command line (CLI) do:

On linux:
cd ~/.config/sublime-text-2/Packages/
git clone https://github.com/currencysecrets/mql4.git
On OSX:
cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/
git clone https://github.com/currencysecrets/mql4.git

Pull updates

On linux:
cd ~/.config/sublime-text-2/Packages/mql4/
git pull
On OSX:
cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/mql4/
git pull

You may also want to download WBond's Package Control found here: http://wbond.net/sublime_packages/package_control

And install packages such as: BracketHighlighter (Cmd + Shift + p then enter “install package” then “brackethighlighter” hit return to install).

Usage

To use the MQL4 language simply begin typing your code. You will begin to see a code hinting box that will link to MetaTrader data types, functions, constants and reserved words. Simply enter or tab the selected term you wish to use and Sublime Text will populate any necessary parameters into your working file.

Parameter Data Types

Some MQL4 functions have parameters and for brevity sake the following abbreviations have been used in replacement of the standard data types recognised by MetaTrader. Please be aware that these shorter terms are only to be used as an indication of what type of value needs to be placed for the selected parameter:

  • bool = boolean
  • char = character
  • clr = color
  • dtt = datetime
  • dbl = double
  • obj = object
  • int = integer
  • str = string
  • … = anything

Some function parameter values have options and this has been distinguished with the available values possible with each value separated by a pipe symol “|”. If a parameter value has a default value this is distinguished as a parameter option with an asterisk “” (eg. ExampleFunction( bool check=TRUE|FALSE)) or as a lone paramater value (eg. AnotherExampleFunction( str me=“Alone” )).

The easiest way to cycle through parameter values is to use the TAB key on your keyboard.

Templates (as of v1.1.0)

Besides functions, parameters, data types and reserved keywords which are populated in the code hinting box we also have basic templates added.

By entering in expertstart the user can get a blank template for writing their expert advisor, as shown here:

//+------------------------------------------------------------------+
//| Test.mq4
//| Copyright 2013, MetaQuotes Software Corp.
//| http://www.metaquotes.net
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//--- input parameters
extern int       ExtParam1=0;
extern int       ExtParam2=0;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----

//----
   return(0);
  }
//+------------------------------------------------------------------+

Users can also add core individual templates by entering init, deinit or start in the text editor.

Feature Requests

If you any feature requests or amendments to be made to the code please let me know!!