How to create an ICCI Expert Advisor with MQL5

video
play-sharp-fill

 

  • Introduction and Objective:
    • The tutorial is centered on creating an expert advisor that trades based on signals from the Commodity Channel Index (ICCI). This ICCI produces buy and sell signals on the chart, guiding trading decisions.
  • Initial Setup in MetaEditor:
    • Users are directed to access the MetaEditor by clicking on an icon or pressing the F4 key.
    • A new file is initiated within the MetaEditor, named “simpleiccistandaloneea”.
  • Incorporating Essential Files:
    • The trade.mqh file is integrated, which comes with MQL5. This file facilitates the creation of an instance of the class cTrade, named “trade”, which will be instrumental in opening trading positions.
  • Defining Parameters and Variables:
    • The tutorial sets up various parameters, including the ask and bid prices, which are normalized to either 3 or 5 digits based on the currency pair.
    • An array named “priceinfo” is created to store price data for the last three candles.
  • ICCI Definition and Calculation:
    • The ICCI is defined using the built-in icci function, calculated based on 14 candles and the close prices.
    • A separate array, “mypricearray”, is established to store the ICCI values.
  • Signal Generation:
    • The ICCI value for the current candle is determined. If the value surpasses 100 (indicating it’s above the upper dotted line on the chart), a sell signal is generated. Conversely, if the value is below -100 (below the lower dotted line), a buy signal is produced.
  • Trading Logic:
    • Based on the generated signal and ensuring no open positions exist, the expert advisor either buys or sells. For instance, a “sell” signal will trigger the sale of 10 micro lots.
  • Displaying Results:
    • A comment function is employed to display the current signal directly on the MetaTrader chart, providing users with real-time insights.
  • Testing and Visualization:
    • After coding, users are prompted to compile the code to ensure its accuracy.
    • The functionality is subsequently tested in MetaTrader using the strategy tester, with a visual mode offering a real-time view of the expert advisor in action.
  • Conclusion and Further Learning:
    • For those unfamiliar with the coding aspects or who find the tutorial’s pace challenging, there are suggestions to explore other basic video series or consider a premium course for a comprehensive understanding.
    • The tutorial concludes by showcasing the expert advisor’s capability to effectively trade based on the Commodity Channel Index in MQL5.

By following this tutorial, users can effectively create an expert advisor that trades based on the ICCI, allowing for informed trading decisions based on real-time signals.


Video Timestamps

  • 0:00 – Introduction to the Commodity Channel Index (ICCI) and its significance in trading.
  • 0:30 – Visual representation of the ICCI on the chart and the generation of buy and sell signals.
  • 1:00 – Starting the MQL5 process: Opening the MetaEditor.
  • 1:30 – Setting up the basic structure for the Expert Advisor and naming it “SimpleICCIStandaloneEA”.
  • 2:00 – Including the “Trade.mqh” file and creating an instance of the “CTrade” class.
  • 2:30 – Calculating the Ask and Bid prices for the current currency pair.
  • 3:00 – Creating an array for the candle prices and filling it with price data.
  • 3:30 – Defining the Commodity Channel Index (ICCI) and its properties.
  • 4:00 – Sorting the price array and filling it with ICCI values.
  • 4:30 – Calculating the buy and sell signals based on the ICCI values.
  • 5:00 – Implementing the trading logic: Opening buy or sell positions based on the generated signals.
  • 5:30 – Compiling the Expert Advisor and testing it in MetaTrader.
  • 6:00 – Observing the results of the Expert Advisor in real-time on the MetaTrader chart.
  • 6:30 – Conclusion: The effectiveness of the ICCI Standalone Expert Advisor in automating trading strategies.

Related Questions and Answers:

  1. What is the primary objective of the tutorial?
    • The tutorial focuses on creating an expert advisor in MQL5 that trades based on signals from the Commodity Channel Index (ICCI).
  2. How can users access the MetaEditor for coding?
    • Users can access the MetaEditor by clicking on an icon or pressing the F4 key.
  3. What is the significance of the “simpleiccistandaloneea” file in the MetaEditor?
    • A new file named “simpleiccistandaloneea” is created within the MetaEditor to develop the expert advisor that trades based on the ICCI signals.
  4. How are essential files incorporated in the tutorial?
    • The “trademqh” file, which comes with MQL5, is integrated. This file facilitates the creation of an instance of the class “CTrade” named “trade,” which is instrumental in opening trading positions.
  5. How is the ICCI defined and calculated in the tutorial?
    • The ICCI is defined using the built-in ICCI function, calculated based on 14 candles and their close prices. An array named “mypricearray” is established to store the ICCI values.
  6. How does the expert advisor generate trading signals based on the ICCI?
    • The ICCI value for the current candle is determined. If the value surpasses 100 (indicating it’s above the upper dotted line on the chart), a sell signal is generated. Conversely, if the value is below -100 (below the lower dotted line), a buy signal is produced.
  7. What trading logic does the expert advisor follow based on the generated signals?
    • Based on the generated signal and ensuring no open positions exist, the expert advisor either buys or sells. For instance, a sell signal will trigger the sale of 10 micro lots.
  8. How are the results of the expert advisor displayed to the user?
    • A comment function is employed to display the current signal directly on the MetaTrader chart, providing users with real-time insights.
  9. What steps should be taken after coding the expert advisor?
    • After coding, users are prompted to compile the code to ensure its accuracy. The functionality is then tested in MetaTrader using the strategy tester, with a visual mode offering a real-time view of the expert advisor in action.
  10. How does the tutorial cater to learners who might find the content challenging?
  • For those unfamiliar with the coding aspects or who find the tutorial’s pace challenging, there are suggestions to explore other basic video series or consider a premium course for a comprehensive understanding.