You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
@sokramm presumably you don't write DLLs in mql4 but rather in C/C++, right? you keep mql4 stuff in mqh and general stuff (logging, database access, etc.) in DLL?
My DLL's are in C++. Anything that is not strictly related to trading (file handling, databases, external tools) I code it in C++ and then call it when I need it from the respective mqh. I keep my mqh with code that needs mql4 libraries.
Some may say that it is not the best approach for speed, but currently my trading strategy is not so concerned about speed, and I care more about portability and having to some day rewrite my code in mql6 (or mql5 if I have to...) or any other trading platform that supports Win DLL's.
- write wrappers around the MQL init(), start() and deinit() functions, the MetaQuotes implementations are to limited for production-ready code. my wrappers are in include\core\...
Are you referring to the error checking or to something else? Could you explain what you mean? Thanks
yes, but not only. the wrappers provide a "safe environment" for code execution (includes error handling). it means i provide a lot of global variables to MQL code (many more than provided by MetaQuotes), store run-time status so the code can react to run-time status change, initialize loggers etc. indicators experts, scripts behave differently in init(), start(), deinit() and they all cause/are influenced by different bugs specific to ea/indicator/script. instead of trying to workaround the same bugs in every EA (for example) every module type (ea, indicator, script, library) has its own base header (in "include\core\..."). my aim was to provide some kind of pluggable MQL environment for fast prototyping of new code.
for ex. this includes the possibility to react to different UNINITIALIZE_REASONs in deinit() and init() without the need to write endless switch/if/else statements. like in other languages i only want to implement some kind of event handler and it should work out of the box.
the empty TestExpert from above:
it compiles fine. now i want to invoke some code similar to an event handler. out of the box it goes like this
again it compiles without further change. from "userland code" it looks like all the onInit* and onDeinit* functions are provided by the terminal. but they are not, it's the wrapper.
now i can concentrate on my Validate() logic and don't need to worry about if and when code is executed. this is what i mean with fast prototyping. in the global EA:init() for example i have this
this all are things i don't want to do again and again and again. i don't want to worry about 4 or 5 digit brokers. all this belongs in a global include that handles all situations specific to this type of module (T_EXPERT|T_SCRIPT|T_INDICATOR). i want to concentrate on business logic instead on MT4 "features" in a portable and compatible way.
what if i update one of the global includes? in windows file explorer i go to the experts folder, search for "*.ex4; mqlcache*" and delete everything. then i restart the terminal and wait a minute. if there's code i dont have the source code for i do a "Synchronize" with my repository located at a internet server. ex4 files without source code are stored in repository. now it doesn't matter if i change code at home, at the restaurant or at a clients office. everything it needs are one "delete" and one "synchronize".
how to make the onInit*() and onDeinit*() functions behave like build-in without compiler complains:
stdlib.mqh:
stdlib.mq4:
this way you only need to implement what you really need/want. of course you can keep the function bodies empty, this is just my personal default implementation.
with this you can, for example, write a script or an expert with all the logic in "init()", you don't need a "start()" function and the compiler doesn't complain. if it makes sense to you.
Ok, thanks for the response. In my case, I also never change my Init or deInit functions for new EA's.
I have a mqh where the trading logic is specified based on signals and indicators. I just need to change that part and I have a new EA with everything else (logging, error checking, trade management) working around it without extra effort.
Just a configuration file in case of needed adjustments.
Hi all,
You can use tortoisesvn to manage your code.
Regards,
Hi all,
You can use tortoisesvn to manage your code.
Regards,
But all the cool kids are using git now
But all the cool kids are using git now
True that.
SVN is so last decade.