LEARN MQL5 TUTORIAL BASICS - 19 HOW TO TRADE A SIMPLE MOVING AVERAGE

Published: 01 January 1970
on channel: MQL5 Tutorial
9,162
147

https://mql5tutorial.com/?s=sma


Introduction to Trading Small Accounts and Managing Risk (00:00 – 00:10)

Introduction to the concept of trading with small accounts and effective risk management strategies.
Accessing Accounts in MetaTrader Navigator (00:10 – 00:24)

Demonstrating how to access the 'Accounts' section in the MetaTrader Navigator and explaining the account types.
Opening a New Trading Account with a Broker (00:24 – 00:39)

Instructions on opening a new trading account, choosing between Metatrader 4 or 5, and selecting the 'Pro-Cent' account type.
Setting Leverage and Passwords for the Account (00:39 – 00:56)

Choosing leverage options and setting up passwords for personal and investor access.
Understanding the Cent Account System (00:56 – 01:22)

Explaining how the cent account works, with a focus on trading in US Dollar cents.
Making Deposits and Internal Transfers (01:22 – 01:36)

Discussing deposit options and how to perform internal transfers between accounts.
Real Money Trading with a Cent Account (01:36 – 02:13)

Highlighting the advantage of trading with real money in a cent account, using a smaller initial investment.
Transitioning from Demo to Real Cent Account (02:13 – 02:30)

Advising on moving from a demo account to a real cent account and the scalability of trading with cents.
Managing Trades and Margin in a Cent Account (02:30 – 02:53)

Demonstrating trade management and margin considerations in a cent account.
Finding Brokers Offering Cent Accounts (02:53 – 03:05)

Tips on finding brokers that offer cent accounts suitable for your country.
Real Profits and Fees with Cent Accounts (03:05 – 03:19)
Emphasizing that trading with cent accounts involves real profits and fees.
Using Statistics Services and Account Performance (03:19 – 03:31)
Encouraging the use of statistics services like FX Blue to track account performance.
Conclusion: Setting Up a Cent Account for Small Budget Trading (03:31 – 03:47)
Concluding the tutorial with a summary of how to set up a cent account for trading with a small budget.


In this video we are going to create a simple Expert Advisor that is going to trade this Moving Average. It’s a Moving Average for 20 candles, so let's find out how to do that with MQL5.
First you need to click on the little button here or press F4 on your keyboard, now you should see the Metaeditor window and here you want to click on: “File/ New/ Expert Advisor (template)” from template, “Continue”, I will call this file: “SimpleMovingAverageEA”, click on “Continue”, “Continue” and “Finish”.
Now you can remove everything above the “OnTick” function and the two command lines here.
We start by including the file: “Trade.mqh” that comes with MQL5 and it provides easy trade functions, so let's create an instance of “CTrade” that will be called: “trade” and we are going to use it to open our positions later on.
As we want to trade in both directions we need to get the Ask price and the Bid price, that is done by using the function “SymbolInfoDouble” for the current symbol, for the Ask price we use “SYMBOL_ASK” – all in capital letters – and for the Bid price we use “SYMBOL_BID” also in capital letters, I like to use “NormalizeDouble” and “_Digits” to automatically calculate if we have a currency pair with 3 digits or 5 digits.
Now let's continue, we create an array for the price data that will be called: “PriceInfo“ and we use the function: “MqlRates” to create it, because “MqlRates” stores the information about prices, volumes and spread.
Now we want to fill the array (PriceInfo) with price data that is done by using “CopyRates” for the current symbol on the chart and the currently used period on that chart, actually this and this statement are equal, we could also use “_Symbol” and “_Period”, we start with the current candle 0 (zero) and we want to copy the price data for 3 candles and store it in our price info (PriceInfo) array.
Let’s create a string for the signal that will also be called: “signal” and we don't assign any value here because we are going to calculate that later on.
Now we need another array, this time for the Moving Average it will be called: “myMovingAverageArray”, so let's define the properties for the Moving Average (movingAverageDefinition). We use the included “iMA” function of MQL5 for the current symbol on the chart and the currently selected period on that chart, I want to calculate the Moving Average for 20 candles in the past, this is a shift value that could be used to move the Moving Average to the right or to the left, I don't want to use it so I select 0 (zero), we want to calculate a Simple Moving Average so we use “MODE_SMA” – all in capital letters – and “PRICE_CLOSE” also in capital letters is used to calculate the value based on the close price.


Watch video LEARN MQL5 TUTORIAL BASICS - 19 HOW TO TRADE A SIMPLE MOVING AVERAGE online without registration, duration hours minute second in high quality. This video was added by user MQL5 Tutorial 01 January 1970, don't forget to share it with your friends and acquaintances, it has been viewed on our site 9,162 once and liked it 147 people.