'iMA' - wrong parameters count dont know what am missing

 

see my code 

 //+------------------------------------------------------------------+
//|                                                      TrendBias.mq5|
//|                        Copyright 2023                            |
//|                        https://www.mql5.com                      |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property strict

// Indicator input parameters
input int MA1_Period = 20;        // Period for 20 MA
input int MA2_Period = 50;        // Period for 50 MA
input int MA3_Period = 100;       // Period for 100 MA
input ENUM_MA_METHOD MA_Method = MODE_SMA;
input ENUM_APPLIED_PRICE Price_Type = PRICE_CLOSE;

// Timeframes for analysis
ENUM_TIMEFRAMES timeframes[] = { PERIOD_M5, PERIOD_M15, PERIOD_M30, PERIOD_H1, PERIOD_H4, PERIOD_D1, PERIOD_W1 };

// Timeframe names for display
string timeframe_names[] = { "M5", "M15", "M30", "H1", "H4", "Daily", "Weekly" };

// Visual elements - objects for displaying trend bias
color up_color = clrGreen;
color down_color = clrRed;
color neutral_color = clrGray;

// Helper function to calculate Moving Averages
double GetMA(int period, ENUM_TIMEFRAMES timeframe, ENUM_MA_METHOD method, ENUM_APPLIED_PRICE price, int shift) {
    return iMA(NULL, timeframe, period, 0, method, price, shift);
}

// Create objects for visual display
void CreateVisuals(int index, string trend, string strength) {
    // Unique object name based on timeframe
    string obj_name = "Trend_" + timeframe_names[index];
    
    // Delete previous objects if exist
    ObjectDelete(0, obj_name);
    
    // Set color based on trend direction
    color trend_color = neutral_color;
    if (trend == "Uptrend") trend_color = up_color;
    if (trend == "Downtrend") trend_color = down_color;
    
    // Create a label to display the trend and strength
    ObjectCreate(0, obj_name, OBJ_LABEL, 0, 0, 0);
    ObjectSetInteger(0, obj_name, OBJPROP_CORNER, CORNER_LEFT_UPPER);
    ObjectSetInteger(0, obj_name, OBJPROP_XDISTANCE, 20);
    ObjectSetInteger(0, obj_name, OBJPROP_YDISTANCE, 20 + 20 * index);
    ObjectSetInteger(0, obj_name, OBJPROP_COLOR, trend_color);
    ObjectSetString(0, obj_name, OBJPROP_TEXT, timeframe_names[index] + ": " + trend + " (" + strength + ")");
    ObjectSetInteger(0, obj_name, OBJPROP_FONTSIZE, 12);
}

// Main function for analyzing trends and displaying results
void OnTick() {
    for (int i = 0; i < ArraySize(timeframes); i++) {
        // Calculate the MAs for the current timeframe
        double MA20 = GetMA(MA1_Period, timeframes[i], MA_Method, Price_Type, 0);
        double MA50 = GetMA(MA2_Period, timeframes[i], MA_Method, Price_Type, 0);
        double MA100 = GetMA(MA3_Period, timeframes[i], MA_Method, Price_Type, 0);
        
        // Trend determination
        string trend = "Neutral";
        string strength = "Weak";
        
        if (MA20 > MA50 && MA50 > MA100) {
            trend = "Uptrend";
            strength = "Strong";
        } else if (MA20 < MA50 && MA50 < MA100) {
            trend = "Downtrend";
            strength = "Strong";
        } else if (MA20 > MA50) {
            trend = "Uptrend";
            strength = "Weak";
        } else if (MA20 < MA50) {
            trend = "Downtrend";
            strength = "Weak";
        }
        
        // Create visual elements on the chart
        CreateVisuals(i, trend, strength);
    }
}

// Clean up objects when the indicator is removed
void OnDeinit(const int reason) {
    for (int i = 0; i < ArraySize(timeframes); i++) {
        ObjectDelete(0, "Trend_" + timeframe_names[i]);
    }
}
MQL5 topluluğu ve hizmetleriyle yeni MetaTrader 5 fırsatlarını keşfedin
MQL5 topluluğu ve hizmetleriyle yeni MetaTrader 5 fırsatlarını keşfedin
  • 2024.09.03
  • www.mql5.com
MQL5: MetaTrader 5 işlem platformunda yerleşik ticaret stratejileri dili, kendi ticaret robotlarınızı, teknik göstergelerinizi, komut dosyalarınızı ve fonksiyon kütüphanelerinizi yazmanıza olanak sağlar
 
see error am getting 

'iMA' - wrong parameters count my inicator.mq5 29 12
built-in: int iMA(const string,ENUM_TIMEFRAMES,int,int,ENUM_MA_METHOD,int)

 

When you post code please use the CODE button (Alt-S)!

Use the CODE button

 
OGBONNAYA JOHN #:
see error am getting 

'iMA' - wrong parameters count my inicator.mq5 29 12
built-in: int iMA(const string,ENUM_TIMEFRAMES,int,int,ENUM_MA_METHOD,int)

iMA returns a handle to use with copy buffer to get the data
Check the documentation for an example

 
OGBONNAYA JOHN #:
see error am getting 

'iMA' - wrong parameters count my inicator.mq5 29 12
built-in: int iMA(const string,ENUM_TIMEFRAMES,int,int,ENUM_MA_METHOD,int)

Place the cursor on iMA(.. and press F1: the reference opens and now compare your call with the call as it is supposed to be. There is even an example to copy & paste!