Algorithmic Trading In Forex: Create Your First Forex Robot!

Trading With Forex Robots: Learn MQL4 Programming By Doing! Create Your First Algorithmic Trading System in MetaTrader 4
4.4 (489 ratings) Instead of using a simple lifetime average, Udemy calculates a
course's star rating by considering a number of different factors
such as the number of ratings, the age of ratings, and the
likelihood of fraudulent ratings.
6,292 students enrolled
$19
$185
90% off
Take This Course
  • Lectures 40
  • Length 6.5 hours
  • Skill Level All Levels
  • Languages English
  • Includes Lifetime access
    30 day money back guarantee!
    Available on iOS and Android
    Certificate of Completion
Wishlisted Wishlist

How taking a course works

Discover

Find online courses made by experts from around the world.

Learn

Take your courses with you and learn anywhere, anytime.

Master

Learn and practice real-world skills and achieve your goals.

About This Course

Published 8/2014 English

Course Description

Latest News: Course Updated Again in July 2015 (MT4 Build 840+)

Learn to program in MQL4 and develop, test, and optimize your own algorithmic trading systems. This course assumes no prior programming or Forex knowledge, just a desire to learn and be successful

In the first section of this course we will install MetaTrader 4, open a free demo account, and learn the essential theory behind algorithmic trading.

The second section focuses on fundamentals of programming. Even if you have never programmed before, this part of the course will quickly bring you up to speed. Moreover, MQL4 is a C-based programming language and everything you learn in this section will also be applicable in languages like C / C++ / C# / Java / etc.

Section three introduces trading system design and gradually blends it with the programming knowledge you developed in section two. Here you will learn how to open your first order through a program also created by you, and how to then work with that order to modify or close it at your discretion.

Finally, everything is put together in the fourth section of the course, where we will come up with a unique trading strategy idea and turn it into a holistic Algorithmic Trading system. Also, I will briefly show you how to test and optimize your Forex Robot in the MetaTrader 4 strategy tester.

Enrol today and kick-start your Algorithmic Trading journey!

I'll see you inside

What are the requirements?

  • Basic fluency with computers

What am I going to get from this course?

  • Learn what algorithmic trading is
  • Quickly & simply learn basic MQL4 programming
  • Learn elementary concepts of trading system design
  • Send, modify, and close your first market order
  • Learn how to create, test, and optimize algorithmic trading systems (expert advisors)

What is the target audience?

  • Anyone who wants to learn the fundamentals of algorithmic trading
  • Anyone who wants to learn a programming language by doing
  • Anyone who wants to practice real-life application of C-based programming

What you get with this course?

Not for you? No problem.
30 day money back guarantee.

Forever yours.
Lifetime access.

Learn on the go.
Desktop, iOS and Android.

Get rewarded.
Certificate of completion.

Curriculum

Section 1: Introduction
02:18

In this short video we will outline some of the topics covered in this free comprehensive course on MQL4 programming. In under 3 minutes we will briefly touch on some interesting aspects of the course, giving you an idea of what you can expect from this series of tutorials on Algorithmic Trading. In this course altogether there is 37 lectures, 3 quizzes, and over 6 hours of quality content! I look forward to taking this journey with you.

Disclaimer
00:43
10:46

In this video I will show you how to install MetaTrader 4 build 600+ and open a free demo account without giving away any personal information! We will use this demo account in further tutorials to test our scripts and expert advisors. You can skip this tutorial if you already have a demo account.

IMPORTANT: Please make sure that in these tutorials you are practicing on a DEMO account. In the present course we will be creating scripts and other software which will carry out transactions on your account via the MetaTrader 4 trading platform. Therefore, you need to use a DEMO account for these educational purposes.

05:31

In this short video we will understand the basic principles that allow MetaTrader 4 and MetaEditor to work together. At a very high level I will explain how expert advisors, indicators and scripts are able to execute operations on the FOREX market.

Where to get the Source Codes for this course?
03:40
Section 2: Programming Core MQL4
06:54

Welcome to the first video-tutorial on MQL4 programming for complete beginners!

