User Name:  
Forgot Password?
Sign up with

Join now (it's free)

User Name:
First Name:
Last Name:

Introduction to Programming Expert Advisors in MQL4

Developed by MetaQuotes Software Corporation, Metatrader 4 (abbreviated as MT4) has become one of the most popular trading platforms for forex for the following reasons: 
  1. It is completely free (zero upfront fees or monthly subscriptions)
  2. It is a widely supported by many brokers
  3. It includes many useful analysis tools
  4. It has a worldwide community of traders
  5. It has a powerful MQL4 programing language
Similar packages for equities and futures can cost over $1000 and/or have $100+ monthly subscription fees, whereas MT4 is completely free. Literally hundreds of forex brokers around the world have adopted the software as the platform of choice for their clients because of its popularity. Clients who do not want to program can use any of the advanced analysis tools in the platform. Clients who do want to program, or take advantage of the programming skills of others, can enter a worldwide community of traders and programmers who have developed hundreds of free and commercial indicators and expert advisors. 

There are many reasons for why a trader should try to learn how to program an expert advisor: 
  1. Expert advisors can trade for you 24 hrs per day without food or sleep. 
  2. Expert advisor operate on a set of rules without greed, fear, ego or bias.
  3. Expert advisors helps combat emotions by getting you in and out of the market based on historically tested strategies. 
  4. Expert advisors are able to identify and react to opportunities faster. 
  5. Expert advisors give you the potential to trade with complex systems that can include multiple conditions for their entries and exits, profit targets, protective stops, trailing stops, and filters, and have them all automated simultaneously. 
  6. Expert advisors can monitor many currency pairs at the same time, giving you many more trading opportunities than manual trading. 
  7. Trading with an expert advisor is a lot easier as the robot has taken over most of the tasks of the manual trader does. 
Of course, one can go out and purchase or borrow the expert advisors of others to trade with, and that is perfectly fine. But if you really want to build an edge factor into your trading, you will strive to learn to program expert advisors, so that you can add to (or hybridize) the best efforts of others and/or develop unique trading systems of your own. 

There are a couple things worth noting about the Metatrader's powerful programming language, called MQL or MQL4, after the Metatrader 4.0 platform: 
  1. MQL4 bears a similarity to programming languages such as C and Java, and thus easy to pick up by programmers. It resembles C in its procedural part and language constructs. It resembles a stripped down version of Java without classes. Programmers already familiar with C or Java might find MQL4 easy to code with. New programmers who want to code in MLQ4 might want to learn C or Java in order to learn its language faster and code better, if you have the time to do so. The problem is, learning a programming language like C or Java take a lot of time, and neither are easy languages to learn for beginners.  
  2. MQL4 can be relatively difficult language to pick up for a beginner without prior programming knowledge. It is easier to learn than C, but not necessarily a walk in the park. MQL4 is a relatively low level programming language that requires the programmer to create custom functions and procedures for handling simple trading functions such as a trailing stop. Fear not, however, you will never be required to program these custom functions from scratch, as you can always learn from the work of others. 
  3. Metatrader itself has many quirks that the programmer needs to be aware of, and it can take dozens of hours of troubleshooting to learn the techniques necessary to program expert advisors.
This guide seeks to help the beginning programmer how to successfully code an expert advisor. There are many tips and tricks, custom functions and procedures, that can take hours to learn, but we will hope to shorten the learning the curve by honing in on the essentials, the parts that are important to learn. Once you learn these essential parts, you will then have the ability to create huge numbers of expert advisors, depending on your time, trading knowledge and creativity, and like learning any new language or skill, the more you practice at it the more you will become fluent in all its finer details.

An e-mail with your verification code has been sent to your e-mail address. Please access your in-box and use the verification button or verification code to complete your registration.
You already have an account linked with this E-mail (it maybe standard or social login). Please, sign in with it.
Please, provide us your e-mail so we can verify your account.