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

Button 1

How to Create a Simple Toggle Button in MQL4

Recently I started using an indicator that had been written by another programmer and initially it was doing a pretty good job. However,eventually I started getting annoyed with one particular implementation...

...or rather lack of implementation.

The indicator itself was a pretty simple affair and in essence all it did was to draw a series of lines starting from a predefined point. I'd drop the indicator on the chart, drag the zero line and the rest of the lines would be redrawn automatically, relative to it's position.

The problem came when I wanted to change the orientation of the lines and make the zero line the top rather than the bottom. The way the original programmer had coded it meant that the user would have to go into the settings, scroll down the list, identify the correct setting and change it from true to false.

Now instead of drawing the lines from zero upwards, it would draw them from zero downwards.

What a long winded way to accomplish a simple task!

So I decided it would be much simpler - and cooler - to have a button on the chart that would toggle the settings state from true to false. That way I wouldn't have to mess around with settings and instead could change the value by the click of a button.

Sounds pretty sweet right?

Well here's how you can do it too... (more…)

August 30, 2015 MQL4 Programming button, mql4, toggle
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