Русский 中文 Español Deutsch 日本語 Português
Video: How to setup MetaTrader 5 and MQL5 for simple automated trading

Video: How to setup MetaTrader 5 and MQL5 for simple automated trading

MetaTrader 5Expert Advisors | 2 June 2022, 13:04
11 821 2
Raimund Bauer
Raimund Bauer

Part 1 – Intro


Hello and welcome to this video series about MetaTrader 5. MetaTrader 5 is a software that can help you automate your trading strategies. It comes with a full blown language called MQL5. That is a programming language.

The download for MetaTrader 5 and MQL5 is totally free. And in this little video series we will get you started with automated trading. Let's see what MQL5 and MetaTrader 5 can do for you and how to get started now.


Part 2 – MetaTrader 5 Download


Before we can do anything with MetaTrader 5 or MQL5, we obviously need to download the software. That can be done on this website. It is called MetaTrader5.com. The software is available for free.

That means that you can download it here on the website and install it on your Windows computer right away. If you want to use Linux or if you use a MacBook, there are also some ways to get it started. Actually, I have a whole series about creating an automated trading server farm on a Linux PC. But let's do some small baby steps today. So please go to MetaTrader5.com, pick the language of your choice and click on this little button here to download the software.


Part 3 – More helpful content available

Actually, there is also a mobile version that you can download for your Apple device or for your Android phone, and I have those too. These are not full blown versions, because they don't include MQL5.

You can use the mobile versions to monitor your trades, but you cannot do anything that is automated. Nevertheless, the app is helpful when you want to check your trading stats and when you're not at home and have no access to your computer.

MetaQuotes also offers a lot of other different stuff, like the MetaTrader Market where you can also purchase trading robots, technical indicators and scripts. They offer so-called trading Signals for real time copy operations from one trading account to another.

There is also a Freelance section where you could find somebody to create your trading robot or your technical indicator according to your own rules. Virtual hosting is used when you want to have an online computer running 24/7, even when you turn off your computer at night.

And last but not least, they have a large community. Here you can find a lot of helpful content from traders for traders. You can comment on those and you could ask for help, but for now we are interested in the download and the setup process.

So let's continue in the next video.

 

Part 4 - What hardware do I need?


This is one of my Stick PCs. Actually, I'm accessing it right now with a remote software. So the next video might be a little blurry. Let's log in here. Actually, I like to use these Stick PCs. This is not the exact same brand, but I think you get the idea. This is one of these little stick PCs.

So let's open the system properties and you can see that I'm using a device that has 2GB of Ram. It runs on an Intel Atom processor, and it's actually powerful enough to run MetaTrader 4 or 5. I also use Netbooks for MetaTrader because they have an included screen and an included battery that will keep your device alive, even when you have a short power outage.

So basically every device you can find that was produced in the last decade would be able to run your automated trading systems and MetaTrader 5. Here we have a different device. This one is a so called EEE netbook, and it runs with a software called MX Linux.

And with Play on Linux, it is possible to run Windows applications on your Linux PC. So this EEE device is even older than ten years. And as you can see, it runs one of my productive accounts here.

Okay, that's it for the hardware requirements. In the next video, we're going to install the software.


Part 5 - How to install MetaTrader


Okay, by now you should have downloaded the MT5Setup.Exe file. So let's right click on the file and select open. In my case I have a German Windows PC.

So now I need to confirm this security warning that I want to execute the file. And yes, I want to confirm that MetaTrader 5 should be installed. Here is the installation wizard. In my case it comes in German and I need to read and confirm the terms and conditions.

So let's click on continue. Now some files need to be downloaded to complete the installation process. This could take a few minutes depending on the speed of your internet connection. But in my case it should be finished within a few seconds. Okay now the installation process has finished.

A website opens, I could now create a new account on MQL5.com. I already have one. So let's close this window, wait for a few seconds and here you can see that MetaTrader 5 is starting right away.

That was the basic setup process. I will see you in the next video where we will connect an account.


Part 6 - How to connect a Demo account


Okay, we are back and the MetaTrader account that I'm using on this instance of MetaTrader is one of my productive accounts. Depending on the broker you use, you may have different types of accounts. I would suggest to start with a so-called Demo account.

Most brokers do offer Demo accounts for free, but keep in mind that some of those Demo accounts are restricted. Either you cannot trade whatever you want or they are going to expire after a month or two. I use a broker who offers Demo accounts for MQL4 and MQL5 as I'm trading with MetaTrader 4 and MetaTrader 5.

A Demo account would be the best choice to get started. The next best thing would be a so-called Cent account. This type of account is traded with real money, but as the name says, you would trade cents instead of dollars.

