Requesting ideas on improving my MQL4 programming

 

Hi,

I currently am able to develop EAs and indicators using pure MQL4 language only.

May I ask what other languages can my MQL4 programs benefit from? For example, if I can program in C++, I can make my MQL4 code call the mentioned language and do amazing stuff like: encryption, http connection, web service, alternative file access, etc.

I am hoping for your ideas.

I dont know what language I should study to do such above. e.g. c, c++, c#, java, perl, etc.

 

I don't REALLY know the answer to your question, but I would recommend learning C++ anyway, since, in my experience, you can pretty much learn any other programming language in a day once you know C++.

(The same is true about starting with java, or another C language, I'm just biased towards C++. It gives a good amount of rudimentary programming knowledge, and it is a highly used and very useful language with readily available learning materials online.)


I would love to hear an answer about the more important (and MQL4 related) part of his message.

 
jcadong5 wrote >>

Hi,

I currently am able to develop EAs and indicators using pure MQL4 language only.

May I ask what other languages can my MQL4 programs benefit from? For example, if I can program in C++, I can make my MQL4 code call the mentioned language and do amazing stuff like: encryption, http connection, web service, alternative file access, etc.

I am hoping for your ideas.

I dont know what language I should study to do such above. e.g. c, c++, c#, java, perl, etc.

So you want to learn a new language that you can benifit from when it comes to MetaTrader. Well the key thing really is in order to utilize the new language it is done via a DLL. I pretty much disagree with fxCal's comment regarding learning C++ you can pick up any other language in a day, I mean really. As a professional software developer for over 15 years with experience in more languages than I care to mention, would say this is completely incorrect. Now I would agree with coding syntax, there is definately similarities. The difficulty with any language is learning how do I do it. eg. the .net framework is completely different than dealing with file includes linking to libs etc etc. If you know what you want to build then it is easy enough to work out with documentation.

Taking it as you aren't an experienced developer then here are some thoughts.

- c/c++ easy enought to create a DLL, export the functions and call them from meta. Knowledge level for a novice is not to be taken lightly, understanding memory management, pointers etc etc can be quite difficult to begin with. On the plus site there is plenty of online resources to help. Using .Net C++ is another option, this means you can build a managed app that you bridge with native code. Biggest advantage is in a managed environment you have a garbage collection that helps with memory and memory leaks.

- c# is a nice language and my favourite to be honest, but although you can build a dll in c# you cannot create export table, so in order to user anything you write with c# you would need to create a dll in c++ and write a bridge to the c# dll in managed c++. This really isn't difficult and easy enough to maintain. The c# language is easier to learn and there is loads of reasources available online.

- java - my knowledge is a bit limited on creating the dll side of things but imaging it is similar to c#.

Either way you will spend alot of time learning. Leaning C/C++ will take a while but in the end if you learn it well seeing as its a low level language it will hold you in good stead.

 

I was exaggerating I guess. What I meant is that the ideology behind programming is 99% the same in most major languages, so really so long as you learn the theory behind programming, it doesn't matter what language you learn it in, the skills transfer over pretty easily. While I might not be able to code in a new language tomorrow, I would be fairly confident in my ability to read through it and understand how it works.


As to your comment on Java, J# would be a lot like C# (though widely considered not as good), while other java versions (excluding JScript) are more like C and C++.


I'm really new to MQL4, what sort of things do people use .dll for? I've heard it referenced as a way to prevent people from decompiling and stealing .ex4 files, are there any other uses for it, or is that pretty much it? Forex and MQL4 are really interesting programming challenges for me, and I'm eager to learn all I can. Any links to information would be appreciated as well.

 
fxCal wrote >>

I don't REALLY know the answer to your question, but I would recommend learning C++ anyway, since, in my experience, you can pretty much learn any other programming language in a day once you know C++.

(The same is true about starting with java, or another C language, I'm just biased towards C++. It gives a good amount of rudimentary programming knowledge, and it is a highly used and very useful language with readily available learning materials online.)

I would love to hear an answer about the more important (and MQL4 related) part of his message.

i know java. but i think (tell me if im wrong), it is not possible to directly extend mql4 language capability, using java.

i saw here somewhere someone saying about calling 'windows library' from mql4. im guessing that that would be made initially using c or c++ or any of those compiled into windows libraries.

 
pfx wrote >>

So you want to learn a new language that you can benifit from when it comes to MetaTrader. Well the key thing really is in order to utilize the new language it is done via a DLL. I pretty much disagree with fxCal's comment regarding learning C++ you can pick up any other language in a day, I mean really. As a professional software developer for over 15 years with experience in more languages than I care to mention, would say this is completely incorrect. Now I would agree with coding syntax, there is definately similarities. The difficulty with any language is learning how do I do it. eg. the .net framework is completely different than dealing with file includes linking to libs etc etc. If you know what you want to build then it is easy enough to work out with documentation.

Taking it as you aren't an experienced developer then here are some thoughts.

- c/c++ easy enought to create a DLL, export the functions and call them from meta. Knowledge level for a novice is not to be taken lightly, understanding memory management, pointers etc etc can be quite difficult to begin with. On the plus site there is plenty of online resources to help. Using .Net C++ is another option, this means you can build a managed app that you bridge with native code. Biggest advantage is in a managed environment you have a garbage collection that helps with memory and memory leaks.

- c# is a nice language and my favourite to be honest, but although you can build a dll in c# you cannot create export table, so in order to user anything you write with c# you would need to create a dll in c++ and write a bridge to the c# dll in managed c++. This really isn't difficult and easy enough to maintain. The c# language is easier to learn and there is loads of reasources available online.

- java - my knowledge is a bit limited on creating the dll side of things but imaging it is similar to c#.

Either way you will spend alot of time learning. Leaning C/C++ will take a while but in the end if you learn it well seeing as its a low level language it will hold you in good stead.

thank you pfx

i guess if i want to stick with my baby (java), i can make a c/c++ java native (called JNI) combination.

 
jcadong5:

For example, if I can program in C++, I can make my MQL4 code call the mentioned language and do amazing stuff like: encryption, http connection, web service, alternative file access, etc.

HTTP connections and "alternative file access" (I assume you mean reading/writing files anywhere on the hard disk) can both be done in MQL by importing calls from the Windows API. For example, https://www.mql5.com/en/forum/118999 and https://www.mql5.com/en/code/8435. (I've not personally tried using the latter, and there are several alternative HTTP libraries available on this forum.)


Personally I know little about Java, and nothing about JNI, but the brief Wikipedia page on the latter doesn't make it look likely that you can call JNI code directly from MQL, i.e. without still needing a DLL as an intermediary.


fxCal wrote >>

I was exaggerating I guess. What I meant is that the ideology behind programming is 99% the same in most major languages, so really so long as you learn the theory behind programming, it doesn't matter what language you learn it in, the skills transfer over pretty easily. While I might not be able to code in a new language tomorrow, I would be fairly confident in my ability to read through it and understand how it works.

I'm with pfx on this one - and with your amended comment rather than your original post. These days, knowing the syntax of a language is usually less than half of achieving competence in that language, because languages are usually also platforms (or whatever you want to call it). Just like pfx's .net framework example, the syntax of MQL is a separate body of knowledge to the functions which it makes available such as OrderSend(). A C or Javascript developer can pick up the syntax of MQL in minutes (possibly even seconds). But there's then still a big job in learning the MQL "framework". And, after that, there's another big job in learning all the things which can go wrong in live rather than demo trading, and all the coding measures which it's prudent to take to cater for this.


fxCal wrote >>

I'm really new to MQL4, what sort of things do people use .dll for? I've heard it referenced as a way to prevent people from decompiling and stealing .ex4 files, are there any other uses for it, or is that pretty much it?

Personally I'd say there are three main things which DLLs get used for with MQL. One is indeed as a licensing or anti-decompilation measure. A second is processor-intensive code, such as neural networks, or anything which cannot realistically be done in MQL rather than in an OO language. The third is anything which requires more complex interfacing with other code than MQL is capable of. For example, there's no COM/ActiveX support in MQL4 - or in MQL5, for that matter.

 
jjc:

Personally I'd say there are three main things which DLLs get used for with MQL. One is indeed as a licensing or anti-decompilation measure. A second is processor-intensive code, such as neural networks, or anything which cannot realistically be done in MQL rather than in an OO language. The third is anything which requires more complex interfacing with other code than MQL is capable of. For example, there's no COM/ActiveX support in MQL4 - or in MQL5, for that matter.

Thanks.

 
fxCal wrote >>

I was exaggerating I guess. What I meant is that the ideology behind programming is 99% the same in most major languages, so really so long as you learn the theory behind programming, it doesn't matter what language you learn it in, the skills transfer over pretty easily. While I might not be able to code in a new language tomorrow, I would be fairly confident in my ability to read through it and understand how it works.

As to your comment on Java, J# would be a lot like C# (though widely considered not as good), while other java versions (excluding JScript) are more like C and C++.

I'm really new to MQL4, what sort of things do people use .dll for? I've heard it referenced as a way to prevent people from decompiling and stealing .ex4 files, are there any other uses for it, or is that pretty much it? Forex and MQL4 are really interesting programming challenges for me, and I'm eager to learn all I can. Any links to information would be appreciated as well.

Well put. Although you can access the winapi in mql it still lacks complete support to things like function pointers. Other features are quite restrictive like the whole file access stuff.

jjc wrote >>

Personally I'd say there are three main things which DLLs get used for with MQL. One is indeed as a licensing or anti-decompilation measure. A second is processor-intensive code, such as neural networks, or anything which cannot realistically be done in MQL rather than in an OO language. The third is anything which requires more complex interfacing with other code than MQL is capable of. For example, there's no COM/ActiveX support in MQL4 - or in MQL5, for that matter.

jjc is bang on regarding usage, essentially if its too hard to do in mql do it in a dll, other advantages are obviously performance. MetaTrader 4 performance is adequate for simple systems, something which MetaTrader 5 tries to address. I personally have used mostly to integrate to other products.

 
jcadong5 wrote >>

thank you pfx

i guess if i want to stick with my baby (java), i can make a c/c++ java native (called JNI) combination.

Perfect also search the forum, i'm sure I have seen a reference to a java sdk someone has written from metatrader 4. Couldn't help myself here is the link https://www.mql5.com/en/forum/121466

 
jjc wrote >>

HTTP connections and "alternative file access" (I assume you mean reading/writing files anywhere on the hard disk) can both be done in MQL by importing calls from the Windows API. For example, https://www.mql5.com/en/forum/118999 and https://www.mql5.com/en/code/8435. (I've not personally tried using the latter, and there are several alternative HTTP libraries available on this forum.)

Personally I know little about Java, and nothing about JNI, but the brief Wikipedia page on the latter doesn't make it look likely that you can call JNI code directly from MQL, i.e. without still needing a DLL as an intermediary.

Yes, we still need c/c++ in the middle between mql4 and java. JNI enables java to talk to c/c++.

Reason: