MQL5 Code-Generating Capabilities

 
I've been researching the topic for some time now, but haven't been able to find the answers I was looking for. My question: Is it possible to control the features of the Visual Wizard programmatically? More broadly, my question relates to metaprogramming (code generating other code). There are several known techniques used in code gen, like expression trees, custom libraries (eg. codeDOM, T4) and plain writing of code to a string. What features in particular does MQL provide to facilitate metaprogramming? If it is not too much to ask, could somebody describe, in general terms of course, how Visual Wizard or any other EAbuilder generate MQL code? In addition, I couldn't find any references to Reflection in MQL documentation. Does it mean the language does not support this powerful technology (I'm only asking because it is used in expression trees for code gen)? If you cannot answer my questions directly, could you at least pinpoint the direction I should aim my research to? Thank you in advance for any help you can give me.
Documentation on MQL5: Standard Constants, Enumerations and Structures / Chart Constants / Types of Chart Events
  • www.mql5.com
Standard Constants, Enumerations and Structures / Chart Constants / Types of Chart Events - Documentation on MQL5
 
Burton:
I've been researching the topic for some time now, but haven't been able to find the answers I was looking for. My question: Is it possible to control the features of the Visual Wizard programmatically? More broadly, my question relates to metaprogramming (code generating other code). There are several known techniques used in code gen, like expression trees, custom libraries (eg. codeDOM, T4) and plain writing of code to a string. What features in particular does MQL provide to facilitate metaprogramming? If it is not too much to ask, could somebody describe, in general terms of course, how Visual Wizard or any other EAbuilder generate MQL code? In addition, I couldn't find any references to Reflection in MQL documentation. Does it mean the language does not support this powerful technology (I'm only asking because it is used in expression trees for code gen)? If you cannot answer my questions directly, could you at least pinpoint the direction I should aim my research to? Thank you in advance for any help you can give me.

Hi Burton,

Code generating other code ?, that sound silly. Did you meant Visual Programming (https://en.wikipedia.org/wiki/Visual_programming_language or just google that as well) ?.

If you meant visual programming, then here's my IMHO, visual programming is not powerful technology, they can not replace hand written programming. Visual programming by large is used mainly by people who does not understand computer language. There's also lack and limitation, simply to say there are not much ideas that can be implemented by using visual programming, mostly caused by visual programming it self and lack of programming knowledge of it's user. Many feature of programming language cannot be represent by visual programming, for example how to visualize classes and structures ?. In MQL4.com, we reviews some MQL4 EA that created by visual programming - they are terrible (EA Builder  and Molanis). 

By the time these people learn programming language, they will realize that they can write a better software than a visual programming does. 


That's my short IMHO reply if you meant Visual Programming.

If you meant something else, ... ups ...this is embarrassing, please disregards my reply as well.

:D 

 
Visual Programming is a part of my question. EA Builder and Molanis products have code generating capabilities, after you are done with your visual design the programs create executable source code. If it is not a trade secret, I  would like to know how they do it (in terms of concepts, no need to reveal actual code, which would be great though). Metaprogramming is not silly, but a very powerful technique that allows to accomplish many tasks (http://en.wikipedia.org/wiki/Metaprogramming), including Visual Programming. Another example is dynamic generation of programs, the ultimate goal I want to achieve. I guess it has something to do with MQL compiler, but I am unsure, hence I posed this question.
 

I think you mean something like this?

MQL5-Studio for HiAsm: http://mql-studio.ru/setup-mql5.htm

HiAsm Studio: http://hiasm.com/

 

Video (MQL5-Studio) : http://mql-studio.ru/player/video/1.mp4 

Unfortunately, only in Russian. 

 

Spasibo, tovarish, to chto nujno! Thanks, FinGeR! The program you referenced has some great capabilities along with environment commands that can be used to programmatically generate diagrams that subsequently generate MQL code. Brilliant! Also, the author, being such a kind person, gives a thorough description of how the program does what it does, and that sheds some light on how code generation occurs, although it's still pretty dark in here. In addition, while examining the discussion of this piece of software on the Russian side of MQL forum I stumbled across a very interesting block of code that I want to share here: https://www.mql5.com/ru/forum/3088/page2#comment_45377 . Urain claims that this code, supplied with a numerical position of an object in a list, is capable of retrieving a pointer to this object without knowing that object's type. This could very well be the first step towards reflection in MQL language.

Despite all this useful info, my question still stands, code generating process is still very unclear to me. How do you examine .mqh/mq5 files to know what classes are hidden there, what state they are in and how they behave? I'll try to bug HiAsm developer with my questions and experiment with Urain's code in the meanwhile, but if somebody possess knowledge in this sphere, I beg you to share it here.

P.S. I am primarily interested in very simple things, like how do I open mq files, how to go to a particular line in a file, how to select certain lines in a file, how to copy and paste stuff? I can accomplish some of the tasks using cmd and Clipboard class of .NET, but going to a line and selecting is an issue.