• Home
  • Free MQL4 Course
  • MQL4 Forums
Forex Mentor Pro
  • Free MQL4 Course
  • MQL4 Made Easy
  • MQL4 Programming
  • Expert Advisors
  • Articles

Improved Input Settings in MQL4

zx spectrum

The new build of MT4 has some people pretty upset and as I mentioned in the last article I wrote on Build 600, I'm really not sure why.

I choose to see the changes as a good thing and as a simplified transition from MQL4 to MQL5, or a mixture of the two. If you want to continue to code in 'old school' MQL4 then you're free to do so, nobody is forcing anybody to change the way they work to any large degree.

If you want to continue to code in 'old school' MQL4 then you're free to do so, nobody is forcing anybody to change the way they work
We're being given options and as far as I'm concerned, that's a good thing.

There are lots of new additions and changes that will be seen by some as a headache and by others as an exciting playground to learn new ways of doing things. It's all about perspective and how you decide to view things.

Are you a 'glass half full' type or a 'glass half empty' type?

Enumerations in MQL4

Here's a nice example of one of the new features in MQL4 that I really like. It's a relatively simple thing and has been available in other programming languages for ages.

Enumerations are a neat way of grouping similar items together in much the same way as we can do with arrays. We could have an array called 'arrDays()' that would hold a collection of days or we could have an enumeration called 'enum_days' that does the same thing.

The main difference is that enumerations are constants so once they're set they can't be changed later, unlike arrays.

Sounds complicated at first but it's really pretty straightforward and as always, check the help file for more examples.

OK so what's the 'improved inputs' that I referred to in the title of this article.

Here it is...

The other week I wrote a simple dashboard so that I could monitor all the currency pairs offered by my broker and alert me when certain conditions were met.

dashboard-screen

Pretty standard stuff so far and it was just something I put together quickly for my own use.

I had already changed from 'normal' external variables to the new 'input' variables but did a bit more reading and found something interesting.

The new build of MQL4 allows you to use enumerations in your input variables and lets you have drop-downs and 'friendly names'.

For my dashboard I was using a fixed font size which was fine because it was only for my own personal use. I wanted to utilize the new enumeration feature so thought it might be cool to have a small, medium and large setting.

As I say, there's no pressing need for it but I just thought it would be cool.

The original font size variable declaration looked like this...

input int fontSize = 12;

Then to use the new enumeration feature I just added a definition and changed the input type.

enum e_fontSize{
 small=10, //Small
 medium=12, //Medium
 large=14, //Large
};
input e_fontSize  fontsize = medium;

Now I get a pretty cool drop down that allows me to change the font size without having to input any numbers.

dashboard-settings

I used this as a simple example and since it's only for my own usage there's no real need. It was just to experiment with using enumerations in MQL4 and get some ideas as to how I might use them in the future.

The other thing to notice is that the comment that comes after each item in the enumeration is displayed in the settings. This way you can have a more 'friendly' and readable values for the end user.

If you take a look in the MetaEditor help file you'll see that the new build of MQL4 already comes with a ton of built-in enumerations. The ones that immediately caught my eye were the ones relating to moving average settings.

Previously I would have to use the integer values in the settings which always caused confusion for my clients. I would have to include a comment both in the code and above the actual settings to explain what each number meant.

Now it's possible to just use the built-in enumerations and take advantage of the cool drop-down boxes.

Take a look in the help file at ENUM_MA_METHOD and ENUM_APPLIED_PRICE to get more ideas.

There's bound to be a period of teething problems as with any new piece of software, but on the whole I think the new changes to MQL4 will be good for everybody.

You can choose to either embrace the changes and make them work for you or you can choose to be one of the whiners and complainers.

I know which one I'd prefer to be.

Jul 7, 2014Steve Fleming

Steve Fleming

Steve Fleming has been a professional programmer for over 20 years and has programmed in MQL4 almost exclusively since 2007. He has coded 100's of EA's and indicators for his growing list of satisfied clients and has helped 1000's of people learn how to code their own EA's.

If you would like to have your strategy coded by Steve Fleming or receive one-on-one training, then please send an email to [email protected] .

More Posts



Keltner Pro
5 Forex Mistakes You May Be MakingPrice Action Trading Really Works

Leave a Reply Cancel reply

July 7, 2014 MQL4 Programming enumeration, mql4, progress3,964
Forex Mentor Pro
Start Learning MQL4 Today!
Recent Posts
  • Instantly Save Yourself $200
  • How to Create a Simple Toggle Button in MQL4
  • Does The Perfect EA Really Exist?
  • Improved Input Settings in MQL4 – Part 2
  • How to Install MQL4 Experts Advisors, Indicators and Scripts
Recent Comments
  • Steve Fleming on Free Tool to Help With Pair Trading
  • Pedro Paredinha on Free Tool to Help With Pair Trading
  • shelton colds jr on R.E.A.D – A Simple Template Approach to Coding in MQL4
  • Steve Fleming on Improved Input Settings in MQL4 – Part 2
  • Dulcy Tsosie on Improved Input Settings in MQL4 – Part 2
Tags
mql4expert advisorsbuild 600metatraderforexexpert advisortutorialarraymarketplaceautomated trading software
GPS Forex Robot
MQL4 Programming

Learning to code in MQL4 can seem difficult at first but once you get the hang of it you'll find it quite easy. The best way to get started is with a free course and you'll find a great one [...]

| 6 Comments Learn More
Testimonials
I came to Steve with the aim of learning how to write expert advisors. With his great teaching style and structured course I have been able to learn an enormous amount and have been able to write a number of expert advisors myself. As I develop various systems and sometimes come across issues Steve is always a great source of help. I look forward to developing more expert advisors and using Steve as a mentor as and when required.
AlanSingapore
After extensively researching around for a coach to fast-track my ability to code Expert Advisors, I came across Steve Fleming. Right from the beginning I found Steve to be very helpful and motivating, within five weeks of coaching I am coding my first EA. Programming is just like any other skill in life, it takes time to learn and I know without a coach like Steve, it would have taken me months to learn MQL. Most importantly what I found in Steve is someone who wants to see you succeed as a … Read more
DeonBrisbane
Working with Steve has really cleared the fog for me as it relates to writing my own EA’s. I had no prior code writing experience. Prior to working with Steve, I had bought every book available on MQL, read lots of blogs and downloaded pdf lessons. But, none of these resources could answer any of my questions. Working with Steve has given me a much broader understanding of how to write code. He not only teaches you how to write an EA, but explains the best coding practices so you are writing cod… Read more
MichaelIdaho
Market Hours
© Automated Trading Software  2008 - 
Contact |  Sitemap |  Risk Warning |  Privacy |  T & C

Free MQL4 Course

Enter your best email address in the box below and get my 5 day MQL4 course immediately!

Arrow