Hi All,
I have the same question. Can somebody from Metaquotes clarify?
Regards
Vivek
Hi!
Same question. Almost five years and nobody can help?
Thanks.
Hi!
Same question. Almost five years and nobody can help?
Thanks.
Why don't you try it and report back?
Can you give directions on how to import a dll class from mql5? I will give a try gladly
Alas, no I can't. It is not something I've ever needed to explore (and I guess that is why the question remains unanswered - not a very common requirement!)
Good luck if you do try
Can you give directions on how to import a dll class from mql5? I will give a try gladly
Reading the documentation before asking questions is generally a good idea.
It shows you exactly how to do it. You clearly didn't.....
https://www.mql5.com/en/docs/basis/preprosessor/import
There are examples of importing .dll files on that page.

- www.mql5.com
Reading the documentation before asking questions is generally a good idea.
It shows you exactly how to do it. You clearly didn't.....
https://www.mql5.com/en/docs/basis/preprosessor/import
There are examples of importing .dll files on that page.
I may have misunderstood the question; I read it as not a simple import of a function but an import of a class.
It's not possible to use classes directly from a DLL or any compiled library.
This article https://www.mql5.com/en/articles/362 shows an interesting approach to use classes in a library.

- 2012.02.20
- o_o
- www.mql5.com
In these cases you don't export the class but auxiliary functions as Stanislav Korotky said, Lets say you have a class in your DLL like so:
class AwesomeIndicator { double tellMeThePriceThatIShouldBuy() { return 42; } }
Now imagine that you need to create that class so that it can do some logic and for you and you get your magic price to buy, all you have to do is the reverse of what C++ is doing, C++ classes are a "syntax sugar" (they are more complex, but for the sake of simplicity, lets forget edge cases), for example:
AwesomeIndicator* pointerToAwesomeIndicator = new AwesomeIndicator(); // When you call a method. pointerToAwesomeIndicator->tellMeThePriceThatIShouldBuy(); // C++ is actually doing something like this, it just allocates the memory for the class members and uses the pointer to reference that memory.. tellMeThePriceThatIShouldBuy(pointerToAwesomeIndicator, ...otherParameters);
With that in mind, you'll need in your DLL a function to create/delete the object and additional functions for each method in your class that you want to expose:
/// Pointers are just either Int32 or Int64 depending on the OS/processor. AwesomeIndicator* createAwesomeIndicator() { return new AwesomeIndicator(); } /// To delete the class and release the memory you need to call this function. double deleteAwesomeIndicator(AwesomeIndicator* targetToDelete) { delete targetToDelete; } // Call the method inside the class. double tellMeThePriceThatIShouldBuy(AwesomeIndicator* targetIndicatorCreated) { return targetIndicatorCreate->tellMeThePriceThatIShouldBuy(); }
Basically you will have a bunch of functions where you'll have to pass the pointer to the object you created. Lots of APIs (DirectX, OpenGL, etc...) works like this, you'll have no issues finding examples online.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi everybody,
I was evaluating which is the best choice among MQL4 and MQL5, I'm a software developer so I really appreciate the OOP introduced in MQL5.
I have a C++ .dll which exposes some useful classes, my question is: can I directly use the classes defined in an external .dll from MQL5. I think this should be quite natural (because of the c++ like nature of MQL5) but I'm pretty sure it's not possible.
What do you suggest? A wrapper .dll is an ugly and uncomfortable way, plus you loose the OOP benefits.
Any suggestion is more than welcome
Thanks in advance
Marco