In this tutorial we will get to know the MetaEditor programming environment, get comfortable with the Graphical User Interface (GUI), and create our very own first MQL4-program! Exciting, isn’t it? This is a very basic tutorial to get you started.

After starting the video, click the maximise button to make it fullscreen and also watch in HD quality so you can see the code clearly!

10:11

In this second tutorial I will show you what variables look like in MT4. We will understand the concept of a variable being a box, where data is kept. Different types of boxes (variables) have the capacity to store different data. This notion is also discussed in the tutorial. We will look at the following types of variables:

  • int
  • double
  • string
  • bool
  • color
  • datetime
10:23

In this tutorial I explain how to use basic MQL4 variables such integers, doubles, strings, and others. We also touch on simple operations: addition, subtraction, multiplication, and division. Finally, we learn how to concatenate strings. All illustrations are supported with working examples using the Alert() statement.

06:09

Hey there!

So, we have already learned about different types of variables including boolean variables. Today we will look at a variety of logical expressions. This is an important part of the decision-making process for automated trading system construction. In this short tutorial you will learn how to compare values using operators such as >, >=, <, <=, == and others, and assign and store the results in boolean variables. Let’s get straight into it!

And remember – if you have any questions, just leave a comment in the feedback form after the video or contact me personally! I am always happy to help out.

07:25

Hi there, I think that you will find this tutorial rather exciting! Why? Because today we will be looking your very first while loop! If you have never ever used loops before, then don’t worry – I will explain everything in detail and as usual we will see how it all works in practice. However, if you are new to programming, I recommend paying detailed attention and making sure that you understand this tutorial before moving on with the course. Feel free to ask any questions – I am here to help. PS: questions can be posted in the comments section after the video.

03:59

Hello there! Today’s tutorial is very short – in just over 3-minutes we will get to know how to use multi-line commentary in MQL4. Believe me – it is very easy! At the same time, as you will see multi-line comments are a very powerful tool and can make your programming experience so much more pleasurable: instead of deleting whole blocks of code you can use multi-line comments to “hide” these block away. Commented code will even change colour to show that it will not be executed.

07:46

The “for” loop is very similar to the “while” loop, however the “for” loop is much more commonly used. This trend is evident in other programming languages as well as in MQL4. Most likely, the “for” loop is preferred because it is more convenient. In today’s tutorial I will show you how the two loops compare to each other, and you can then decide for yourself which you prefer. Both are equally valid approaches..

Actually, this happens quite a lot in programming. Often, you can implement the same thing in two (or more) different ways, and only your personal preference will guide you to pick one. This is totally normal. Moreover, this is how people develop their ownprogramming styles, which is natural. So congratulations! Today you are making your first step towards developing your personal unique coding style.

09:01

Finally! Today we are going to apply our knowledge to the Forex market and work with some real-time EURUSD prices. Very exciting stuff!

We will learn about the if statement and see how we can use it to add decision-making processes to our future FX Robots. Note that the next couple of tutorials will be building on top of this one, so make sure you follow the code in the video carefully! Luckily, in this course we learn by doing, so if you do happen to make an error somewhere – you will be able to pick it up right away. Otherwise, If you run into trouble – why not leave me a comment with your question?

09:05

The Else statement complements the if statement, and together the two work hand-in-hand. Just like in the previous tutorial, in this video we will study the new bit of information through a real-life example. You will learn how easy it is to simulate trading decisions in a price channel using the if and else statements. Let’s do it!

10:46

Today we will finish up with conditional (branching) statements by looking at the else ifstatement. It all really comes together in this tutorial. Detailed visualisations of a EURUSD chart are used to illustrate how the implemented logic would be used in an Algorithmic Trading. You will notice from this video that we are actually looking at a thebackbone of a real working trading strategy! Psssstt: by the end of this course you will be able to build the whole strategy start to finish! Isn’t that exciting?!

09:07

