Discussing the article: "SP500 Trading Strategy in MQL5 For Beginners"

 

Check out the new article: SP500 Trading Strategy in MQL5 For Beginners.

Discover how to leverage MQL5 to forecast the S&P 500 with precision, blending in classical technical analysis for added stability and combining algorithms with time-tested principles for robust market insights.

A list of the companies included in the index is easily accessible on the internet. We can leverage our understanding of how the index is composed to help us create a trading strategy. We shall select a handful of the largest companies in the index and use the respective price of each company as an input to an AI model that will predict the closing price of the index based on our sample of companies that hold proportionally large weights. Our desire is to develop a strategy that blends AI with trusted, time-proven techniques.

Our technical analysis system will employ trend-following principles to generate trading signals. We need to incorporate several key indicators:

  • The Commodity Channel Index (CCI) as our volume indicator. We only want to enter trades that are backed by volume.
  • The Relative Strength Index (RSI) and the Williams Percent Range (WPR) to gauge buying or selling pressure in the market.
  • A Moving Average (MA) as our final confirmation indicator.


    Author: Gamuchirai Zororo Ndawana

     

    Awesome thank you for your interesting and well documented code , Looking forward to getting it to work . There is at least one trap with  for newbies , that is to change the target symbol on line 92  to your brokers symbol for sp500 ,also  on line 84  to match the stock symbols your broker has. 

    what should line 286 'Our Model Parameters return? I get [-nan(ind)], the rest seems to work perfectly.

     
    I think the is because I don't have the data downloaded for the SP500 yet sorry , I should have checked that first 
     
    linfo2 #:

    Awesome thank you for your interesting and well documented code , Looking forward to getting it to work . There is at least one trap with  for newbies , that is to change the target symbol on line 92  to your brokers symbol for sp500 ,also  on line 84  to match the stock symbols your broker has. 

    what should line 286 'Our Model Parameters return? I get [-nan(ind)], the rest seems to work perfectly.

    You're right, it's a subtle gotcha to be cautious of. My broker has the weirdest names for certain symbols, I'm glad you managed you resolve the issue.
     

    I was hopefull this might actually work. Thanks to the auther for sharing it regardless.

    cannot load indicator 'Relative Strength Index' [4302]
    cannot load indicator 'Moving Average' [4302]
    cannot load indicator 'Williams' Percent Range' [4302]
    cannot load indicator 'Commodity Channel Index' [4302]

    I understand indicators should automatically be loaded and displayed.(fails)

    I manually placed the indicators on the chart and even created a template with all indicators included. Even when every stock's chart is open and all indicators placed on chart manually, the EA fails to read indicators on it's own.

     
    Malcolm Campbell #:

    I was hopefull this might actually work. Thanks to the auther for sharing it regardless.

    cannot load indicator 'Relative Strength Index' [4302]
    cannot load indicator 'Moving Average' [4302]
    cannot load indicator 'Williams' Percent Range' [4302]
    cannot load indicator 'Commodity Channel Index' [4302]

    I understand indicators should automatically be loaded and displayed.(fails)

    I manually placed the indicators on the chart and even created a template with all indicators included. Even when every stock's chart is open and all indicators placed on chart manually, the EA fails to read indicators on it's own.

    Hey Malcom, may you share a screenshot of your experience