Our Blog

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…)

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! 🙂

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

(more…)

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

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

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.

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

(more…)

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 the backbone 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?!

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

(more…)

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!

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

(more…)

What are you waiting for?

START LEARNING FOREX TODAY!

as seen on: