A very interesting article. It's missing for the sake of completeness:
1. Where do we get the quotes, can they be taken from hst files?
2. How to make this library compatible with the one in the 2009a or 2009b MateLab? Don't they also have C and C++ there?
A very big request.
- Quotes are taken from the terminal - they are now both detailed and deep (10 years and more).
Under no circumstances should we directly look into the binary files of the terminal storages - it will only cause serious data access conflicts. Even if the tests showed "it worked, no problems", still there will come a moment of simultaneous access to this data of terminal and external program, and someone will crash as a result. People have stumbled upon it many times. - Docking libraries in MQL5 is now much easier, due to transparent support for stdcall / cdecl conventions on DLL calls.
If someone writes a good and detailed article about linking MetaTrader 4/5 and Matlab via DLL, it will earn $200 or more.
The MQL4.community already has articles on Matcad - MetaTrader 4 bundle:
- www.mql5.com
I need to link two terminals so that they translate their quotes into Excel in real time.
In MT4 it could be done with DDE. In MT5 it seems that through DLL is the only way out.
But if each incoming tick will be passed to DLL... I think it will be something unimaginably slow. Of course I haven't tried to implement it yet... but honestly, I don't want to try it. It's going to be a nightmare.
In short, let's return DDE to MT5. It is an anachronism, but sometimes you may need it.
P.S. Thank you for this article, it is very timely. I have been missing just such a material.
Renat, what about the call speed of the dll?
It's very easy to check the call speed. For example, a rough calculation can be done like this:
_DLLAPI int __stdcall fnCalcSpeed(int var1,int var2,int var3) { return(0); } #import "MQL5DLLSamples.dll" int fnCalcSpeed(int var1,int var2,int var3); #import int calls=0; int ticks=GetTickCount(); while(GetTickCount()-ticks<1000) { for(int i=0;i<1000;i++) fnCalcSpeed(1,2,3); calls++; } Print(calls * 1000, "вызовов в секунду");
I got 57,000 calls per second on a Quad Q9400 @2.66Ghz. The same code gives about 20,000,000 calls per second in MetaTrader 4, as there is no control and piping there.
We will definitely try to reduce the loss on DLL calls in MetaTrader 5.
Ah, well, if there are about 50,000 calls per second, I think it's possible to broadcast quotes through the DLL as well. There won't be any losses.
Thank you for the code.
If it is possible to export quotes only through dll, then it means that a script should be placed on each instrument to be exported? What if there are many of them? For example, 50?
I understand that it is possible to pass quotes for many instruments in one script, but it will not be a full-fledged substitute for DDE, where ticks are not lost.
The point is that we are not tasked with "providing a quotation interface".
Our aim is to create a complete and self-sufficient environment for developing analytical systems. Such an environment so that even third-party programmes do not need to be used.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Published article How to write a DLL for MQL5 in 10 minutes and exchange data?:
Author: Renat Fatkhullin