need help to solve these error message for fibo

 

good day am trying to complete a simple fib but keep getting error messages wrong parameter count

'ObjectName' - wrong parameters count harmonic finder asap.mq5 55 27

'ObjectDelete' - wrong parameters count harmonic finder asap.mq5 58 10

'ObjectsTotal' - wrong parameters count harmonic finder asap.mq5 52 23

no indicator plot defined for indicator 0 0

here is my code

//+------------------------------------------------------------------+
//|                                                       Fibonacci  |
//|                           Copyright 2024, oxygen  
//|                                             
//+------------------------------------------------------------------+
#property indicator_chart_window
#property strict

// Input parameters
input int fiboLevels = 5; // Number of Fibonacci levels to plot

// Variables
double fiboLevelsArray[5] = {0.0, 23.6, 38.2, 50.0, 61.8}; // Fibonacci levels in percentage
double fiboLevelsValues[5]; // Array to store Fibonacci levels values
string fiboObjectsPrefix = "FiboLevel_"; // Prefix for Fibonacci objects

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   // Initialization code here, if needed
   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   // Calculate highest high and lowest low within the available data
   double highestHigh = high[ArrayMaximum(high, 0, rates_total - 1)];
   double lowestLow = low[ArrayMinimum(low, 0, rates_total - 1)];
   
   // Calculate Fibonacci levels dynamically
   double range = highestHigh - lowestLow;
   for (int i = 0; i < fiboLevels; i++)
     {
      fiboLevelsValues[i] = highestHigh - range * fiboLevelsArray[i] / 100.0;
     }

   // Remove previous Fibonacci objects
   int totalObjects = ObjectsTotal();
   for (int i = totalObjects - 1; i >= 0; i--)
     {
      string objectName = ObjectName(i);
      if (StringFind(objectName, fiboObjectsPrefix) == 0)
        {
         ObjectDelete(objectName);
        }
     }

   // Plot Fibonacci levels
   for (int i = 0; i < fiboLevels; i++)
     {
      string fiboLevelName = fiboObjectsPrefix + DoubleToString(fiboLevelsArray[i], 1);
      if (rates_total > 0)
        {
         ObjectCreate(0, fiboLevelName, OBJ_HLINE, 0, time[rates_total - 1], fiboLevelsValues[i]);
         ObjectSetInteger(0, fiboLevelName, OBJPROP_COLOR, clrGray);
         ObjectSetInteger(0, fiboLevelName, OBJPROP_WIDTH, 1);
        }
      else
        {
         Print("Error: Not enough bars in history for object creation");
        }
     }

   return(rates_total);
  }
//+------------------------------------------------------------------+
Documentation on MQL5: Language Basics / Preprocessor / Program Properties (#property)
Documentation on MQL5: Language Basics / Preprocessor / Program Properties (#property)
  • www.mql5.com
Every mql5-program allows to specify additional specific parameters named #property that help client terminal in proper servicing for programs...
 
Whats App: 'ObjectName' - wrong parameters count harmonic finder asap.mq5 55 27
      string objectName = ObjectName(i);

Perhaps you should read the manual. ObjectName - Object Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
   How To Ask Questions The Smart Way. (2004)
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

 

Congrats on the moderator status, you worked hard for it, ;-)

 

I always wondered why William wasn't a moderator before, he was the quintessential moderator to begin with, haha


highlight name 

And press F1 key, easiest approach for accessing the API


should be:

ObjectsTotal(0);

ObjectDelete(0, objectName);

ObjectName(0, i);
 
niConor Mcnamara #:

I always wondered why William wasn't a moderator before, he was the quintessential moderator to begin with, haha


highlight name 

And press F1 key, easiest approach for accessing the API


should be:

not sure what am doing wrong tried it now am getting 33 errors was getting 3
 

I don't know either, there's no errors in this:

//+------------------------------------------------------------------+
//|                                                       Fibonacci  |
//|                           Copyright 2024, oxygen  
//|                                             
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
#property indicator_plots 0

// Input parameters
input int fiboLevels = 5; // Number of Fibonacci levels to plot

// Variables
double fiboLevelsArray[5] = {0.0, 23.6, 38.2, 50.0, 61.8}; // Fibonacci levels in percentage
double fiboLevelsValues[5]; // Array to store Fibonacci levels values
string fiboObjectsPrefix = "FiboLevel_"; // Prefix for Fibonacci objects

string objectName;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   // Initialization code here, if needed
   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   // Calculate highest high and lowest low within the available data
   double highestHigh = high[ArrayMaximum(high, 0, rates_total - 1)];
   double lowestLow = low[ArrayMinimum(low, 0, rates_total - 1)];
   
   // Calculate Fibonacci levels dynamically
   double range = highestHigh - lowestLow;
   for (int i = 0; i < fiboLevels; i++)
     {
      fiboLevelsValues[i] = highestHigh - range * fiboLevelsArray[i] / 100.0;
     }


   // Plot Fibonacci levels
   for (int i = 0; i < fiboLevels; i++)
     {
      string fiboLevelName = fiboObjectsPrefix + DoubleToString(fiboLevelsArray[i], 1);
      if (rates_total > 0)
        {
         ObjectCreate(0, fiboLevelName, OBJ_HLINE, 0, time[rates_total - 1], fiboLevelsValues[i]);
         ObjectSetInteger(0, fiboLevelName, OBJPROP_COLOR, clrGray);
         ObjectSetInteger(0, fiboLevelName, OBJPROP_WIDTH, 1);
        }
      else
        {
         Print("Error: Not enough bars in history for object creation");
        }
     }

   return(rates_total);
  }
//+------------------------------------------------------------------+


void OnDeinit(const int reason){

   ObjectsDeleteAll(0, objectName);
}


and it's working


This is for MT5. Can you specify if you're using MT4 or MT5?

 

I  am using mt5 but it does not work for me as for the error its gone now but it wont work nothing comes up on my chart maybe i just have to delete this and start over again

 
Whats App #:

I  am using mt5 but it does not work for me as for the error its gone now but it wont work nothing comes up on my chart maybe i just have to delete this and start over again

You will only see these levels on H4 or D1 timeframe. The indicator itself seems coded well

 
Conor Mcnamara #:

I always wondered why William wasn't a moderator before, he was the quintessential moderator to begin with, haha


highlight name 

And press F1 key, easiest approach for accessing the API


should be:

THANK YOU FOR YOUR HELP IT IS FIX NOW