How to create an EA for 3 moving averages with MQL5

video
play-sharp-fill
  • Introduction and Objective:
    • The tutorial is centered around the TRIX (Triple Exponential Moving Average) indicator, an oscillator that helps identify if a trend is likely to continue. The TRIX oscillator, when above zero, can indicate a long trend, and when below zero, it can suggest a short trend. The crossing of the TRIX lines can also be a good indication of a potential trend reversal.
  • Initial Setup in MetaEditor:
    • Users are guided to open the MetaEditor by clicking a specific icon or pressing the F4 key.
    • A new file is initiated within the MetaEditor, named “simple TRIX”.
  • Array Creation and Initialization:
    • Two arrays, “mypricearray0” and “mypricearray1”, are established to store price data for the last three candles.
    • The copyrates function is used to populate these arrays with price data.
  • TRIX Definition and Calculation:
    • The TRIX is defined using the built-in MQL5 function. It calculates based on the last thirteen candles, considering fast and slow exponential moving averages.
    • The TRIX values are stored in the arrays created earlier.
  • Signal Generation and Logic:
    • The expert advisor evaluates the TRIX values. Depending on the TRIX’s position relative to the zero line, it will display “trending upwards” or “trending downwards” on the MetaTrader chart.
  • Testing and Visualization:
    • After coding, users are advised to compile the code.
    • The functionality is then tested in MetaTrader using the strategy tester, with visualization providing a real-time view of the expert advisor in action.
  • Conclusion and Further Learning:
    • The tutorial showcases the expert advisor’s capability to effectively trade based on the TRIX indicator in MQL5. The TRIX is a versatile tool that can be used to spot potential bullish or bearish trends in the market.

By following this tutorial, users can effectively create an expert advisor that trades based on the TRIX indicator, allowing for informed trading decisions based on the indicator’s signals.


Video Timestamps

  • 0:00 – Introduction to the Trix indicator as an oscillator.
  • 0:30 – Explanation of the Trix oscillator values and their significance in trend prediction.
  • 1:00 – Historical background of the Trix oscillator and its development in the 1980s.
  • 1:30 – Visual representation of the Trix oscillator’s trend change indication on the chart.
  • 2:00 – Steps to create an Expert Advisor in MQL5 using the Trix indicator.
  • 2:30 – Setting up the Expert Advisor in MetaEditor and initializing the code.
  • 3:00 – Creating a price information array and defining the Trix properties.
  • 3:30 – Sorting the price array and filling it with data.
  • 4:00 – Calculating the Trix value for the current candle and outputting it on the chart.
  • 4:30 – Compiling the code in MetaEditor and ensuring no errors or warnings.
  • 5:00 – Testing the Expert Advisor in MetaTrader and observing the Trix value on the chart.

elated Questions and Answers:

  1. What is the primary focus of the tutorial?
    • The tutorial is centered around the TRIX (Triple Exponential Moving Average) indicator, an oscillator that helps identify if a trend is likely to continue or reverse.
  2. How can users access the MetaEditor for coding?
    • Users can open the MetaEditor either by clicking a specific icon or pressing the F4 key.
  3. What is the purpose of the “simple TRIX” file in MetaEditor?
    • The “simple TRIX” file is initiated within the MetaEditor to code and develop the expert advisor that utilizes the TRIX indicator for trading.
  4. How are the arrays named “mypricearray0” and “mypricearray1” utilized in the tutorial?
    • The arrays “mypricearray0” and “mypricearray1” are designed to store price data for the last three candles. They are populated using the copyrates function.
  5. How is the TRIX oscillator defined and calculated?
    • The TRIX is defined using the built-in MQL5 function. It calculates based on the last thirteen candles, considering both fast and slow exponential moving averages.
  6. How does the tutorial interpret the TRIX values for trading signals?
    • The expert advisor evaluates the TRIX values. Depending on the TRIX’s position relative to the zero line, it will display “trending upwards” or “trending downwards” on the MetaTrader chart.
  7. What steps should be taken after coding the TRIX-based expert advisor?
    • After the coding process, users should compile the code. The functionality of the created expert advisor is then tested in MetaTrader using the strategy tester, offering a real-time visualization of the expert advisor in action.
  8. What is the significance of using the TRIX indicator in MQL5?
    • The TRIX indicator helps in identifying potential bullish or bearish trends in the market, making it a valuable tool for traders to make informed decisions.
  9. What can users achieve by following this tutorial?
    • By following this tutorial, users can effectively create an expert advisor that trades based on the TRIX indicator, allowing for informed trading decisions based on the indicator’s signals.
  10. Are there any suggestions for further learning?