5.00
(2 Ratings)

Algorithmic Trading in MQL5: OOP & PO

Wishlist Share
Share Course
Page Link
Share On Social Media

About Course

In this course you will learn how to code with object-oriented programming, how to adapt our simple expert advisor to a new framework and how to work with pending orders.

Introduction to MQL5 Object-Oriented Programming (OOP)

In the first part we will focus on how to code object-oriented programming in MQL5. We will cover the theory while maintaining a practical approach.

First, we will introduce you to object-oriented programming, covering classes and objects, and then we will explain MQL5 OOP main concepts, such as encapsulation, inheritance or polymorphism, both in theory and code and with examples.

New MQL5 OOP Framework for the Expert Advisor

In the second part we will take the expert advisor that we built in the previous course, “Algorithmic Trading In MQL5: Code Robots & Free Up Your Time” and we will rebuild that robot with classes and objects of our own.

During this part we will create a new framework for our expert advisor where we rearrange the code and encapsulate it within different header files that will form our framework. Framework v2.0 uses a custom Trade class to send the orders, v2.1 uses MetaQuotes library class.

In case that you did not complete the previous course, you will have available for download a copy of that expert advisor in this course, so you can follow along with the lectures.

MQL5 Pending Orders

We will cover everything about pending orders and we will create a version of our robot that trades with them.

Here you will learn what type of pending orders we can use in Metatrader 5, how to place them, how to modify and delete them and how to set their expiration time. In short, you will learn how to trade algorithmicly with any pending order:

  1. – How to send, modify and cancel buy limit and sell limit pending orders
  2. – How to send, modify and cancel buy stop and sell stop pending orders
  3. – How to send, modify and cancel buy stop limit and sell stop limit pending orders

I am confident that you will find great value on all the knowledge and techniques shared in this course.

If you like the program and if you are interested on improving your MQL5 skills and your trading robots, then wait no more! This course is for you!

After this course, you will have a better framework for your expert advisor and you will be able to bring your MQL5 skills to a level that will allow you to follow-up with any of our advanced courses.

The different expert advisors and files coded during the course are provided to you with the course.

– Jose Martinez

Show More

What Will You Learn?

  • How to code from an object-oriented programming approach
  • How to code classes and objects and implement them in an expert advisor
  • How to send, modify, set expiration and cancel pending orders
  • How to connect your trading to a VPS

Course Content

Introduction
In this first section we look at our starting point, which is the expert advisor that was built in the course "Algorithmic Trading in MQL5: Code Robots & Free Up Your Time", the Simple Moving Average EA. In this section we review that expert strategy, code and performance to have a common ground moving forward.

Introduction to OOP, Classes and Objects
In this section, we will explore the basic concepts of object-oriented programming (OOP) in MQL5. OOP offers advantages over traditional top-down programming, such as structured and modular code, making it easier to organize and avoid repetition. Problem-solving becomes faster as code is divided into classes. OOP allows for code reusability by creating objects of a class. Most modern software development, including MQL5 applications, follows an OOP approach. Although learning OOP may seem challenging, it is a more intuitive and efficient method for developing expert advisors. Join us to master OOP and enhance your programming skills.

CTrade Class
This section focuses on restructuring an expert advisor using object-oriented programming. The advisor will be improved by creating four include files, each hosting different classes. The first include file, named "trade," will contain a trade class for sending orders. The second include file, "position management," will hold a PM class for managing positions. The third include file, "bar data," will have a bar data class for working with bar information. Lastly, the "indicator" include file will contain classes for creating and working with indicators. The instructor demonstrates how to create these include files in a new folder.

CPM Class (Position Management)
In this section, we start creating the Position Management class. We add a comment section and declare the class with variables and methods for stop loss, take profit, trailing stop loss, and break even. We also create objects for sending orders and declare a constructor to initialize memory. We define functions for calculating stop loss and take profit, as well as trailing stop loss and break even for hedging and netting accounts. We differentiate the methods with comments. Finally, we implement the constructor.

CBar Class
In this section, we start coding the CBar class to retrieve bar data. We add a comment section and declare the class. We create a public access object of the mqlRates structure, which will store the rates of the bars. We set this array as a series array in the constructor. We then create a refresh method to retrieve bar data, which calls the copy rates function. This function copies the rates to our var object array.

CIndicator Class
In this section, we begin coding the classes for our indicators. We will have a base class and derived classes for each indicator, such as moving average and bollinger bands. The base class, named CIndicator, will have variables and methods. The main array will store values copied by the main buffer. The constructor sets the main array as a series array. We declare a virtual init method, which will be implemented differently in each derived class. The init function sets the handle for the indicator. We also have a refreshMain function to update the values in the main array. In the next lectures, we will implement these methods.

Pending Orders in MQL5
In this section, we will be improving our expert advisor by implementing different types of pending orders in MT5. We will review these order types and add methods to our citrate class to place, find, modify, specify expiration time, and delete these orders. This missing piece will make our expert advisor capable of sending any type of order, which is exciting. So, let's dive in and make these improvements to our advisor.

Additional and Final
In this final section of the course, we will cover strategy test errors in backtesting, new concepts and framework updates, and virtual private servers. The lectures on VPS, which were also covered in the previous course on "Algorithmic trading in MQL5: code robots and free up your time", will be included here for those who missed that course.

Student Ratings & Reviews

No Review Yet
No Review Yet