So you can get real trading experience with that type of account and you can make real profits or losses. So it's trading under real conditions, but you wouldn't need a big bank account to do it. And once everything works as desired, you can scale up each type of account.

To create a new account you need to right click onto accounts, select open an account. Here you can pick the broker of your choice. In my case, I will use MetaQuotes. Now I click on Continue.

We want to open a Demo account to trade virtual money without any risk. So let's select this option and click on Continue. Fill in the required fields.

I want to change the leverage here. And you need to make sure that you use an account type that says it is hedged because with the so-called netting mode you wouldn't be able to have more than one position for each direction. I always use Hedge account types and if you already have an account, please make sure that you see the term Hedge here.

So once I'm satisfied, I need to agree to the terms and conditions. For some reason I need to add the country for the mobile phone number. Now let's click on Continue.

And here are my user credentials. It says a new account was opened, so I need to copy the registration information to the clipboard. Now let's click on Finish.

And here is my brand new MetaQuotes Demo account. I'm already connected and you can check that if you open the Market watch you should see some price changes and a running clock.

So everything is working. And I will see you in the next video.


Part 7 - How to adjust your chart settings


To allow automated trading in MetaTrader 5, we need to adjust some settings. First of all, I want to remove the two indicators here. And I can do that by right clicking and then I select "Delete Indicator" or "Delete Indicator window".

That looks a little bit better, but I don't like the grid on the chart and with the right click I select properties. Here you can choose if you want to see candlesticks, a line chart or a bar chart. I prefer line charts.

I want the chart to scroll automatically and here is a tab called "Show". That is where I can disable the "Show grid" option and when I'm satisfied I click on okay. This is a neat and clean chart.

We don't need any fancy stuff here because automated trading is not about looking on the chart. We will use MQL5 to calculate the values that are in the chart. So if you click anywhere on the line here you can see the open, the high, the low and the close price.

And MQL5 knows that for each and every candle on the chart, I don't want to adjust the settings for each and every chart in the future. So I right click on the chart, select templates and save a template here. I will call this one "Default".

Click on Save. Now you will find this one here in the templates menu and you can change the template with a mouse click. So before we had a messy view like this. But for MQL5 something like this is better.

And there is also a little trick. If you save this template and use the name "tester", it will be the default view for every back test you will do in the future. Let's open a chart window for the Australian against the Canadian dollar and it is opened with our default template for the 1 minute time frame we are going to use to trade automatically.

By the way, you can always change the view later and it's also possible to use the plus and minus keys to zoom in and out of your chart. You will see all these options here including the shortcuts and if you need to change the time frame, you can even do this with a mouse click.

Okay, now you know how to adjust your chart to trade with MQL5.


Part 8 - How to adjust options for auto trading


By now your MetaTrader should look similar to mine and in the left upper corner here you see that auto trading is not allowed now, so let's adjust some settings. Please click on Tools, Options and on the first tab you will see your trading server and your login.

If you are using MetaTrader 5 behind a firewall, maybe you need to enable the proxy server settings here. Usually it's a web address or an IP address and a port. I don't use one so I can disable the option here. This option will keep your personal settings and data.

I will leave it enabled and I will disable the newsfeed because for technical automated trading we don't need any news. Let's go to the charts tab. Usually I leave most of the options as they are, but 100,000 bars in the chart is way too much.

I will change this to 5000 because it will require less calculation power and I can trade more charts with less resources. This tab here with the trade options contains a very important setting that is the volume. You should definitely change this to "by default".

That will save you. If you accidentally enable the one click trading option and this isn't set, you might accidentally open a big trade for a whole lot and lose all your money.

The Expert Advisors tab contains a setting to allow automated trading. That must be enabled and these two options here should make your trading more secure. But to be honest, I always disable them because usually I don't change my trading account.

I trade one account on one PC and from time to time I change the trading profile here. But this usually isn't by accident and I know my expert advisors won't do anything harmful to my account when I do it. If you are starting off right now and if you are not sure if or if you not want to have these options enabled, feel free to leave them as they are.

There is another option here that will disable automated trading when the chart symbol or the period has been changed. Basically it's the same. Make your own decision, but usually it is a good idea to leave all the three options here unmarked. If you do use them, please keep in mind that they might prevent automated trading to work and it might cost you a lot of time to find the cause.

The Events tab will allow you to enable or disable sound events. You can also enable or disable sounds for single events. Usually I disable all the sounds.

On the Notifications tab you could enable push notifications. That will work for iPhone or Android devices. And you can download the mobile version for MetaTrader 5 with these two buttons.

