cannot load indicator 'Relative Strength Index' [4804]

 
//+------------------------------------------------------------------+
//|                                                      SpikeDetector.mq5 |
//|                        Copyright 2022, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots   1

#include <Trade\Trade.mqh>
#include <Indicators\Indicators.mqh>
#include <Indicators\Indicator.mqh>
#include <indicators\Oscilators.mqh>



// Input parameters
input int SpikeSize = 10; // Minimum size of a spike in pips
input int LookbackPeriod = 20; // Lookback period for volume and RSI analysis
input int RsiOverboughtLevel = 70; // RSI overbought level
input int RsiOversoldLevel = 30; // RSI oversold level
input double MinVolumeRatio = 2.0; // Minimum ratio of current volume to average volume
input double MaxRSIRange = 50.0; // Maximum range of RSI values over the lookback period

// Indicator buffers
double SpikesBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
   // Define indicator properties
   IndicatorSetString(INDICATOR_SHORTNAME, "Spike Detector");
   IndicatorSetInteger(INDICATOR_DIGITS, _Digits);
   SetIndexBuffer(0, SpikesBuffer, INDICATOR_DATA);
   PlotIndexSetInteger(0, PLOT_DRAW_TYPE, DRAW_ARROW);
   PlotIndexSetString(0, PLOT_LABEL, "Spikes");
   PlotIndexSetInteger(0, PLOT_ARROW, 233);
   PlotIndexSetDouble(0, PLOT_EMPTY_VALUE, EMPTY_VALUE);
   

   return(INIT_SUCCEEDED);
}

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])
                
                
{
   double rsi_buffer[];
   ArraySetAsSeries(rsi_buffer, true);
   
   double high_prices[];
   double low_prices[];
   long tick_volumes[];
   CopyHigh(_Symbol, _Period, 0, rates_total, high_prices);
   CopyLow(_Symbol, _Period, 0, rates_total, low_prices);
   CopyTickVolume(_Symbol, _Period, 0, rates_total, tick_volumes);

   double rsi_calculated;

   for(int i = rates_total - 1; i >= 0; i--)
   {
      double range = high_prices[i] - low_prices[i]; // Calculate the range of the current bar
      double avg_volume = iMA(_Symbol, _Period ,LookbackPeriod ,0 ,MODE_SMA ,VOLUME_REAL); // Calculate the average volume over the lookback period
      double rsi_range = iATR(_Symbol, _Period ,LookbackPeriod); // Calculate the range of RSI values over the lookback period

      rsi_calculated = iRSI(_Symbol, _Period ,LookbackPeriod,i); // Calculate RSI value for current bar
      ArrayResize(rsi_buffer, rates_total); // Store RSI value in buffer

      // Check if the current bar is a spike
      if(range >= SpikeSize * _Point * 0.9 && tick_volumes[i] >= avg_volume * MinVolumeRatio && rsi_range <= MaxRSIRange && (rsi_buffer[i] >= RsiOverboughtLevel || rsi_buffer[i] <= RsiOversoldLevel))
      {
         if (SpikesBuffer[i] == 0.0)
         {
            SpikesBuffer[i] = high_prices[i]; // Mark the spike with an arrow
         }
         else
         {
            SpikesBuffer[i] = EMPTY_VALUE;
         }
      }
      else
      {
         SpikesBuffer[i] = EMPTY_VALUE; // No spike detected
      }
   }
   return(rates_total);
}

Can someone please help. I have no idea why this happening


Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • 2023.04.07
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
 

Please edit your post to use the CODE button (Alt-S)!

Use the CODE button

 
Sergey Golubev #:

Please edit your post to use the CODE button (Alt-S)!

Cool. Did do the edit.
 
      double avg_volume = iMA(_Symbol, _Period ,LookbackPeriod ,0 ,MODE_SMA ,VOLUME_REAL); // Calculate the average volume over the lookback period
      double rsi_range = iATR(_Symbol, _Period ,LookbackPeriod); // Calculate the range of RSI values over the lookback period

Perhaps you should read the manual, especially the examples.
   How To Ask Questions The Smart Way. (2004)
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick/OnCalculate (after the indicator has updated its buffers), you use the handle, shift and count to get the data.
          Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
          Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
          How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 (2020)
          How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 (2020)
          MQL5 for Newbies: Guide to Using Technical Indicators in Expert Advisors - MQL5 Articles (2010)
          How to call indicators in MQL5 - MQL5 Articles (2010)

 
William Roeder #:

Perhaps you should read the manual, especially the examples.
   How To Ask Questions The Smart Way. (2004)
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick/OnCalculate (after the indicator has updated its buffers), you use the handle, shift and count to get the data.
          Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
          Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
          How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 (2020)
          How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 (2020)
          MQL5 for Newbies: Guide to Using Technical Indicators in Expert Advisors - MQL5 Articles (2010)
          How to call indicators in MQL5 - MQL5 Articles (2010)

Wow Man. you are really helpful. How could the world not know the star they created. Or maybe we should thank your mother for the kindness she showed towards you as a child. Clearly you on the road to greatness, Hope when you ask for help that the people show you the kindness you show other people. 
 
Oom Jan #: Wow Man. you are really helpful. How could the world not know the star they created. Or maybe we should thank your mother for the kindness she showed towards you as a child. Clearly you on the road to greatness, Hope when you ask for help that the people show you the kindness you show other people. 

Snowflake steaming at the slightest heat. You wasted hundreds of peoples time looking at your broken code, yet we are the problem? Live in ignorance; on my do not help list.
Others disagree with you.
My terse remarks have resulted in many posters putting in some effort and learning. And some have posted that they are grateful that they were forced to study.

Thank you, William Roeder! - General - MQL5 programming forum (2022)