Issue Displaying Buttons in Separate Window for Symbol Changer Indicator

 

I'm creating a "Symbol Changer" indicator in MQL5 that should display currency pair buttons in a separate window below the main chart. The goal is for the buttons to appear in the indicator's own window (similar to how an RSI indicator would display), without overlaying the main chart.

Here's what I've done so far:

  1. I set #property indicator_separate_window to create a separate window.
  2. I used ObjectCreate() with OBJ_BUTTON to create buttons for each currency pair.
  3. I tried to ensure that the buttons appear in the separate window by using ChartID() instead of 0 when calling ObjectCreate() and ObjectSetInteger() for positioning.
  4. The OnCalculate function is empty, as no calculations or plots are needed for this indicator.

Despite these efforts, the buttons keep appearing over the main chart rather than in the separate window below it. Increasing the height of the indicator window doesn’t resolve the issue, and I can't get the buttons to stay confined to the indicator's own space.

Code Example: Here’s a simplified version of the code I'm using to create the buttons:

#property indicator_separate_window
#property indicator_buffers 0
#property indicator_plots 0

input string Pairs = "AUDCAD,AUDCHF,AUDJPY,EURUSD,GBPUSD";
input int ButtonWidth = 65;
input int ButtonHeight = 20;
input color ButtonColor = clrGainsboro;
input color SelectedButtonColor = clrBlue;
input color TextColor = clrBlack;

int OnInit() {
    string pairs[];
    StringSplit(Pairs, ',', pairs);
    int xPos = 10, yPos = 10;

    for (int i = 0; i < ArraySize(pairs); i++) {
        CreateButton("Button_" + pairs[i], pairs[i], xPos, yPos);
        xPos += ButtonWidth + 5;
    }

    return INIT_SUCCEEDED;
}

void CreateButton(string name, string label, int x, int y) {
    if (!ObjectCreate(ChartID(), name, OBJ_BUTTON, 0, 0, 0)) return;
    ObjectSetInteger(ChartID(), name, OBJPROP_XDISTANCE, x);
    ObjectSetInteger(ChartID(), name, OBJPROP_YDISTANCE, y);
    ObjectSetInteger(ChartID(), name, OBJPROP_XSIZE, ButtonWidth);
    ObjectSetInteger(ChartID(), name, OBJPROP_YSIZE, ButtonHeight);
    ObjectSetInteger(ChartID(), name, OBJPROP_COLOR, ButtonColor);
    ObjectSetString(ChartID(), name, OBJPROP_TEXT, label);
}
 
Hydra Corporation:

I'm creating a "Symbol Changer" indicator in MQL5 that should display currency pair buttons in a separate window below the main chart. The goal is for the buttons to appear in the indicator's own window (similar to how an RSI indicator would display), without overlaying the main chart.

Here's what I've done so far:

  1. I set #property indicator_separate_window to create a separate window.
  2. I used ObjectCreate() with OBJ_BUTTON to create buttons for each currency pair.
  3. I tried to ensure that the buttons appear in the separate window by using ChartID() instead of 0 when calling ObjectCreate() and ObjectSetInteger() for positioning.
  4. The OnCalculate function is empty, as no calculations or plots are needed for this indicator.

Despite these efforts, the buttons keep appearing over the main chart rather than in the separate window below it. Increasing the height of the indicator window doesn’t resolve the issue, and I can't get the buttons to stay confined to the indicator's own space.

Code Example: Here’s a simplified version of the code I'm using to create the buttons:

Specify the sub window when creating the object.  See the documentation 
[Deleted]  
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
 
Hydra Corporation: I tried to ensure that the buttons appear in the separate window by using ChartID() instead of 0 when calling ObjectCreate() and ObjectSetInteger() for positioning.
  1. Using ChartID instead of zero is irrelevant. You want to create the object on a subwindow of the current chart.
  2. Where do you find the sub-window index (where your indicator is running) and pass it to ObjectCreate? What is sub-window zero? Read the documentation.