MQL5 Tutorial

MQL5 Tutorial Classics – Simple Moving Average Robot with MQL5


Listen Later

Introduction to Moving Averages (00:00 – 00:14) Explanation of moving averages and their use in determining if the current price is above or below the average value of a particular number of candles. Adjusting Moving Average Properties (00:14 – 00:32) Demonstrating how to change the properties of a moving average, such as adjusting the period to one candle. Exploring Different Moving Average Settings (00:32 – 00:54) Experimenting with different settings for moving averages, like setting the period to 100 and observing the changes on the chart. Using Moving Averages to Determine Market Direction (00:54 – 01:12) Discussing how traders use moving averages to identify market trends, such as when the current price crosses the moving average from above or below. Creating an Expert Advisor for Moving Averages (01:12 – 01:39) Introduction to creating an Expert Advisor in MetaTrader for moving averages, including how to view the value of the moving average at any point. Setting Up the Expert Advisor in MetaEditor (01:39 – 02:02) Instructions on opening MetaEditor in MetaTrader, creating a new Expert Advisor file named ‘Simple Moving Average’, and initial setup. Defining the Moving Average Array (02:02 – 02:34) Creating and setting up an array to hold price values for the moving average. Configuring the Moving Average Parameters (02:34 – 02:57) Detailed explanation of how to define the moving average parameters, including the period, shift, and type. Sorting the Price Array and Filling Data (02:57 – 03:36) Using ‘ArraySetAsSeries’ to sort the price array and ‘CopyBuffer’ to fill it with price data for the moving average. Calculating and Displaying the Moving Average Value (03:36 – 04:11) Calculating the current moving average value and using the ‘Comment’ function to display it on the chart. Adding a Moving Average Indicator to the Chart (04:11 – 04:53) Instructions on adding a moving average indicator to the chart for visual representation and saving the template for the strategy tester. Testing the Expert Advisor in Strategy Tester (04:53 – 05:50) Demonstrating how to use the strategy tester in MetaTrader to test the newly created Expert Advisor and verifying its accuracy. Verifying the Expert Advisor’s Accuracy (05:50 – 06:06) Final verification of the Expert Advisor’s accuracy by comparing its calculated value with the actual moving average value on the chart.   If you have been trading for a while, chances are high that you have used or maybe you have seen a moving average. This is a moving average and it is a line and you can use it to find out if the current price is above or below the average value of a particular number of candles. This is a moving average for the last twenty candles and if you right click on it, you can change the properties here. So let’s change the period to one and now you see that the moving average for one candle is connecting all the closed prices. This is a bearish candle so it closes here. This is a bullish candle so here is the closing price. Let’s look again at the properties and select one hundred and now you don’t even see the moving average because it’s far above the candles. As traders we use moving averages to find out if it’s going down and that would be the case when the current prices crosses the moving average from the above. Or if it’s going up and that would be the case when the current price crosses the moving average from below. Now how can we create an Expert Advisor for this? Now if you point your mouse on any point of the moving average, you will see a value and you will see that the value would change with very candle. Here it is 0.988749 and the closing price is 0.98848. So let’s create an Expert Advisor for that, to do that please hit this little button here or press the F4 key to bring up the Meta Editor. Now you need to click on new Expert Advisor from template, continue. We will give it the name simple moving average, continue, continue,
...more
View all episodesView all episodes
Download on the App Store

MQL5 TutorialBy Raimund Bauer