please solve my problem with my EA

 
//+------------------------------------------------------------------+
//|                        MarketAdaptation.mqh                       |
//|   Advanced functions for adapting strategies to market conditions |
//+------------------------------------------------------------------+
#ifndef __MARKET_ADAPTATION_MQH__
#define __MARKET_ADAPTATION_MQH__

// Function to get Moving Average value
double GetMA(int period, int ma_shift = 0, ENUM_MA_METHOD ma_method = MODE_SMA, int price_type = PRICE_CLOSE, int shift = 0)
{
    return iMA(_Symbol, PERIOD_M15, period, ma_shift, ma_method, price_type, shift);
}

// Function to get RSI value
double GetRSI(int period, int price_type = PRICE_CLOSE, int shift = 0)
{
    return iRSI(_Symbol, PERIOD_M15, period, price_type);
}

// Function to get ATR value
double GetATR(int period, int shift = 0)
{
    return iATR(_Symbol, PERIOD_M15, period);
}

// Function to check if the market is trending
bool IsTrending()
{
    double maShort = GetMA(14);
    double maLong = GetMA(50);
    return maShort > maLong;
}

// Function to check if the market is overbought or oversold
bool IsOverboughtOrOversold()
{
    double rsi = GetRSI(14);
    return rsi > 70 || rsi < 30;
}

// Function to determine if the market is experiencing high volatility
bool IsHighVolatility()
{
    double atr = GetATR(14);
    return atr > iATR(_Symbol, PERIOD_M15, 14); // Compare with the current ATR value
}

#endif // __MARKET_ADAPTATION_MQH__

this is my code



but there is an error: 'iMA' - wrong parameters count MarketAdaptation.mqh 11 12
   built-in: int iMA(const string,ENUM_TIMEFRAMES,int,int,ENUM_MA_METHOD,int) MarketAdaptation.mqh 11 12


can someone please rewrite the code to solve this issue  

thanks <3


Moving Average - Trend Indicators - Technical Indicators - Price Charts, Technical and Fundamental Analysis - MetaTrader 5 Help
  • www.metatrader5.com
The Moving Average Technical Indicator shows the mean instrument price value for a certain period of time. When one calculates the moving average...
 
Rafay Asif:
'iMA' - wrong parameters count MarketAdaptation.mqh 11 12
   built-in: int iMA(const string,ENUM_TIMEFRAMES,int,int,ENUM_MA_METHOD,int) MarketAdaptation.mqh 11 12

This indicates that you are trying to compile MQL4 code with the MQL5 compiler

 
Vladislav Boyko #:

This indicates that you are trying to compile MQL4 code with the MQL5 compiler


please tell me how do i fix this because i cant seem to solve this one minor error

 
Rafay Asif #:

please tell me how do i fix this because i cant seem to solve this one minor error

Look at the documentation 
In mql5 you get an indicator handle then use copybuffer to get indicator data
 
Rafay Asif #:

please tell me how do i fix this because i cant seem to solve this one minor error

  1. Stop trying to generate code using AI
  2. Start learning programming
 
Vladislav Boyko #:

  1. Stop trying to generate code using AI
  2. Start learning programming

This. And look in the codebase to see a working iRSI.

Beginners keep making this same mistake over and over again - writing a lot of code, and "hoping" that it works when that compile button is pressed. Get one thing working at a time. The baby does not run in the beginning, it starts by learning to crawl

 
  1. Stop using ChatGPT/Copilot.
              Help needed to debug and fix an AI EA - Trading Systems - MQL5 programming forum #2 (2023)

    ChatGPT (the worst), “Bots Builder”, “EA builder”, “EA Builder Pro”, EATree, “Etasoft forex generator”, “Forex Strategy Builder”, ForexEAdvisor (aka. ForexEAdvisor STRATEGY BUILDER, and Online Forex Expert Advisor Generator), ForexRobotAcademy.com, forexsb, “FX EA Builder”, fxDreema, Forex Generator, FxPro, “LP-MOBI”, Molanis, “Octa-FX Meta Editor”, Strategy Builder FX, “Strategy Quant”, “Visual Trader Studio”, “MQL5 Wizard”, etc., are all the same. You will get something quick, but then you will spend a much longer time trying to get it right, than if you learned the language up front, and then just wrote it.

    Since you haven't learned MQL4/5, therefor there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into yours.

    We are willing to HELP you when you post your attempt (using Code button) and state the nature of your problem, but we are not going to debug your hundreds of lines of code. You are essentially going to be on your own.

    ChatGPT
    1. Even it says do not use it for coding. * 
    2. Mixing MT4 and MT5 code together.
    3. Creating multiple OnCalculate/OnTick functions.
    4. OnCalculate returning a double.
    5. Filling buffers with zero in OnInit (they have no size yet). Setting buffer elements to zero but not setting Empty Value to correspond.
    6. Calling undefined functions.
    7. Calling MT4 functions in MT5 code.
    8. Sometimes, not using strict (MT4 code).
    9. Code that will not compile.
    10. Creating code outside of functions. * 
    11. Creating incomplete code. * 
    12. Initialization of Global variables with non-constants. * 
    13. Assigning a MT5 handle to a double or missing the buffer and bar indexes in a MT4 call. * 
    14. Useing MT4 Trade Functions without first selecting an order. * 
    15. Uses NULL in OrderSend (MT4). * 
    bot builder Creating two OnInit() functions. * 
    EA builder
    1. Counting up while closing multiple orders.
    2. Not useing time in new bar detection.
    3. Not adjusting for 4/5 digit brokers, TP/SL and slippage. * 
    4. Not checking return codes.
    EATree Uses objects on chart to save values — not persistent storage (files or GV+Flush.) No recovery (crash/power failure.)
    ForexEAdvisor
    1. Non-updateing global variables.
    2. Compilation errors.
    3. Not checking return codes.
    4. Not reporting errors.
    FX EA Builder
    1. Not checking return codes.
    2. Loosing open tickets on terminal restart. No recovery (crash/power failure.)
    3. Not adjusting stops for the spread. * 
    4. Using OrdersTotal directly.
    5. Using the old event handlers.

  2. #ifndef __MARKET_ADAPTATION_MQH__
    #define __MARKET_ADAPTATION_MQH__
    

    This is unnecessary in MTx

  3.     return iMA(_Symbol, PERIOD_M15, period, ma_shift, ma_method, price_type, shift);
    

    That is MT4 call.

    double GetRSI(int period, int price_type = PRICE_CLOSE, int shift = 0)
    {
        return iRSI(_Symbol, PERIOD_M15, period, price_type);

    That is MT5 call, that returns an int.

  4.     double atr = GetATR(14);
        return atr > iATR(_Symbol, PERIOD_M15, 14); // Compare with the current ATR value
    

    When will ATR(14) ever be greater than ATR(14)?

  5. Why did you post your question in the MT5 General section (a catch all category) instead of the MT5 EA section (non-indicator codeing)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
    Next time, post in the correct place. I have moved this thread.