Skip to content
All library documents

Using Indicator Trends as Expert Advisor Entry Conditions

Article MQL5 articles

Summary

This MQL5 cookbook installment adapts an existing Expert Advisor to use a selectable indicator as part of its position-opening conditions. The example offers a Moving Average, Commodity Channel Index, or custom price-channel indicator. It explains how to create the chosen indicator handle, retrieve values, and evaluate whether the indicator has risen or fallen across a configured sequence of bars. It also reorganizes the growing program into include files and adds checks for terminal, account, and program-level trading permission.

The article then describes parameter optimization in the Strategy Tester and reports that the optimization took about 40 minutes on a dual-core processor. It refers to an optimization chart and recovery-factor results, but the supplied text does not include enough result detail to judge profitability, robustness, or out-of-sample performance. The material is primarily a programming walkthrough: indicator direction supplies the entry condition, while the example’s settings and reported optimization are not evidence that the method generalizes across instruments or market regimes.

Key ideas

  • An Expert Advisor can select among standard and custom indicators to define entry conditions.
  • The example checks indicator direction across a configurable number of bars.
  • Indicator handles provide access to values that the program retrieves for its signal checks.
  • Trading permission checks can prevent an EA from attempting orders when execution is disabled.
  • Strategy Tester optimization is shown, but the excerpt does not establish out-of-sample robustness.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.