Category: MQL4 for Complete Beginners

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 […]

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.

Enrol in the full course here: https://www.forexboat.com/learn-mql4

(more…)

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.

Enrol in the full course here: https://www.forexboat.com/learn-mql4

(more…)

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 […]

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.

Source code beneath the video

The video below is usually part of a paid course. Here you have the chance to see it for free. Simply enter your details and click “Play”.

 

This video is part of our Algorithmic Trading course. If you like it, you can check out by clicking the button below:

Algorithmic Trading Course

(more…)

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.

Source code after video

Enrol in the full course here: https://www.forexboat.com/learn-mql4

(more…)

OrderCloseWelcome back!

In Tutorial 15 we learned how to open market orders from Scripts. For an Algorithmic Trading System to make profits it also has to close orders. Therefore, closing orders is equally important and today I will show you how it’s done.

The OrderClose Function

When executing new orders we used the OrderSend function. Similarly, to close an existing order we need to use the OrderClose function. OrderClose is an MQL4 trade function which takes the following parameters:
bool OrderClose(
int ticket, // ticket
double lots, // volume
double price, // close price
int slippage, // slippage
color arrow_color // color
);

In today’s tutorial we will discuss each of these parameters individually in detail. Nevertheless, you can always look for additional information on the MetaQuotes’ official website: OrderClose Reference

Video Tutorial

Additionally, in this tutorial we will further continue working with order ticket numbers. Knowing how to handle tickets is a useful skill. It will come in handy when we start programming expert advisors in section 3 of this course.

The source code is located below the video. Feel free to let me know if you have any questions by using the comments section at the end of this post.

Enrol in the full course here: https://www.forexboat.com/learn-mql4

(more…)

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 will protect 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!

Enrol in the full course here: https://www.forexboat.com/learn-mql4

(more…)

Today we are going to talk about a fundamental cornerstone of any programming language – 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!

Enrol in the full course here: https://www.forexboat.com/learn-mql4

(more…)

Ordersend

Ordersend

Hello friends!

In today’s tutorial we will learn how to use the OrderSend function. OrderSend is an MQL4 trade function which is used to place Buy and Sell orders on the Forex Market. Once an order is placed you will be able to see it in Meta Trader 4 just like you can view any other position. 

OrderSend Parameters

In this tutorial we will focus on the StopLoss and TakeProfit parameters. In the previous tutorial we learned how to use extern variables to allow input of parameters by the trader. The external values were used to calculate the StopLoss and TakeProfit levels, which we will use in the OrderSend function today.

Another important parameter is cmd variable, which is used to specify the direction of your intended trade. In the video below I will show you how to use the OP_BUY keyword to execute a Buy transaction. Similarly, OP_SELL can be used to execute Sell orders.

Here is a list of other parameters that the OrderSend function allows you to input:
int OrderSend(
string symbol, // symbol
int cmd, // operation
double volume, // volume
double price, // price
int slippage, // slippage
double stoploss, // stop loss
double takeprofit, // take profit
string comment=NULL, // comment
int magic=0, // magic number
datetime expiration=0, // pending order expiration
color arrow_color=clrNONE // color
);

We will discuss most of  these parameters in today’s tutorial. However, more information can always be found on the MetaQuotes’ official website: OrderSend Reference

Video Tutorial

Alright! Let’s go ahead and send some orders with OrderSend. The video below is usually part of a paid course. Here you have the chance to see it for free. Simply enter your details and click “Play”

Remember – the code for this tutorial is located beneath the video.

This video is part of our Algorithmic Trading course. If you like it, you can check out by clicking the button below:

Algorithmic Trading Course

(more…)

What are you waiting for?

START LEARNING FOREX TODAY!

as seen on: