Any good tutorials or literature on developing Dynamic Link Libraries (DLLs) to work with Metatrader?

 
Just wondering if someone can point me in the right direction for some good tutorials to start learning about dynamic link libraries (dlls), and the advantages they offer MT4 by using dlls?
 
Calpurnia:
[...] and the advantages they offer MT4 by using dlls?

Various advantages spring to mind:


  • Re-use of existing code, rather than having to rewrite things in MQL (not applicable in your case)
  • Ability to transfer code from MT4 to other trading platforms (probably not applicable in your case)
  • Speed of execution (though MQL is pretty fast except when used for some fairly niche scenarios)
  • Availability of richer language features such as classes, inheritance etc (many of which are coming in MT5)
  • Greater ability to call Windows API functions, other code libraries, etc
  • Availability of better debugging tools than in MQL.
  • Obfuscation of code. It's much harder to "decompile" a DLL than an EX4 file.
Lots of people use DLLs mainly for the last of these reasons. But simply using a DLL isn't as much of a protection as people think - for example, there's a very easy way of taking out Megadroid Pro's licensing, despite the fact that it uses a DLL.


Just wondering if someone can point me in the right direction for some good tutorials to start learning about dynamic link libraries (dlls)

Writing DLLs basically means writing in C or C++. Off the top of my head, the only mainstream higher-level language which may offer the ability to write the sort of DLLs usable by MetaTrader (i.e. non-COM DLLs) is possibly Delphi.


Writing in MQL isn't a bad foundation for writing in C - the former is basically derived from the latter. But low-level languages such as C give you all sorts of extra headaches such as having to take care of memory allocation yourself, and having to understand the mechanics of memory addresses etc. Basically, it's very easy to make a DLL cause a fatal crash, whereas this should be impossible in MQL. The more general point is that a higher-level language such as MQL should give you greater speed of development than a lower-level language, traded off against a loss of flexibility and speed of execution.


Having said all that, I wouldn't know where to recommend that you start in learning about C/DLLs. Over to someone else...

 

Have you compiled, executed, and modified the sample DLL code included with MT4?

 
NO....i didn't know it included dlls?
 
Calpurnia:
NO....i didn't know it included dlls?

The samples directory of an MT4 installation includes the C source code (and Visual Studio project files) for an example DLL. It's going to be pretty meaningless and intimidating as a starting point if you're not familiar with C. Which I'm guessing you're not.

 

I don't even know what a dll does....much less have any experience with C.

I do know PERL pretty well though (lotta good that'll do me)

 
I looked in the samples folder in my metaeditor, and it has a DLLsample file under it. But the file is empty?
 

Look again with Windows File Explorer

On mine it is

D:\Program Files (x86)\MetaTrader\FXDD - MetaTrader 4\experts\samples 

├───DLLSample
│ ExpertSample.cpp
│ ExpertSample.def
│ ExpertSample.dsp
│ ExpertSample.dsw
│ StdAfx.h
│
├───include
│ sampledll.mqh
│
└───libraries
ExpertSample.dll
 
Calpurnia wrote >>

I don't even know what a dll does....much less have any experience with C.

I do know PERL pretty well though (lotta good that'll do me)

Knowing Perl is sorta of a Hero's badge imho. bout 1oyrs ago I based a selling site's server side ordering with it.

Then one happy day, I came across a buglet feature that just would not go away. Nobody seemed to understand. A sobering time...

But, seriously - IF can stand the PERL heat what are you waiting for???

MQL4 and/or C is seriously simple.

Is not the syntax, is the understanding and learning the howto's of an HLL. Web is overflowing with many tutorial sites on C

https://en.wikipedia.org/wiki/Dynamic-link_library gives you background.

 

I was looking at Metaeditors files (dumb!)

I found them in the root folders.

Now, how can I use this dll to learn?

 

Its a sample, like "Hello World"

Do you have a C compiler?

Can you compile the sample DLL?

Can your EA/Indicator/Script find and attach the DLL, and communicate with it?

Can you unerstand the sample and modify it?

There are many basic tasks to get out of the way before you can do anything exciting.

Reason: