I've followed your directions carefully but I'm unable to get this working with Matlab 2007b. I continuously get these errors, when trying to use your prebuilt examples, with the MT5 Terminal.
2010.08.29 10:33:30 TestMLEngine (EURUSD,H1) Cannot open 'C:\Users\QuantFX\AppData\Roaming\MetaQuotes\Terminal\216E2BD2BB8CE60176A41ADF6AC1C76D\MQL5\Libraries\LibMlEngine.dll' (126)
2010.08.29 10:33:47 TestDllMatlab (EURUSD,H1) Cannot open 'C:\Users\QuantFX\AppData\Roaming\MetaQuotes\Terminal\216E2BD2BB8CE60176A41ADF6AC1C76D\MQL5\Libraries\nnSMA.dll' (126)
I don't really know what to think of it becuase I'm able to get the project mentioned in the article "How to Exchange Data: A DLL for MQL5 in 10 Minutes " found here https://www.mql5.com/en/articles/18 working without any problems.
2010.08.29 10:44:16 MQL5DLL_Test (EURUSD,H1) Access violation write to 0x00000000 in 'C:\Users\QuantFX\AppData\Roaming\MetaQuotes\Terminal\216E2BD2BB8CE60176A41ADF6AC1C76D\MQL5\Libraries\MQL5DLLSamples.dll'
2010.08.29 10:44:16 MQL5DLL_Test (EURUSD,H1) Replace: A quick brown cat jumps over the lazy dog
2010.08.29 10:44:16 MQL5DLL_Test (EURUSD,H1) Array: 0 1 2 3 4 5 6 7 8 9
2010.08.29 10:44:16 MQL5DLL_Test (EURUSD,H1) Time 297 msec, int: -752584127 double: 17247836076609
So the terminal obvioulsy has no problems with access violations to the \Libraries folder, and I'm certain the Expert Advisor "Options" allow for dll imports and autotrading...Any help would be greatly appreciated because I've been stumped by this since first reading this article. Thanks In Advance
- 2010.01.27
- MetaQuotes Software Corp.
- www.mql5.com
Finally got this working...Excellent article I must say. I'm not highly experienced with Visual Studio and I'm a newbie to metatrader programming. So, this seemed somewhat of a challenge with all the errors I was recieving. Although it is very easy in the long run for all versions of matlab and visual studio. Anyone who is making their first attempts at connecting Metatrader and Matlab together I suggest do the following to gain insight, if you never have worked with matlab engine or metatrader external libraries. 1. Create the project that comes with matlab found in matlabroot\externs\examples\eng_mat\engwindemo.c by following this article. http://www.mathworks.com/support/solutions/en/data/1-78077S/index.html?product=ML&solution=1-78077S Compile it, and should you have problems, like missing dll files, use dependency walker, found here http://www.dependencywalker.com/ to determine what missing files need to be placed in your C:\Windows\System 32 folder in order to get the version of matlab engine you are using to work. It might be good to note that you may end up having to put alot files in your system 32 folder,or know the right places to link them at in your project. Although most dll's are found in your matlabroot\bin\win(32 or 64) folder. After you've put in the first few dll files needed go back and try to build your project again. You might find that you don't need to do everything that dependency walker suggests. If you get the project to compile and run then your're almost done... 2. Build the project suggested in the article How to Exchange Data: A DLL for MQL5 in 10 Minutes https://www.mql5.com/en/articles/18 . If you get that project working then just rememebr as you create the project above you're combining the two. Remember all the steps you followed and when you're ready to compile this project make sure "stdafx.h" is the first #include header in DLLUnit.cpp, and you have turned off precompiled headers, just before building. Using the files above as is may give some warnings that are easily fixable, but the project should work without any hassle. My added two cents here may sound like the dummie's guide to this project, but doing those things may save you a couple hours of your spare time if you needed to build this project with another version of matlab or use visual studio.
Cheers
If I am not mistaken, the type of Matlab matrices in Table 1 is incorrect. The letter u is missing. I.e., for example, the uint16 type is responsible for the range from 0 to 65535, not the int16 type . And so on...
Class | Range of Values | Conversion Function |
---|---|---|
Signed 8-bit integer | -27 to27-1 | int8 |
Signed 16-bit integer | -215 to215-1 | int16 |
Signed 32-bit integer | -231 to231-1 | int32 |
Signed 64-bit integer | -263 to263-1 | int64 |
Unsigned 8-bit integer | 0 to28-1 | uint8 |
Unsigned 16-bit integer | 0 to216-1 | uint16 |
Unsigned 32-bit integer | 0 to232-1 | uint32 |
Unsigned 64-bit integer | 0 to264-1 | uint64 |
Good afternoon, thanks for the great article, very helpful!
However, a problem has arisen. Maybe someone has encountered it.
When closing an Expert Advisor, MT5 hangs completely when I close it. I use MS Visual Studio2010 + Matlab r2011a.
What do you think could be the reason? Thanks in advance!
Good afternoon. I did everything as in the article, but when running the TestMlEngine script, an error popped up:
2011.12.17 15:55:23 TestMLEngine(EURUSD,H1) Cannot open 'C:\Users\H_F_M\AppData\Roaming\MetaQuotes\Terminal\DEA4AAFB99C996D79821EC8BDBADDC3C\MQL5\Libraries\LibMlEngine.dll' (126)
and then immediately:
2011.12.17 15:55:23 TestMLEngine (EURUSD,H1) Cannot find 'mlxGetSizeOfName' in 'LibMlEngine.dll'
2011.12.17 15:55:23 TestMLEngine (EURUSD,H1) Cannot find 'mlxGetLogical' in 'LibMlEngine.dll'
2011.12.17 15:55:23 TestMLEngine (EURUSD,H1) Cannot find 'mlxGetInt' in 'LibMlEngine.dll'
2011.12.17 15:55:23 TestMLEngine (EURUSD,H1) Cannot find 'mlxGetDouble' in 'LibMlEngine.dll'
2011.12.17 15:55:23 TestMLEngine (EURUSD,H1) Cannot find 'mlxInputLogical' in 'LibMlEngine.dll'
2011.12.17 15:55:23 TestMLEngine (EURUSD,H1) Cannot find 'mlxInputInt' in 'LibMlEngine.dll'
2011.12.17 15:55:23 TestMLEngine (EURUSD,H1) Cannot find 'mlxInputDouble' in 'LibMlEngine.dll'
2011.12.17 15:55:23 TestMLEngine (EURUSD,H1) Cannot find 'mlxInputChar' in 'LibMlEngine.dll'
2011.12.17 15:55:23 TestMLEngine (EURUSD,H1) Cannot find 'mlxOpen' in 'LibMlEngine.dll'
2011.12.17 15:55:23 TestMLEngine (EURUSD,H1) Cannot find 'mlxClose' in 'LibMlEngine.dll'
Somewhere on the forum I found that this is due to missing dlls, with the help of depends.exe I found what it was missing, I threw it into the same folder, it helped, but not quite.Now it shows:
2011.12.17 15:57:59 TestMLEngine (EURUSD,H1) Cannot open 'C:\Users\H_F_M\AppData\Roaming\MetaQuotes\Terminal\DEA4AAFB99C996D79821EC8BDBADDC3C\MQL5\Libraries\LibMlEngine.dll' (127).
and the list goes on with "Cannot find...". Can you tell me what the problem is? I've been struggling for a week already...
Yes, I have Win7 + Matlab R2011a + VS201.
.
Good afternoon. I did everything as in the article, but when running the TestMlEngine script, an error popped up:
2011.12.17 15:55:23 TestMLEngine (EURUSD,H1) Cannot open 'C:\Users\H_F_M\AppData\Roaming\MetaQuotes\Terminal\DEA4AAFB99C996D79821EC8BDBADDC3C\MQL5\Libraries\LibMlEngine.dll' (126)
and then immediately:
2011.12.17 15:55:23 TestMLEngine (EURUSD,H1) Cannot find 'mlxGetSizeOfName' in 'LibMlEngine.dll'
2011.12.17 15:55:23 TestMLEngine (EURUSD,H1) Cannot find 'mlxGetLogical' in 'LibMlEngine.dll'
2011.12.17 15:55:23 TestMLEngine (EURUSD,H1) Cannot find 'mlxGetInt' in 'LibMlEngine.dll'
2011.12.17 15:55:23 TestMLEngine (EURUSD,H1) Cannot find 'mlxGetDouble' in 'LibMlEngine.dll'
2011.12.17 15:55:23 TestMLEngine (EURUSD,H1) Cannot find 'mlxInputLogical' in 'LibMlEngine.dll'
2011.12.17 15:55:23 TestMLEngine (EURUSD,H1) Cannot find 'mlxInputInt' in 'LibMlEngine.dll'
2011.12.17 15:55:23 TestMLEngine (EURUSD,H1) Cannot find 'mlxInputDouble' in 'LibMlEngine.dll'
2011.12.17 15:55:23 TestMLEngine (EURUSD,H1) Cannot find 'mlxInputChar' in 'LibMlEngine.dll'
2011.12.17 15:55:23 TestMLEngine (EURUSD,H1) Cannot find 'mlxOpen' in 'LibMlEngine.dll'
2011.12.17 15:55:23 TestMLEngine (EURUSD,H1) Cannot find 'mlxClose' in 'LibMlEngine.dll'
Somewhere on the forum I found that this is due to missing dlls, with the help of depends.exe I found what it was missing, I threw it into the same folder, it helped, but not quite. Now it shows:
2011.12.17 15:57:59 TestMLEngine (EURUSD,H1) Cannot open 'C:\Users\H_F_M\AppData\Roaming\MetaQuotes\Terminal\DEA4AAFB99C996D79821EC8BDBADDC3C\MQL5\Libraries\LibMlEngine.dll' (127).
and the list goes on with "Cannot find...". Can you tell me what the problem is? I've been struggling for a week already...
Yes, I have Win7 + Matlab R2011a + VS201.
When I installed Matlab, the System path was only "C:\Program Files\MATLAB\R2011b\bin". I added "C:\Program Files\MATLAB\R2011b\bin\win32". Dlls from Matlab directory became visible and Matlab Engine started. Before that I wrote that I couldn't see the dlls.
Good day) I have another problem - for some reason the "Borland" catalogue is not found in the <MATLAB>\extern\lib\win32\ folder, although Borland C++ Builder 6 is installed. Accordingly, the files libeng.lib and libmx.lib cannot be connected to the project either. Far gives the following on the command "implib libeng libeng.lib libeng.dll":
)
And the Borland folder was not there and still is not... Can anyone tell me how to deal with this problem? Or at least will throw these two files?:-)
In general, please help, because I don't understand something....
For the purity of the experiment I installed VMware, where I installed 2 systems - XP and 7.
Then I installed Matlab R2011b, installed MCR, installed the latest build of MT5. From the archive attached to the article, all the files were scattered into folders, as written in the instructions in the archive. I compiled the mq5 files into ex5 (i.e. I deleted the existing ex5 files in the archive and put the newly compiled ones in their place). I start MT5, start Matlab (I tried not to start it - the result is the same), in the terminal I click on TestMlEngine, and it gives me:
TestMLEngine (EURUSD,H1) 13:44:58 Cannot open 'C:\Users\User\AppData\Roaming\MetaQuotes\Terminal\DEA4AAFB99C996D79821EC8BDBADDC3C\MQL5\Libraries\LibMlEngine.dll' (126)
TestMLEngine (EURUSD,H1) 13:44:58 Cannot find 'mlxClose' in 'LibMlEngine.dll'
TestMLEngine (EURUSD,H1) 13:44:58 Cannot find 'mlxOpen' in 'LibMlEngine.dll'
TestMLEngine (EURUSD,H1) 13:44:58 Cannot find 'mlxInputChar' in 'LibMlEngine.dll'
TestMLEngine (EURUSD,H1) 13:44:58 Cannot find 'mlxInputDouble' in 'LibMlEngine.dll'
TestMLEngine (EURUSD,H1) 13:44:58 Cannot find 'mlxInputInt' in 'LibMlEngine.dll'
TestMLEngine (EURUSD,H1) 13:44:58 Cannot find 'mlxInputLogical' in 'LibMlEngine.dll'
TestMLEngine (EURUSD,H1) 13:44:58 Cannot find 'mlxGetDouble' in 'LibMlEngine.dll'
TestMLEngine (EURUSD,H1) 13:44:58 Cannot find 'mlxGetInt' in 'LibMlEngine.dll'
TestMLEngine (EURUSD,H1) 13:44:58 Cannot find 'mlxGetLogical' in 'LibMlEngine.dll'
TestMLEngine (EURUSD,H1) 13:44:58 Cannot find 'mlxGetSizeOfName' in 'LibMlEngine.dll'.
I don't know what to do. I tried everything I could. I tried the DLL from the article "How to write a DLL library for MQL5 and exchange data in 10 minutes?" ().(https://www.mql5.com/ru/articles/18)- it works without problems.
Can anyone tell me how else to get to it? What am I doing wrong?
Thanks in advance.

- 2010.01.27
- MetaQuotes Software Corp.
- www.mql5.com
When I installed Matlab, the System path was only "C:C:\Program Files\MATLAB\R2011b\bin". I added "C:\Program Files\MATLAB\R2011b\bin\win32". Dlls from Matlab directory became visible and Matlab Engine started. Before that I wrote that I couldn't see the dlls.
If you mean the Path environment variable, I added "C:\Program Files\MATLAB\R2011b\bin\win32" to it, but the situation didn't change :-(

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
New article MetaTrader 5 and MATLAB Interaction is published:
Author: Andrey Emelyanov