MQLLock Library
What is MLL?
Its a collection of useful Functions you can use complementary in your MQL Code. Below you see all available functions in detail. We will continue developing more and more functions for MLL. Please contact us to request more Features to be implemented into MLL.
How does it work?
You will find mll.dll inside your Projects Download Area to download. Use this mll.dll while developing any Project. This DLL will work even without converting your Project to ML. If you ever decide to convert your project to ML Protection Level then ML Engine detects usage of mll.dll automatically and includes those functions into output.dll. So you dont have to carry mll.dll to your clients if you decide to let protect your project with ML. ML Engine natively supports whole MLL Functions
Inside Project Download Area you will find an MQL Include File called mll.mqh, you can use this file to import mll.dll into your code
Available Functions Overview
- int MLRand(int min, int max)
- bool MLFileExists(string FileName)
- string MLComputerID()
- string MLMACID()
- int MLMt4ToFront()
- int MLOpenBrowser(string URL)
- int MLChartToFront(int hwnd)
- int MLStartTicker(int hwnd, int period)
- int MLStopTicker(int hwnd,int period)
- int MLLinkAdd(int hwnd, int parent, string text, string URL)
- int MLLinkRemoveAll(int root)
- int MLLinkRemoveAll(int root)
- string MLGetWinDir()
- string MLGetTempDir()
- string MLGetAppdataDir()
- string MLGetHomeDir()
- string MGetSystemDriveL()
- string MLGetProgramFilesDir()
- string MLShellExecute(string command, bool hidden)
- string MLVersion()
- int MLLastError()
Remotevar functions
- int MLRVInit(string AUTH)
- int MLRVClose(int handle)
- int MLRVInt(int handle, string VarName)
- double MLRVDouble(int handle, string VarName)
- string MLRVString(int handle, string VarName)
- bool MLRVBool(int handle, string VarName)
- datetime MLRVDate(int handle, string VarName)
- bool MLRVExists(int handle, string VarName)
Function : MLRand(int min, int max)
MLRand returns a random Value between min and max. MQL has MathRand which returns a random value but the problem is this value is between 0 and 32767 and we think this is not well implemented Randomizing function. Thats why we have made this replacement. MLL MLRand function is able to return Random values negative, positive and also values over 32767!
//-- MLRand Demonstration for(int i=0;i<300;i++) Print("Random between -55555 and +55555. Iteration #"+i+" Returned: ", MLRand(-55555,55555));
Function : MLFileExists(string FileName)
This function accepts a FileName as Parameter and returns a boolean to determine if given FileName exists or not. MQL Does not have a native FileExists function, even if it would exist it would be jailed around files/ folder and you would not be able to check existence of files outside MT4 Directories. MLL FileExists function is designed to fill this gap.
if (MLFileExists("c:\\Windows\\SysWOW64\\user32.dll")) Print("You have x64 Based Windows");
Function : MLComputerID()
Returns a string as ComputerID also known as CID from current computer. You can use this function to get unique ID per Computer. CID has been defined by Fx1 Inc to have a unique ID per computer. We do detect CID based on computer configuration, user configuration. This function returns a string value.
Print("Your ComputerID/CID is: "+MLComputerID());
Function : MLMACID()
Returns a string of current MAC address.
Print("Your MACID is: "+MLMACID());
Function : MLMt4ToFront()
This function brings MT4 Terminal to Front. Imagine sometimes you want to display something very important to use of your Project, in such cases you can call this function and Terminal Window will get to Front and user will be informed via some notification such as Alert().
if ((Bid-Ask)<10*Point) { MLMt4ToFront(); Alert("Spread is very low now, time to Trade!"); }
Function : MLOpenBrowser(string URL)
Use this function to open any URL from your Project. MLOpenBrowser will call users default browser with given URL.
int deinit() { // We will open users browser with given url at the end of Expert Advisor // To Display latest news about this Expert Advisor MLOpenBrowser("http://my.company/product/deinit.php"); }
Of course this function can be used everywhere in your code but anyways be carefully please. If you call this function too often this may cause users computer get blocked due to load. URL needs to start with http:// or https://, mailto: is also supported
Function : MLChartToFront(int hwnd)
This function brings the Chart to Front inside same Terminal. Imagine user has 5 charts open and if user is used to use maximized charts then user will have only 1 chart visible. You can use MLChartToFront function to bring the Chart with your Project to front. Use this function to indicate important actions.
if (TimeToTrade==true) { MLChartToFront(hwnd); Alert("Trade Now! "); }
Function : MLStartTicker(int hwnd,int Period)
Function : MLStartStop(int hwnd,int handle)
MLStartTicker & MLStop Ticker are working together. These functions send ticks to defined Terminal in given Periods. Stop Function stops the ticks. Period is defined in miliseconds and minimum valus is 200. Below you see a demonstration how to use Ticker Feature effectively. You should never forget to Stop the Ticker. Calling multiple Tickers inside same Project is not allowed.
// DLL Imports #import "mll.dll" int MLStartTicker(int hwnd, int period); // Start automatic ticker, returns a handle int MLStopTicker(int hwnd, int handle); // Stop ticker from given handle #import int handle=0; int ticks=0; int hwnd=0; int init() { hwnd = WindowHandle(Symbol(),Period()); handle=MLStartTicker(hwnd,500); if (handle>0) Print("Ticker has been started successfully"); else Print("Ticker could not be started"); return(0); } int deinit() { // We must stop the Ticker at the end of EA if (handle>0) MLStopTicker(hwnd,handle); return(0); } int start() { ticks++; // We count the ticks per Tick Comment("Tick Count :",ticks); return(0); }
Function : MLLinkAdd(int hwnd, int parent, string Content, string URL)
Function : MLLinkRemoveAll(int handle)
MLLink Functions are designed to add Links to MT4 Terminals Navigation Window. This unique Feature gives you the power to Add Links to Terminal. See Screenshoot on Left side to understand ML Link Feature. As you see ML Link Feature is able to make Terminal Window Modifications and improve interaction with Clients.
Every link has a parent and parent nodes are not clickable. Parent nodes has to have 0 in second parameter and empty URL. URLs support http://, https:// and mailto: tags. So its possible to open users default email client using ML Link Feature.
Its very important to remove Links from Chart inside deinit() or whenever you dont need them anymore. To remove all links you simply call MLLinkRemoveAll() function with handle of parent. Calling MLLinkAdd to start a new parent returns a handle which is unique for every Parent. You have to define this as global Variable in MQL to be able to call same parameter with MLLinkRemoveAll.
We think Demonstration Code will tell you everything about MLL Link Feature:
// DLL Imports #import "mll.dll" int MLLinkAdd( int hwnd, int parent, string text, string link ); int MLLinkRemoveAll( int root ); #import int parent1=0; int parent2=0; int ticks=0; int hwnd=0; int init() { hwnd = WindowHandle(Symbol(),Period()); // Lets Build our Links at start // ---- PARENT 1 // Parent Link has parent = 0 and link should be kept empty ("") // Lets add the Parent parent1 = MLLinkAdd(hwnd,0,"Super EA",""); // Lets add Sub Links MLLinkAdd(hwnd,parent1,"Contact Support","mailto: support@fx1.net"); MLLinkAdd(hwnd,parent1,"Product Support","http://superea.com"); MLLinkAdd(hwnd,parent1,"Google","http://google.com"); MLLinkAdd(hwnd,parent1,"Buy other EA","http://fx1.collective2.com"); // ---- PARENT 2 parent2 = MLLinkAdd(hwnd,0,"Useful Links",""); // Lets add Sub Links MLLinkAdd(hwnd,parent2,"Fx1 Code Library","https://fx1.net/cl.php"); MLLinkAdd(hwnd,parent2,"MQL4 Forum","http://www.mql4.com"); MLLinkAdd(hwnd,parent2,"Recent Forex News","http://www.forexfactory.com"); } int deinit() { if (parent1>0) MLLinkRemoveAll(parent1); if (parent2>0) MLLinkRemoveAll(parent2); } int start() { ticks++; // We count the ticks per Tick Comment("Tick Count :",ticks); return(0); }
Function : MLGetWinDir()
Function : MLGetTempDir()
Function : MLGetAppdataDir()
Function : MLGetHomeDir()
Function : MLGetSystemDrive()
Function : MLGetProgramFilesDir()
returns %windir% , %temp%, %appdata%, %homepath%, %systemdrive% and %programfiles% paths as string. These paths are shortcuts to some important Windows paths.
// Read Windows Environment Directories Print("Windows Directory : "+MLGetWinDir()); Print("Temp Directory : "+MLGetTempDir()); Print("Adddata Directory : "+MLGetAppdataDir()); Print("Home Directory : "+MLGetHomeDir()); Print("System Directory : "+MLGetSystemDrive()); Print("ProgramFiles Directory : "+MLGetProgramFilesDir());
Function : MLShellExecute(string command,bool state)
You can execute commands using this function. The state input accepts a boolean which indicates that the execution should be hidden or not. The state is only working for DOS/Shell Commands, not for native Windows software.
// Lets open Microsoft Windows Notepad string notepadpath = MLGetWinDir()+"\\system32\\notepad.exe"; MLShellExecute(notepadpath,true);
Important: always use state=true for windows applications
Function : MLVersion()
This function returns current ML Library version you are running. In some cases your clients may run older ML Library DLL files. You may capture this problem by comparing the versions
Function : MLLastError()
This function returns Last Error occoured in MQLLock Library Routines. Here is all possible return values listed:
Enumaration | Value |
---|---|
ML_OK (No Error) | 0 |
ML_REG_OPEN (Failed to Open Registry) | -1 |
ML_INVALID_SERVER | -2 |
ML_READ_FILE | -3 |
ML_SEND_REQUEST | -4 |
ML_OPEN_URI | -5 |
ML_CONNECT_SERVER | -6 |
ML_INTERNET_OPEN | -7 |
ML_NO_DATA | -8 |
ML_INVALID_HANDLE | -9 |
ML_INVALID_PARAMETER | -10 |
ML_TIMEOUT | -11 |
ML_DATA_LIMIT | -12 |
ML_DUPLICATE_DATA | -13 |
ML_UNKNOWN | -97 |