How to create a Simple Envelopes EA with MQL5

video
play-sharp-fill
  • Introduction and Objective:
    • The tutorial guides users in creating an expert advisor that employs the Envelopes indicator. The Envelopes indicator draws two lines on the chart, and when a candle closes above the upper line, it generates an entry signal. The indicator is akin to the Bollinger Band indicator.
  • Initial Setup in MetaEditor:
    • Users are instructed to open the MetaEditor by clicking a specific icon or pressing the F4 key.
    • A new file is initiated within the MetaEditor, named “simple envelopes”.
  • Array Creation and Initialization:
    • An array, “price data”, is established to store price data for the last three candles.
    • The copyrates function is used to populate the array with price data.
  • Envelopes Definition and Calculation:
    • The Envelopes indicator is defined using the built-in function. It calculates based on 14 candles using the close prices and a deviation of 0.100.
    • Two arrays, one for the upper band and another for the lower band, are set up to store the Envelopes values.
  • Signal Generation and Logic:
    • The expert advisor evaluates the Envelopes values. If the last candle closes above the upper band, it outputs “upper signal”. If it closes below the lower band, it outputs “lower signal”. If the price is between the two bands, it displays the values for both bands.
  • 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 Envelopes indicator in MQL5. The Envelopes can be a standalone tool, but it’s often combined with other indicators to enhance trading strategies.

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


Video Timestamps

  • 0:00 – Introduction to the Envelopes indicator and its significance in trading.
  • 0:30 – Explanation of the Envelopes indicator drawing two lines on the chart.
  • 1:00 – Significance of a candle closing above the upper line as an entry signal.
  • 1:30 – Comparison of the Envelopes indicator to the Bollinger Bands indicator.
  • 2:00 – Interpretation of the upper and lower envelope bands and their values.
  • 2:30 – Differing trader opinions on the implications of price breaking the upper line.
  • 3:00 – Steps to create an Expert Advisor for the Envelopes indicator in MetaEditor.
  • 3:30 – Setting up the Expert Advisor and defining the properties of the Envelopes.
  • 4:00 – Sorting and filling the price array with data.
  • 4:30 – Retrieving the Envelopes values for the current candle and displaying signals on the chart.
  • 5:00 – Compiling the Expert Advisor and testing it in MetaTrader.

Related Questions and Answers:

  1. What is the primary focus of the tutorial?
    • The tutorial concentrates on creating an expert advisor in MQL5 that trades based on signals from the Envelopes indicator, which draws two lines on the chart to generate entry signals.
  2. How can users access the MetaEditor for coding?
    • Users can open the MetaEditor by clicking on a specific icon or pressing the F4 key.
  3. What is the purpose of the “simple envelopes” file in MetaEditor?
    • The “simple envelopes” file is initiated within the MetaEditor to code and develop the expert advisor that trades based on the Envelopes indicator signals.
  4. How is the array named “price data” utilized in the tutorial?
    • The “price data” array is designed to store price data for the last three candles. It is populated using the copyrates function.
  5. How is the Envelopes indicator defined and calculated in the tutorial?
    • The Envelopes indicator is defined using a built-in function and is calculated based on 14 candles using their close prices and a deviation of 0.100. Two arrays are set up to store the values for the upper and lower bands of the Envelopes.
  6. How does the expert advisor generate trading signals based on the Envelopes?
    • The expert advisor evaluates the Envelopes values. If the last candle closes above the upper band, it outputs “upper signal”. If it closes below the lower band, it outputs “lower signal”. If the price is between the two bands, it displays the values for both bands.
  7. How are the results of the expert advisor displayed to the user?
    • The results are displayed directly on the MetaTrader chart, indicating whether the last candle closed above the upper band, below the lower band, or between the two bands.
  8. What steps should be taken after coding the expert advisor?
    • After coding, users should compile the code. The functionality is then tested in MetaTrader using the strategy tester, with a visual mode providing a real-time view of the expert advisor in action.
  9. How does the tutorial view the Envelopes indicator in the context of broader trading strategies?
    • The Envelopes indicator can serve as a standalone tool, but the tutorial mentions that it’s often paired with other indicators to enhance trading strategies.
  10. What can users achieve by following this tutorial?
  • By following this tutorial, users can effectively create an expert advisor that trades based on the Envelopes indicator, allowing for informed trading decisions based on the indicator’s signals.