The Switch Operator is a handy tool for implementing lengthy conditional statements. However, from the previous three tutorials we already know a very simple tool for doing the same thing – multiple “if”, “else if”, and “else” statements. Now this alternative may not be as elegant as using the Switch operator, but it is simpler. Having that in mind, consider this tutorial optional. Do watch it if you would like to learn some extra information, otherwise feel free to skip straight to the next one! After all, you can always revisit any of the videos at a later stage.

07:51

In this video we will recap what was discussed in this Core MQL4 section of the course. It is highly advisable that you know well all of this material, because it will be required in the next section. Don’t forget to do the quiz!

I look forward to seeing you on the next tutorial. Any feedback is appreciated!

10 questions

Some really quick multiple choice questions to help you recap what we learned in this section.

There is one question for each lecture except for the one about the Switch operator.

Good luck!

Section 3: System design and trading functions
14:14

Hello there! Today we will be looking at some examples of how you would use price levels in an Algorithmic Trading System. In fact, this approach can be used in manual trading strategies as well. The stuff we will be working with today is very basic, so you will find it very simple. At the same time, easy strategies are the best to practice programming for financial markets.

There won’t be any coding in today’s tutorial, so you can just watch it in relaxed mode :)We will turn one of the underlying strategies into code next time.

10:34

Welcome back! In this tutorial we will take one of the strategies we discussed last time and turn into into an MQL4 program.

Also, another important aspect of today’s lesson is – incorporating trader input. We will work with extern variables, which will allow us to create parameters for the trader. In that way the trader can control the script directly from the MetaTrader 4 Forex Platform.

Extern variables will come in very handy when we start coding our expert advisor. So pay attention today! :)

08:53

Spoiler alert: today will be an extremely exciting tutorial! For the first time in this course we will execute a market order!

If you include the Intro videos, then we’ve had nearly 20 lessons, so I think that we deserve to finally send a market order.

We’re going to jump straight into it, so hold on tight!

13:49

Today we are going to talk about a fundamental cornerstone of any programminglanguage – functions.

To execute a market order in the past tutorial we used the OrderSend() function. Well,MQL4 has many more other functions which we will be using throughout this course. Therefore, it is important to understand what functions are and how they work.

In this tutorial I will even show you how to create functions of your own. After you create your first function everything will fall into place and the next couple of tutorials in this course will seem like a piece of cake!

15:58

Have you ever had problems with computer software? Perhaps a program crashed while you were working in it, and you lost a lot of information or had to redo work? Well, can you imagine if that happens to an FX-Robot? If a program (script / expert advisor) crashes while trading on the Forex market, the consequences can be catastrophic!

That’s why in today’s tutorial we will learn how to create fail-safe blocks of code which willprotect the trader using our programs in the event of a malfunction. Today we will discuss the minimal error-handling that you would want to add to your programs. For more on this topic, check out my premium course Algorithmic Trading For Success!

10:05

In Tutorial 15 we learned how to open market orders from within Algorithmic Trading Systems. Closing orders is equally important and today I will show you how it’s done.

Also, we will further continue working with order ticket numbers. This skill of handling tickets will come in useful when we start programming expert advisors in section 3 of this course.

12:10

We have already discussed how to open and close market orders through a FOREX robot. Today we will learn how you can get your Algorithmic Trading system to adjust market orders. In order to do this you will need to use the OrderModify() function.

Modifying market orders is used to adjust the StopLoss (e.g. trailing stoploss),TakeProfit, and other parameters of the orders. In many trading systems it is imperative to modify existing market orders and that is why I have included this topic in this basic course.

Note that in this beginners course we will not be working with pending orders. If you want to learn about pending orders (such as Buy-Limit, Sell-Limit, Buy-Stop, and Sell-Stop) then look at my premium course Algorithmic Trading For Success.

19:37

How do we track market orders? Manually it’s easy – you just look at the information provided at the bottom of the terminal. But what if we want to do it from inside a Forex-robot?

Well, it’s also pretty simple – we just need to use the OrderSelect() function to select the order and then we are able to use a range of functions to find out additional information about our order. Today I will show you how to use OrderSelect(), OrderStopLoss(), OrderTakeProfit().

