Indicator Not Displaying Lines in Separate Window in MQL5

 

Hi everyone,

I'm developing a currency strength indicator in MQL5 that calculates the relative strength of each currency and plots lines for each one in a separate window below the main chart (similar to RSI). However, I’m having trouble getting the lines to display in the indicator’s window, even though I've set #property indicator_separate_window .

Here’s what I’ve done so far:

  1. Set #property indicator_separate_window to make it appear in a separate window.
  2. Used SetIndexBuffer and PlotIndexSetInteger for each currency line with PLOT_DRAW_TYPE , PLOT_LINE_WIDTH , and PLOT_LINE_COLOR settings.
  3. Calculated the values in OnCalculate and populated each buffer (e.g., USD_Buffer , EUR_Buffer ).
  4. Verified that the calculations produce valid values.

Here’s a sample of the code that configures the buffers and calculates the values:

#property indicator_separate_window
#property indicator_buffers 4

double USD_Buffer[];
double EUR_Buffer[];
double GBP_Buffer[];
double JPY_Buffer[];

int OnInit()
{
    SetIndexBuffer(0, USD_Buffer);
    PlotIndexSetInteger(0, PLOT_DRAW_TYPE, DRAW_LINE);
    PlotIndexSetInteger(0, PLOT_LINE_WIDTH, 2);
    PlotIndexSetInteger(0, PLOT_LINE_COLOR, clrRed);
    PlotIndexSetString(0, PLOT_LABEL, "USD");

    // Similar setup for EUR, GBP, JPY buffers
    return INIT_SUCCEEDED;
}

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[])
{
    for (int i = prev_calculated; i < rates_total; i++) {
        USD_Buffer[i] = /* calculated value */;
        EUR_Buffer[i] = /* calculated value */;
        // similarly for GBP and JPY
    }
    return rates_total;
}

Despite this, when I apply the indicator to the chart, the separate window appears, but the lines do not render. I've double-checked that I have sufficient historical data for all symbols and ensured the calculation logic is working, but the window remains empty.

Does anyone have suggestions on what might be missing or misconfigured? Any guidance would be greatly appreciated!

Thank you in advance!

 
Leonardo A:

Hi everyone,

I'm developing a currency strength indicator in MQL5 that calculates the relative strength of each currency and plots lines for each one in a separate window below the main chart (similar to RSI). However, I’m having trouble getting the lines to display in the indicator’s window, even though I've set #property indicator_separate_window .

Here’s what I’ve done so far:

  1. Set #property indicator_separate_window to make it appear in a separate window.
  2. Used SetIndexBuffer and PlotIndexSetInteger for each currency line with PLOT_DRAW_TYPE , PLOT_LINE_WIDTH , and PLOT_LINE_COLOR settings.
  3. Calculated the values in OnCalculate and populated each buffer (e.g., USD_Buffer , EUR_Buffer ).
  4. Verified that the calculations produce valid values.

Here’s a sample of the code that configures the buffers and calculates the values:


Despite this, when I apply the indicator to the chart, the separate window appears, but the lines do not render. I've double-checked that I have sufficient historical data for all symbols and ensured the calculation logic is working, but the window remains empty.

Does anyone have suggestions on what might be missing or misconfigured? Any guidance would be greatly appreciated!

Thank you in advance!

and where have you specified the number of plots for example?

I would suggest you look at one of the existing indicators and learn from that...

https://www.mql5.com/en/docs/indicators/irsi

Documentation on MQL5: Technical Indicators / iRSI
Documentation on MQL5: Technical Indicators / iRSI
  • www.mql5.com
The function returns the handle of the Relative Strength Index indicator. It has only one buffer. Parameters symbol [in] The symbol name of the...
 
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