panel around labels not working correctly

 

Hi,

I have trying to put a panel around some labels that are just getting certain information, to make it look better i have colour schemes. The colour schemes have background colours.

the panels are only going out so far

//+------------------------------------------------------------------+
// Enhanced Panel Functions
//+------------------------------------------------------------------+
void RectLabelCreate(string name, int x, int y, color clr, int width, int height, bool selection)
{
    int corner = CORNER_RIGHT_UPPER;
    ResetLastError();
    
    // Delete existing object if it exists
    ObjectDelete(0, name);
    
    if (!ObjectCreate(0, name, OBJ_RECTANGLE_LABEL, 0, 0, 0))
    {
        Print(__FUNCTION__, ": Failed to create rectangle label! Error code = ", GetLastError());
        return;
    }
    
    ObjectSetInteger(0, name, OBJPROP_XDISTANCE, x);
    ObjectSetInteger(0, name, OBJPROP_YDISTANCE, y);
    ObjectSetInteger(0, name, OBJPROP_XSIZE, width);
    ObjectSetInteger(0, name, OBJPROP_YSIZE, height);
    ObjectSetInteger(0, name, OBJPROP_BGCOLOR, clr);
    ObjectSetInteger(0, name, OBJPROP_BORDER_TYPE, BORDER_FLAT);
    ObjectSetInteger(0, name, OBJPROP_CORNER, corner);
    ObjectSetInteger(0, name, OBJPROP_SELECTABLE, selection);
    ObjectSetInteger(0, name, OBJPROP_HIDDEN, true);
    ObjectSetInteger(0, name, OBJPROP_BACK, false);
    ObjectSetInteger(0, name, OBJPROP_ZORDER, 0);
    
    // Force object to be visible
    ObjectSetInteger(0, name, OBJPROP_TIMEFRAMES, OBJ_ALL_PERIODS);
    ObjectSetInteger(0, name, OBJPROP_SELECTED, false);
    ObjectSetInteger(0, name, OBJPROP_HIDDEN, false);
}

void LabelCreate(string name, int x, int y, string text, color clr, int font_size, bool isBold = false)
{
    ResetLastError();
    
    // Delete existing object if it exists
    ObjectDelete(0, name);
    
    if (!ObjectCreate(0, name, OBJ_LABEL, 0, 0, 0))
    {
        Print(__FUNCTION__, ": Failed to create label! Error code = ", GetLastError());
        return;
    }
    ObjectSetString(0, name, OBJPROP_TEXT, text);
    ObjectSetString(0, name, OBJPROP_FONT, isBold ? "Arial Bold" : FontName);
    ObjectSetInteger(0, name, OBJPROP_FONTSIZE, font_size);
    ObjectSetInteger(0, name, OBJPROP_COLOR, clr);
    ObjectSetInteger(0, name, OBJPROP_CORNER, CORNER_RIGHT_UPPER);
    ObjectSetInteger(0, name, OBJPROP_XDISTANCE, x);
    ObjectSetInteger(0, name, OBJPROP_YDISTANCE, y);
    ObjectSetInteger(0, name, OBJPROP_ANCHOR, ANCHOR_RIGHT_UPPER);
    ObjectSetInteger(0, name, OBJPROP_SELECTABLE, false);
    ObjectSetInteger(0, name, OBJPROP_HIDDEN, true);
    ObjectSetInteger(0, name, OBJPROP_BACK, false);
    ObjectSetInteger(0, name, OBJPROP_ZORDER, 2);
    
    // Force object to be visible
    ObjectSetInteger(0, name, OBJPROP_TIMEFRAMES, OBJ_ALL_PERIODS);
    ObjectSetInteger(0, name, OBJPROP_SELECTED, false);
    ObjectSetInteger(0, name, OBJPROP_HIDDEN, false);
}

int CalculatePanelWidth()
{
    int maxWidth = 0;
    string texts[] = {
        "Trade Information", 
        "Spread: 41.0", 
        "No Active Trades", 
        "Trade History", 
        "Market Sessions",
        "Balance: " + currencySymbol + "100000.00",  // Add maximum possible width texts
        "Equity: " + currencySymbol + "100000.00"
    };
    
    for(int i = 0; i < ArraySize(texts); i++)
    {
        int textWidth = GetTextWidth(texts[i], HeaderFontSize);
        if(textWidth > maxWidth)
            maxWidth = textWidth;
    }
    return maxWidth + (PANEL_PADDING * 4); // Increased padding
}

void CreatePanel(string name, int x, int y, int width, int height)
{
    if(!ShowBackground)
        return;

    // Check and delete existing object
    if(ObjectFind(0, name) >= 0)
        ObjectDelete(0, name);

    // Create border first (lowest Z-order)
    if(ShowBorder)
    {
        RectLabelCreate(name + "Border", 
                       x - BorderWidth, 
                       y - BorderWidth, 
                       BorderColor, 
                       width + (BorderWidth * 4), 
                       height + (BorderWidth * 4), 
                       false);
        ObjectSetInteger(0, name + "Border", OBJPROP_ZORDER, 0);
        ObjectSetInteger(0, name + "Border", OBJPROP_BACK, false);
    }

    // Create background panel (middle Z-order)
    RectLabelCreate(name + "Back", 
                   x, 
                   y, 
                   BackgroundColor, 
                   width + (BorderWidth * 2), 
                   height + (BorderWidth * 2), 
                   false);
    ObjectSetInteger(0, name + "Back", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, name + "Back", OBJPROP_BACK, false);
}

void CreateHeader(string name, string text, int x, int y, int width)
{
    // Header background (middle Z-order)
    RectLabelCreate(name + "HeaderBack", x, y, HeaderBackgroundColor, width, HEADER_HEIGHT, false);
    ObjectSetInteger(0, name + "HeaderBack", OBJPROP_ZORDER, 1);

    // Header text (highest Z-order)
    LabelCreate(name + "Header", x + PANEL_PADDING, y + (HEADER_HEIGHT/2), text, TextColor, HeaderFontSize, HeaderBold);
    ObjectSetInteger(0, name + "Header", OBJPROP_ZORDER, 2);
}

void CreateStyledSeparator(string name, int x, int y, int width)
{
    RectLabelCreate(name, x, y, separatorColor, width, 1, false);
    ObjectSetInteger(0, name, OBJPROP_ZORDER, 1);
}

ive added only a small amount of the code, this is the panel function. If anyone can help, much appreciated 

Thanks

 
Is it possible to have a background for an indicator that sits behind labels and text. I am struggling to figure out how to do this. 
 
Is there an option to use a horizontal line as a separator for the lines, i have given up hope for a background panel, now looking to use a horizontal line as a spacer/separator.