On this tab you could set up an SMTP server to send emails. The FTP server would help you to upload your stats to a file transfer protocol server. And right now you don't have to sign up to the community.

And we are not going to use external signals. And if you are finished you can click on OK. And now you see that auto trading is enabled.

And in this video you have learned how to set up MetaTrader 5 to work with automated MQL5 Expert Advisors.


Part 9 - Your first automated backtest


In this video we are going to do the first automated test. If you click on the folder Expert Advisors you will see a few files and an examples folder. Now please click on the examples folder. And in the examples you will find an Expert Advisor that is called Moving Average. Now let's click on View, Strategy Tester or press Control and R on your keyboard. And now you should see the Strategy Test panel here.

And here you want to select the Moving Average ex5 file. Pick a currency pair here. Select the 1 minute chart. That's the M1 chart.

Now let's change the data quality to 1 minute OHLC. That's open High, Low and Close prices - and click on Start.

And this is what you can expect from the built in Strategy Tester example that is the Moving Average. I think you will agree with me that there is a lot of room for improvement here. Let's go back to settings, enable the visualization mode and start another test. And now you can watch the simple Moving Average Expert Advisor trade.

And if you invest enough time you might find out that your account balance will go down on a consistent basis. I will speed that up for you.

We are on January 3rd and we have made a loss of about $150. Now you know how to start your first MQL5 back test and trade the Moving Average.ex5 file that is by default included in the examples folder from MetaTrader 5. And I will promise you it will produce a loss.

And in the next few videos we are going to change that.


Part 10 - How to import an Expert Advisor


By now you have done your first automated trades. And the results for the built-in moving average example Expert Advisor have been very bad. You would have lost over $6,100.

Humans use so-called heuristics. A heuristic is a mental shortcut. So after the first disastrous result you might maybe do a second test. And if you see the results for the second test draining your account, probably that would be it for you. And you would say this automated trading is a total waste of time and money. That is how your mind works.

To save time you are going to do something for one or two times. Then you make a conclusion based on just one or two results. Well I have done literally thousands of these test series and now let me show you what is possible.

Let's click on file, open data folder and that should open the encrypted folder here. It is part of your user folder. And here you will find a folder called MQL5 experts. Inside of the experts folder you will find a folder called Advisors.

And I'm going to paste one of my systems. This one is called Forex Trading Framework. Now let's restart MetaTrader. That will take a few seconds and here we are.

And you should see the Forex Trading framework appearing in the Navigator window. Now we can select it here for the back test and start another test. And this time it looks different. It's going in the right direction.

This is how it should look like. And I have created dozens of systems that can do it. In the next video we are going to create a simple expert advisor with a few lines of code.

Last comments | Go to discussion (2)
Rajiv99
Rajiv99 | 2 Jun 2022 at 16:08

hello Raimund Bauer


Thanks for helping me understand Automated MT5 but where can i find the last and most important video to change the software to get positive results

simartspoako
simartspoako | 9 Jun 2022 at 01:07
OMG Raimund! 

I have been a subscriber of your youtube channel for a year now... Thanks you so much, your videos been really helpful! :D
Learn how to design a trading system by Accumulation/Distribution (AD) Learn how to design a trading system by Accumulation/Distribution (AD)
Welcome to the new article from our series about learning how to design trading systems based on the most popular technical indicators. In this article, we will learn about a new technical indicator called Accumulation/Distribution indicator and find out how to design an MQL5 trading system based on simple AD trading strategies.
DoEasy. Controls (Part 1): First steps DoEasy. Controls (Part 1): First steps
This article starts an extensive topic of creating controls in Windows Forms style using MQL5. My first object of interest is creating the panel class. It is already becoming difficult to manage things without controls. Therefore, I will create all possible controls in Windows Forms style.
Data Science and Machine Learning (Part 04): Predicting Current Stock Market Crash Data Science and Machine Learning (Part 04): Predicting Current Stock Market Crash
In this article I am going to attempt to use our logistic model to predict the stock market crash based upon the fundamentals of the US economy, the NETFLIX and APPLE are the stocks we are going to focus on, Using the previous market crashes of 2019 and 2020 let's see how our model will perform in the current dooms and glooms.
Developing a trading Expert Advisor from scratch (Part 7): Adding Volume at Price (I) Developing a trading Expert Advisor from scratch (Part 7): Adding Volume at Price (I)
This is one of the most powerful indicators currently existing. Anyone who trades trying to have a certain degree of confidence must have this indicator on their chart. Most often the indicator is used by those who prefer “tape reading” while trading. Also, this indicator can be utilized by those who use only Price Action while trading.