My indicator is not displaying on Chart any idea the missing component?

 

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Yellow
#property indicator_color2 Yellow
#property indicator_width1 2
#property indicator_width2 2
// Input parameters
input int RsiPeriod = 14;
// Indicator buffers
double ResistanceBuffer[];
double SupportBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
    // Set the indicator buffers
    SetIndexBuffer(0, ResistanceBuffer);
    SetIndexBuffer(1, SupportBuffer);
    // Set the indicator labels
    PlotIndexSetString(0, PLOT_LABEL, "Resistance");
    PlotIndexSetString(1, PLOT_LABEL, "Support");
    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 the RSI values
    double rsiBuffer[];
    ArrayResize(rsiBuffer, rates_total);
    //int rsiCount = iRSI(NULL, 0, RsiPeriod, PRICE_CLOSE, rsiBuffer);
    int rsiCount = iRSI(NULL, 0, RsiPeriod, PRICE_CLOSE);
    // Find strong resistance and support zones
    int resistanceCount = 0;
    int supportCount = 0;
    for (int i = 1; i < rsiCount - 1; i++)
    {
        if (rsiBuffer[i] >= 70 && rsiBuffer[i - 1] < 70)
        {
            resistanceCount++;
            ResistanceBuffer[resistanceCount] = high[i];
        }
        else if (rsiBuffer[i] <= 30 && rsiBuffer[i - 1] > 30)
        {
            supportCount++;
            SupportBuffer[supportCount] = low[i];
        }
        else
        {
            ResistanceBuffer[i] = 0.0;
            SupportBuffer[i] = 0.0;
        }
    }
    // Remove the remaining values from the buffer
    for (int i = resistanceCount + 1; i < rates_total; i++)
    {
        ResistanceBuffer[i] = 0.0;
    }
    for (int i = supportCount + 1; i < rates_total; i++)
    {
        SupportBuffer[i] = 0.0;
    }
    return rates_total;
}
 

Good morning
Obviously you are trying to make an RSI with the marked thresholds.

I made two codes
One with the irsi function and the other without the function, more difficult for beginners but should provide answers

Free download of the 'Rsi code for beginners by William210' indicator by 'William210' for MetaTrader 5 in the MQL5 Code Base, 2023.08.30

And

Free download of the 'Rsi without Irsi() code for beginners by William210' indicator by 'William210' for MetaTrader 5 in the MQL5 Code Base, 2023.09.21


Consider putting stars for SEO, thank you

Rsi code for beginners by William210
Rsi code for beginners by William210
  • www.mql5.com
Rsi beginner tutorial to learn how to code in MQL5
 
Your topic has been moved to the section: Technical Indicators
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 
Bernard Fiagbe:
#property indicator_chart_window
#property indicator_buffers 2

How many plots?

 

The indicator functions, like iRSI(), return a handle in MQL5, not a count.

It should also be obtained in the OnInit() handler and then used later with CopyBuffer() to get the indicator buffer contents.

Please refer to the documentation for more information and examples.
Documentation on MQL5: Technical Indicators / iRSI
Documentation on MQL5: Technical Indicators / iRSI
  • www.mql5.com
iRSI - Technical Indicators - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
William Roeder #:

How many plots?

No plots here just buffers
 
Tobias Johannes Zimmer #:
No plots here just buffers
Plot is what is displayed graphically