Gå offline med appen Player FM !
MQL5 TUTORIAL – HOW TO CREATE A SHIFTED MOVING AVERAGE
Manage episode 383093920 series 1376757
- Introduction to Shifted Moving Average Indicator (00:00 – 00:11)
- Introduction to the concept of a shifted moving average, which projects one moving average into the future.
- Setting Up the MQL5 Code (00:11 – 00:18)
- Overview of the MQL5 code setup, including the creation of a string variable named ‘signal’ for storing trading signals.
- Declaring Moving Average Arrays (00:18 – 00:27)
- Declaring two arrays, ‘my moving average array’ and ‘my shifted average array,’ to store values of moving averages.
- Defining Two Moving Averages (00:27 – 00:46)
- Using the ‘IMA’ function to define two moving averages: a 50-period simple moving average and another 50-period SMA with a 20-period shift.
- Sorting Arrays and Copying Values (00:46 – 01:08)
- Sorting the arrays in descending order and using ‘CopyBuffer’ to copy the last three values of both moving averages into their respective arrays.
- Calculating Moving Average Values (01:08 – 01:15)
- Calculating and storing the values of the current candle for both moving averages.
- Generating Trading Signals (01:15 – 01:32)
- Generating buy or sell signals based on the comparison of the moving average values.
- Displaying Trading Signal on Chart (01:32 – 01:43)
- Using the ‘Comment’ function to display the current trading signal on the chart.
- Conclusion and Further Learning Resources (01:43 – 02:18)
- Concluding remarks on the functionality of the code and suggestions for further learning through other videos or a premium course.
In this video, we are going to take a look at this indicator here. It’s a shifted moving average, which means that we use one moving average and project the results into the future. Let’s see how we can do something like this with MQL5. In this MQL5 code, a string variable named signal is created to store the trading signal.
This signal will be either buy or sell. Two arrays, my moving average array and my shifted average array are declared. These arrays will store values of moving averages. Two moving averages are defined using the IMA function. Moving average definition calculates a 50-period simple moving average using the closing prices of the current symbol and period. Shifted average definition calculates another 50-period SMA, but with a 20-period shift applied. The array set as series function is used to sort the my moving average array and my shifted average array in descending order. The copy buffer function is used to copy the last three values of both moving averages into their respective arrays. The values of the current candle for both moving averages are calculated and stored in my moving average value and my shifted average value.
Trading signals are generated based on the comparison of these moving average values. If my moving average value is greater than my shifted average value, it sets signal to buy. If my moving average value is less than my shifted average value, it sets signal to sell. The current trading signal, buy or sell, is displayed on the chart using the comment function. This code calculates two moving averages, compares their values, and generates a buy or sell signal based on the comparison. It then displays the current trading signal on the trading chart for reference.
Okay, by now you should have a working version of this indicator on your chart. I hope everything went well. If it was too fast for you or if you have no idea what all the code does, you maybe want to watch one of the other videos or maybe even the premium course on our website might be interesting for you. For now, I say thank you for watching and I will see you in the next video.
The post MQL5 TUTORIAL – HOW TO CREATE A SHIFTED MOVING AVERAGE appeared first on MQL5 Tutorial.
27 episoder
Manage episode 383093920 series 1376757
- Introduction to Shifted Moving Average Indicator (00:00 – 00:11)
- Introduction to the concept of a shifted moving average, which projects one moving average into the future.
- Setting Up the MQL5 Code (00:11 – 00:18)
- Overview of the MQL5 code setup, including the creation of a string variable named ‘signal’ for storing trading signals.
- Declaring Moving Average Arrays (00:18 – 00:27)
- Declaring two arrays, ‘my moving average array’ and ‘my shifted average array,’ to store values of moving averages.
- Defining Two Moving Averages (00:27 – 00:46)
- Using the ‘IMA’ function to define two moving averages: a 50-period simple moving average and another 50-period SMA with a 20-period shift.
- Sorting Arrays and Copying Values (00:46 – 01:08)
- Sorting the arrays in descending order and using ‘CopyBuffer’ to copy the last three values of both moving averages into their respective arrays.
- Calculating Moving Average Values (01:08 – 01:15)
- Calculating and storing the values of the current candle for both moving averages.
- Generating Trading Signals (01:15 – 01:32)
- Generating buy or sell signals based on the comparison of the moving average values.
- Displaying Trading Signal on Chart (01:32 – 01:43)
- Using the ‘Comment’ function to display the current trading signal on the chart.
- Conclusion and Further Learning Resources (01:43 – 02:18)
- Concluding remarks on the functionality of the code and suggestions for further learning through other videos or a premium course.
In this video, we are going to take a look at this indicator here. It’s a shifted moving average, which means that we use one moving average and project the results into the future. Let’s see how we can do something like this with MQL5. In this MQL5 code, a string variable named signal is created to store the trading signal.
This signal will be either buy or sell. Two arrays, my moving average array and my shifted average array are declared. These arrays will store values of moving averages. Two moving averages are defined using the IMA function. Moving average definition calculates a 50-period simple moving average using the closing prices of the current symbol and period. Shifted average definition calculates another 50-period SMA, but with a 20-period shift applied. The array set as series function is used to sort the my moving average array and my shifted average array in descending order. The copy buffer function is used to copy the last three values of both moving averages into their respective arrays. The values of the current candle for both moving averages are calculated and stored in my moving average value and my shifted average value.
Trading signals are generated based on the comparison of these moving average values. If my moving average value is greater than my shifted average value, it sets signal to buy. If my moving average value is less than my shifted average value, it sets signal to sell. The current trading signal, buy or sell, is displayed on the chart using the comment function. This code calculates two moving averages, compares their values, and generates a buy or sell signal based on the comparison. It then displays the current trading signal on the trading chart for reference.
Okay, by now you should have a working version of this indicator on your chart. I hope everything went well. If it was too fast for you or if you have no idea what all the code does, you maybe want to watch one of the other videos or maybe even the premium course on our website might be interesting for you. For now, I say thank you for watching and I will see you in the next video.
The post MQL5 TUTORIAL – HOW TO CREATE A SHIFTED MOVING AVERAGE appeared first on MQL5 Tutorial.
27 episoder
Alle episoder
×Velkommen til Player FM!
Player FM is scanning the web for high-quality podcasts for you to enjoy right now. It's the best podcast app and works on Android, iPhone, and the web. Signup to sync subscriptions across devices.