Home › Forums › Development › Coders Supporting Coders
This topic has been reported for inappropriate content
Tagged: new mq4 coding style
- This topic has 58 replies, 15 voices, and was last updated 4 years, 7 months ago by
simplex.
-
AuthorPosts
-
Hi Fellow Coders!
- Got stuck in an indicator project?
- Want to improve your coding skills?
- Need somebody to listen while you’re complaining about the pitfalls of MQ4 or MQ5?
- Got some exotic coding idea and want to discuss it before actually starting a project?
- Looking for a fellow coder to team up in a particular project?
- Getting some error message again and again?
- Like to share a link interesting for fellow MQL coders?
- Looking for a coding related link and can’t find some?
- Need some ‘how to’ advice in a project?
If only one of your answers would be ‘yes’, this thread is supposed to be your place to visit. If your question is not in my list, but you feel it would fit: this is your place, too!
Whether you would label your question newbie, apprentice, advanced, or master class level – just don’t hesitate to post it!
A note to newbie coders: if you’re asking ‘How do I code an MQ4 indicator?‘, please don’t expect a super exhaustive answer! Expect a link or two, if you’re lucky. There’s other places on the web to provide this kind of information. Ask for that specific link, if you’re looking for it.
During the weeks that have passed now since this forum exists, we’ve discussed several technical items related more to coding than to a specific trading method on other threads. I will collect some of those posts and repost them here if this makes sense. If those discussions took place in private groups I will possibly strip them down a bit.
Looking forward to your contributions!
simplex
A good trader is a realist who wants to grab a chunk from the body of a trend, leaving top- and bottom-fishing to people on an ego trip. (Dr. Alexander Elder)
This reply has been reported for inappropriate content.
Congratulation Brother,
1st Subcriber..
Intuition, Experiences and Common sense..
http://www.binaryoptionsedge.com/This reply has been reported for inappropriate content.
Awesome Simplex! Subscribed here as well!
Focus, Patience, Determination & Order in chaos
This reply has been reported for inappropriate content.
Compiled from another thread:
One thought related to debugging: I found it to be very useful to place
#property strict
in your code. It requires a bit (really only a bit) more discipline while coding to avoid compiling errors, but what you’ll get as a reward is much more detailed runtime errors, especially popular ‘array out of range’.
When using deeply nested loops or running optimizations I would suggest to at least give it a try. Personally, I try to compile all of my new code in strict mode. This provides a lot more confidence in my own code.
Find a detailed table about this setting here: http://docs.mql4.com/mql4changes#compiler_difference In the link provided scroll down to the large table in the middle of the article. This is where the details are being listed.
But that forces you to write the code with mql5 structure, doesn’t it?
No, that’s not necessary. It’s an instruction to the compiler to compile more strictly. In many cases you will notice a considerably higher number of compiler errors and warnings. Most of them are VERY easy to fix, a couple of minutes should be sufficient. Once getting used to it, you will automatically avoid code structures which lead to issues during compilation.
Regarding ‘array out of range’ error: this cannot be detected during compilation, it can only occur during runtime. When compiling in non-strict mode, array out of range is not considered a critical error. Thus the program will not terminate.
What’s the consquence? The indi or EA has come to a state that has not been intended by its coder. Some read or write operation when addressing an array cannot be executed, but the program will continue execution. This is a potentially dangerous situation.
If I’m the coder, I like to know when an array cell can’t be addressed properly. Thus:
#property strict
IMO, one of the best novelties in ‘new’ MQL4 to increase coding quality.Compiling in strict mode you can reuse variables in the same way as in non-strict mode. Albeit you have to be aware of where exactly you declare a variable – it’s not only the decision between global and local.
Consider the following code:
double MyFunc(…) { // do something if (someBoolean) { // BLOCK BEGIN double MyVar = 0; // do your stuff MyVar = …. ; } // BLOCK END // do more stuff return(MyVar); }
Compiled in non-strict mode, integer MyVar will have a function-wide scope, so its value can be returned.
Compiled in strict mode, the scope of a variable ends at the end of the block (not necessarily the function) in which it was declared. So our code will lead to a compiler error. If you want to compile this function in strict mode, the code has to be changed a bit:
double MyFunc(…) { double MyVar = 0; // do something if (someBoolean) { // BLOCK BEGIN // do your stuff MyVar = …. ; } // BLOCK END // do more stuff return(MyVar); }
If you declare MyVar outside the if-block, it will be visible function-wide, and your code will compile in strict mode.
Cheers, simplex
A good trader is a realist who wants to grab a chunk from the body of a trend, leaving top- and bottom-fishing to people on an ego trip. (Dr. Alexander Elder)
This reply has been reported for inappropriate content.
Learn New MQL Coding: MQL goes OOP
Some of us may continue struggling when trying to switch from old school MQ4 coding to the new opportunities build 600+ does offer. Especially using OOP methods continues to be a mighty mystery to me, personally.
broketrader started a nice thread over at FF that provides some entry level introduction: http://www.ff.com/showthread.php?t=473578 . It’s absolutely worth reading, but it doesn’t seem to be enough to get me started.
I’m absolutely convinced that introducing OOP methods in our old school code might make a big shift towards easier maintenance, sustainability, and stability of our projects. I’d like to move on in this direction.
Can anybody provide additional links to good resources to study?
Is an experienced OOP coder around who maybe would take the role of a mentor leading fellow coders on their path towards OOP?
Any suggestion would be appreciated!
A good trader is a realist who wants to grab a chunk from the body of a trend, leaving top- and bottom-fishing to people on an ego trip. (Dr. Alexander Elder)
This reply has been reported for inappropriate content.
A Multipair EA Shell
Can anybody provide a reliable multipair EA shell coded in MQ4? Specific Strategy doesn’t matter.
Currently I’m considering to code a multipair EA based on TZ, and it would be very nice not to start from scratch.
Any hint will be greatly appreciated!
A good trader is a realist who wants to grab a chunk from the body of a trend, leaving top- and bottom-fishing to people on an ego trip. (Dr. Alexander Elder)
This reply has been reported for inappropriate content.
A Multipair EA Shell Can anybody provide a reliable multipair EA shell coded in MQ4? Specific Strategy doesn’t matter. Currently I’m considering to code a multipair EA based on TZ, and it would be very nice not to start from scratch. Any hint will be greatly appreciated!
Even if i´m not a coder yet, maybe you could use https://fxdreema.com/ .. it is a website where you can configure your EA. Maybe it´s possible to just create your multipair construct with it. The website states that this is possible. Maybe it helps
"A dream you dream alone is only a dream. A dream you dream together is a reality." (John Lennon)
This reply has been reported for inappropriate content.
Even if i´m not a coder yet, maybe you could use https://fxdreema.com/ .
Thanks for the link – didn’t know them yet.
When it comes to EA generators, I’m very reluctant. Seen way too much rubbish in the past. At least it should be worth a closer look. Do you have any personal experience with their service?
A good trader is a realist who wants to grab a chunk from the body of a trend, leaving top- and bottom-fishing to people on an ego trip. (Dr. Alexander Elder)
This reply has been reported for inappropriate content.
Can anybody provide a reliable multipair EA shell coded in MQ4? Specific Strategy doesn’t matter.
Yesterday night I found xMeter MultiPair source at http://www.stevehopwoodforex.com/phpBB3/viewtopic.php?f=5&t=1310
This might work as a blueprint – although there’s a lot of work to do: I inserted
#property strict
, compiled it and got 23 errors and 214 compiler warnings.I’ll review their code more properly, and then maybe roll up my sleeves and make that thing run at first.
My call for a good blueprint remains open for now.
s.
A good trader is a realist who wants to grab a chunk from the body of a trend, leaving top- and bottom-fishing to people on an ego trip. (Dr. Alexander Elder)
This reply has been reported for inappropriate content.
Do you have any personal experience with their service?
Only playing around with it. Just thought that you could make your desired construct relatively easy with it , because you are already a coder and know what to look for within the given possibilities of this service.
Even with such a generator you still got to know what buffers do etc… i really think it might be just better to sit down and learn to code.
Such lego-like generators can´t really give to everything you want..
"A dream you dream alone is only a dream. A dream you dream together is a reality." (John Lennon)
This reply has been reported for inappropriate content.
Great thread Simplex. Subscribe … and thanks for the link @FF.
This reply has been reported for inappropriate content.
Just thought that you could make your desired construct relatively easy with it
Hehe – my ‘desired construct’ is a stable multipair EA shell – no matter which strategy. I seriously doubt that any MQL code generator in the world will provide this kind of output.
But anyway: thanks for the link you provided!
A good trader is a realist who wants to grab a chunk from the body of a trend, leaving top- and bottom-fishing to people on an ego trip. (Dr. Alexander Elder)
This reply has been reported for inappropriate content.
Hi Brothers and Sisters, Maybe this link could also help us when we start to learn mql programming. It is useful for me as I’m still noob in programming.
https://www.youtube.com/user/Jimdandy1958/playlists
Best Regards
MTH
Intuition, Experiences and Common sense..
http://www.binaryoptionsedge.com/This reply has been reported for inappropriate content.
Thanks for the link Kiads. But if you see yourself as a noob in coding then all real beginners will be too scared to even start *lol*
"A dream you dream alone is only a dream. A dream you dream together is a reality." (John Lennon)
[ LearnAlways ]January 20, 2015 at 10:29 am #4262This reply has been reported for inappropriate content.
Just thought that you could make your desired construct relatively easy with it
Hehe – my ‘desired construct’ is a stable multipair EA shell – no matter which strategy. I seriously doubt that any MQL code generator in the world will provide this kind of output. But anyway: thanks for the link you provided!
Hi Simplex,
Pls check out http://www.stevehopwoodforex.com/phpBB3/viewtopic.php?f=37&t=3565 . Not sure if its the one u looking for The Dream Team’s Unbelievably Magnificent Shell Thingy thread at SHF.
Best Regards,
LearnAlways
I only know I know nothing
Skype: learnalways@outlook.comThis reply has been reported for inappropriate content.
Not sure if its the one u looking for The Dream Team’s Unbelievably Magnificent Shell Thingy thread at SHF.
Hey LA,
Thanks for that link. I already reviewed Steve’s and Tommaso’s shell several weeks ago, but the link might be very useful to others. Unfortunately, it’s not a multipair shell. For single pair use, it’s definitely my favourite.
Now I’m considering which one is the better blueprint to start with.
simplex
A good trader is a realist who wants to grab a chunk from the body of a trend, leaving top- and bottom-fishing to people on an ego trip. (Dr. Alexander Elder)
This reply has been reported for inappropriate content.
Hello Gentlemen,
I am looking for an advice on how to change an indicator.
Back on ff.com, smallcat provided a script that writes the ingredients (OHLC of Bar, fractals etc.) of a Zig Zag leg to a txt file.
Its called “mt4tofile-2011-2012-v1.3”
Lately the components, that this script should work with, have changed.
It has to use the Fractal indicator based on the close value of a Bar. http://www.penguintraders.com/groups/fractal-arrow-prediction/documents/ // Fractal_Close_Mod
And it has to use the ZZ indicator that only connects to those Fractals. http://www.penguintraders.com/groups/fractal-arrow-prediction/documents/ // ZigZag Close Modified
I have replaced the names in iCustom to call the new indicator and while the script now writes the correct fractals into the txt file, the ZZ legs are wrong.
To find the correct ZZ leg the script originally used the indicator “SmallCatZzFractal-v1.1”.
So i also changed the iCustom in this indicator but it led to a more worse outcome.
Can someone please give a hint on how to adjust the attached script or indicator.
Thanks in advance.
Attachments:
You must be logged in to view attached files.This reply has been reported for inappropriate content.
I am looking for an advice on how to change an indicator.
Hey Koni,
Are the indicators you attached to your post the originals as provided by @smallcat or do they incorporate modifications by yourself?
Did you notice that SmallCatZzFractal-v1.1 requires an indicator called Custom ZigZag to run? See the iCustom call within smallcat’s code.
For the same reason, the script requires custom indicator Fractals_close to run. Without those indicators it will at least be difficult to solve your problem.
Can you provide links to those indicators or post them as well?
simplex
A good trader is a realist who wants to grab a chunk from the body of a trend, leaving top- and bottom-fishing to people on an ego trip. (Dr. Alexander Elder)
This reply has been reported for inappropriate content.
Hi simplex,
I ve made only one change.
“mt4tofile-2011-2012-v1.3.mq4” originally used the iCustom call “Fractals”, but i changed it to using “Fractals_Close_Mod” which can be found here http://www.penguintraders.com/groups/fractal-arrow-prediction/documents/
This works very well so i have tried to replace the name “Custom ZigZag” in “SmallCatZzFractal-v1.1” to the indicator name “ZigZag Close Modified”
Unfortunately the ZZ legs written to file are wrong.
I have also tried to replace i”Fractals ” within “SmallCatZzFractal-v1.1” with an appropriate iCustom call.
Also wont work :(
-
This reply was modified 8 years ago by
Koni.
Attachments:
You must be logged in to view attached files.This reply has been reported for inappropriate content.
This works very well so i have tried to replace the name “Custom ZigZag” in “SmallCatZzFractal-v1.1″ to the indicator name “ZigZag Close Modified”
Next question that comes to my mind: did you check whether the indicators you changed (original and new one) are using their respective indicator buffer numbers in the same way?
And maybe it would be a good idea to ask @smallcat directly because one of his indicators is involved. To be honest: at the moment I don’t have enough spare time to dive into this deeply, that’s why I’m suggesting to contact the original contributors.
cheers, s.
A good trader is a realist who wants to grab a chunk from the body of a trend, leaving top- and bottom-fishing to people on an ego trip. (Dr. Alexander Elder)
This reply has been reported for inappropriate content.
Hi simplex, I ve made only one change. “mt4tofile-2011-2012-v1.3.mq4″ originally used the iCustom call “Fractals”, but i changed it to using “Fractals_Close_Mod” which can be found here http://www.penguintraders.com/groups/fractal-arrow-prediction/documents/ This works very well so i have tried to replace the name “Custom ZigZag” in “SmallCatZzFractal-v1.1″ to the indicator name “ZigZag Close Modified” Unfortunately the ZZ legs written to file are wrong. I have also tried to replace i”Fractals ” within “SmallCatZzFractal-v1.1″ with an appropriate iCustom call. Also wont work :(
Hi Koni,
I just upload the mq4 of “Zz closed modified” file. Honestly i do not know it is the right way to get the close price of ZZ or not. May be you can get idea from there.
It is similar to default MT4 ZZ. So calling using iCustom is similar like you call the value of default MT4 ZZ. Hope this help.
Sorry, i am so busy these last weeks … still can not test it …
This reply has been reported for inappropriate content.
Hehe – my ‘desired construct’ is a stable multipair EA shell – no matter which strategy.
Ok – this seems to be a really nice one including a full featured dashboard:
http://www.stevehopwoodforex.com/phpBB3/viewtopic.php?f=89&t=4046#p110924
I’ll have a closer look over the weekend.
A good trader is a realist who wants to grab a chunk from the body of a trend, leaving top- and bottom-fishing to people on an ego trip. (Dr. Alexander Elder)
This reply has been reported for inappropriate content.
Hi,
Any body know how to make a line which does not include the Weekends ? The end of the line is in the future (i want to know if the line is still valid or already expired). I tried to create a function for this, but it is still failed.
I read some where in internet, if we use iBars/iBarShift, then it will automatically not included weekends in its calculation. so i did it like this ….
datetime CheckLifeTime(int lifeTimeDays, int TF, datetime beginTime) {
int beginBar = iBarShift(NULL,TF,beginTime);
int lifeTimeBars = (lifeTimeDays*24*60*60)/(TF*60);
int endBar = beginBar-lifeTimeBars;
datetime endTime = iTime(NULL,TF,endBar);
return(endTime);
}And i tried to call it like this :
targetTime = CheckLifeTime(theLifetimeDays,PERIOD_M15,iTime(NULL,PERIOD_M15,i));
The result of “endBar” is negative (because the bar is in the future). And the return value is always zero (the targetTime is in year 1970)… What is wrong ?Any ideas is welcome, Thanks in advance
This reply has been reported for inappropriate content.
Hi smallcat,
Sorry – missed your post for several days.
Actually I’m not sure whether I understand what you’re trying to achieve. Would certainly be easier to solve if we had your full status quo (full indicator code instead of snippets) and a description of what should be changed.
Otherwise anybody who is willing to support you would have to implement your snippets in another indicator, hoping to have met what’s your actual issue. This could be a lot of work, and since the chances to meet your problem exactly are small, nobody is answering.
Just my guess.
Cheers, simplex
A good trader is a realist who wants to grab a chunk from the body of a trend, leaving top- and bottom-fishing to people on an ego trip. (Dr. Alexander Elder)
This reply has been reported for inappropriate content.
Hi smallcat, Sorry – missed your post for several days. Actually I’m not sure whether I understand what you’re trying to achieve. Would certainly be easier to solve if we had your full status quo (full indicator code instead of snippets) and a description of what should be changed. Otherwise anybody who is willing to support you would have to implement your snippets in another indicator, hoping to have met what’s your actual issue. This could be a lot of work, and since the chances to meet your problem exactly are small, nobody is answering. Just my guess. Cheers, simplex
Thanks brother. I have finally found the solution by setting the TIME2 to future time, instead of using Bar. I use buffer to hold the rectangle information, then draw it after that.
Thanks, smallcat
-
This reply was modified 7 years, 11 months ago by
smallcat.
-
This reply was modified 7 years, 11 months ago by
smallcat.
-
This reply was modified 7 years, 11 months ago by
smallcat.
-
This reply was modified 3 years, 1 month ago by
lohnere.
Attachments:
You must be logged in to view attached files. -
AuthorPosts
- You must be logged in to reply to this topic.