Also, I will give you an extremely useful tip on how to check if an order has been closed or not using the OrderCloseTime() function. This part will be very important when we get to coding our Expert Advisor in Section 3 of the course.

06:18

In this brief tutorial we will recap on all of the knowledge gained in Section 3: System design and trading functions.

In this section we covered off some important topics such as how to design basic trading systems, how to incorporate trader input in algorithmic trading systems, what functions are and how to build your own functions. Also, we talked extensively about the followingtrading functions: OrderSend(), OrderClose(), OrderModify().

Finally, we discussed how to get information on market orders through OrderSelect() and assisting functions. We will need all of this knowledge in our next section, so please make sure that you are quite comfortable with everything we have learned up until now.

10 questions

Some really quick multiple choice questions to help you recap what we learned in this section.

There are two question for each lecture.

Good luck!

Section 4: Putting it all together
10:42

In this tutorial we will introduce a new type of program in MQL4 – expert advisors.

In essence, expert advisors (EA’s) are your Forex robots. There are some key differences between expert advisors and scrips, and we will discuss them in this tutorial.

Also, we will create our first test EA and see how it works in the MetaTrader 4 trading terminal.

Source code below video. Important: remember that this is no longer a script – it’s an expert advisor now, and therefore you need to select the associated option in when using the MetaEditor Wizard.

14:37

Developing a trading strategy is a very important part of any Algorithmic Trading System (Forex Robot). In fact, it is the basis!

You can’t just go and start programming a system not knowing what you want to get in the end. Sure, your goals may change in the process. However, always before you start you should have a plan in mind or even better – on a piece of paper.

That is why today and in the next two tutorials we will have a short break from programming and focus on developing our trading strategy. In this tutorial we will learn about different types of rule-based decisions, which you might consider for your Algorithmic Trading System.

13:11

In today’s tutorial we will brainstorm and together come up with a trading strategy idea for the GBPUSD. I think it’s important to enjoy what you program in MQL4, and therefore instead of coding something generic in the upcoming tutorials, we will be working on this really cool trend retracement idea. Look inside to find out more!

15:32

Interested in Automated Trading System design? Well this tutorial is exactly what you need to improve your skills!

Today we will turn our Forex trading idea into a holistic trading strategy. Moreover, we will put it all into a fancy looking diagram to help our programming down the track, and I will show you how this is done too!

12:18

The preparation stage is complete and today we will finally start programming our FOREX Robot in MQL4. We will start by completing the blue section of the trading strategy design template, which is responsible for time of day controls. If you recall we want our expert advisor to send buy and sell orders only once at a certain hour of every day. That is exactly what we will implement today.

16:56

Today we will continue coding the Simple System expert advisor. In this tutorial we will program the core of our Algorithmic Trading System.

We will use the OrderSend() function to send Buy and Sell orders to the market based on which way the price has moved. To check the price we will be using the Open[] array, which Metaeditor provides for us.

11:16

In this video we will complete our Forex Robot by adding market exit conditions to it. Specifically, we want to close any existing orders before we the Algorithmic Trading System opens new ones. This way we will make sure that there is only one open order at any given time, therefore limiting our currency risk and exposure.

Feel free to leave me some feedback if you have any questions on the code or if you just like my tutorials!

15:47

Today we will learn the very basics of backtesting. We will practice using the Metatrader Strategy Tester and see how we can optimize the expert advisor which we have created. We will find two different sets of parameters, which will both be profitable in the backtest.

Please note: do not use this expert advisor for trading on your real account. This Forex robot has been developed exclusively for educational purposes.

12:37

In this tutorial we will add the moving average indicator as an additional market entry condition to our trading strategy. To do this we will use the iMA() function which is built-in into MQL4. Functions such as iMA, iMACD, iRSI and many others allow you to quickly access the Moving Average, MACD, RSI and other indicators from within your Algorithmic Trading Systems. In this beginners course we will only touch on the iMA() briefly, but that should be enough for what we need in our trading system.

11:13

Welcome back to our Series of Tutorials! Today we are going to compare how our algorithmic trading system performs before and after adding the Moving Average entry filter. This will allow us to evaluate the effectiveness of this filter. Then we will learn how to optimise the filter for a given set of parameters. Do you think we can boost the result of our system by an extra 5% ?? Well let’s find out!

07:28

In this short tutorial we will summarize everything we learned in the previous section called “Putting it all together”. Looking back you will see how we first came up with an idea, then put that idea into a diagram, then programmed the algorithmic trading systemstep-by-step, making sure that everything works correctly every time, and finally we back-tested our algorithmic trading system, added a moving average filter, and even optimizedthis filter to get the maximum profit!

IMPORTANT: I just wanted to stress one more time that the expert advisor from this course is only for educational purposes. If you choose to use it on any account, then you are doing so at your own risk. Forex trading carries substantial risks, and you could lose all of your investment.

10 questions

A series of brief multiple choice questions to help you revise what we learned in this section.

I should warn you! This quiz is tough and you have to be on your A-Game this time.

Good luck!

Section 5: Course summary
*** Share This Course ***
Article
04:58

In this tutorial I will suggest some next steps which you may consider taking to further improve your MQL4 programming and algorithmic trading skills.

I am currently working on more FREE as well as Premium courses. Once published they will be available through this page: http://www.forexboat.com/courses/

It has been a pleasure learning together and I look forward to seeing you at the next series of lectures. Until then – happy coding!

***EXCLUSIVE BONUS FOR STUDENTS***
Article

Students Who Viewed This Course Also Viewed

  • Loading
  • Loading
  • Loading

Instructor Biography

Kirill Eremenko, Data Scientist & Forex Systems Expert

My name is Kirill Eremenko and I am super-psyched that you are reading this!

I teach courses in two distinct Business areas on Udemy: Data Science and Forex Trading. I want you to be confident that I can deliver the best training there is, so below is some of my background in both these fields.

Data Science

Professionally, I am a Data Science management consultant with over five years of experience in finance, retail, transport and other industries. I was trained by the best analytics mentors at Deloitte Australia and today I leverage Big Data to drive business strategy, revamp customer experience and revolutionize existing operational processes.

From my courses you will straight away notice how I combine my real-life experience and academic background in Physics and Mathematics to deliver professional step-by-step coaching in the space of Data Science. I am also passionate about public speaking, and regularly present on Big Data at leading Australian universities and industry events.

Forex Trading

Since 2007 I have been actively involved in the Forex market as a trader as well as running programming courses in MQL4. Forex trading is something I really enjoy, because the Forex market can give you financial, and more importantly - personal freedom.

In my other life I am a Data Scientist - I study numbers to analyze patterns in business processes and human behaviour... Sound familiar? Yep! Coincidentally, I am a big fan of Algorithmic Trading :) EAs, Forex Robots, Indicators, Scripts, MQL4, even java programming for Forex - Love It All!

Summary

To sum up, I am absolutely and utterly passionate about both Data Science and Forex Trading and I am looking forward to sharing my passion and knowledge with you!

Instructor Biography

Martín Durán - (Kirill's Team), Financial Analyst and Forex Trader

Hello, my name is Martín Durán.

I teach courses related to Forex Trading. I want to provide you some information related to my background:

Financial Planning

Professionally, I am a Financial Analyst with almost four years of experience in healthcare industry.

Forex Trading

Since 2008 I have been trading the Forex Market and I think there are plenty of opportunities to obtain financial benefits form this Market which can be translated into financial and personal freedom.

Summary

I think that my experience as Financial Analyst and my efforts in Forex Trading represent a good combination in order to share with you knowledge and tools for you to apply.

Instructor Biography

Hi there,

We are the ForexBoat team. You will find us in the Forex courses by Kirill Eremenko - we are here to help you out with any questions and make sure your journey through the courses is always smooth sailing!

The best way to get in touch is to post a discussion in the Q&A of the course you are taking. In most cases we will respond within 24 hours.

We're passionate about helping you enjoy the courses!

See you in class,

Sincerely,

The Real People at ForexBoat

Ready to start learning?
Take This Course