Objects are not being drawn on the chart.

 

The indicator is supposed to draw a red circle using wingdings under an up candle when its volume is higher than the individual volumes of the previous two up candles.

The same logic for down candles. Using text, e.g. draw a letter O, instead of wingdings also does not work.

Suggestions are welcome.

//+------------------------------------------------------------------+
//|                       Vifta-a.mq4                               |
//|       Change of Behaviour Indicator                             |
//+------------------------------------------------------------------+
#property copyright "Copyright 2025, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.08"
#property strict
#property indicator_chart_window

input int LookbackBars = 100;  // Number of bars to check
input int TextOffset = 20;     // Distance of circle from the candle (in pixels)
input int FontSize = 14;       // Wingdings font size

//+------------------------------------------------------------------+
//| Initialization                                                   |
//+------------------------------------------------------------------+
int OnInit()
{
    return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Main Calculation                                                 |
//+------------------------------------------------------------------+
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[])
{
    if (rates_total < 10)
        return(0);

    for (int i = rates_total - 2; i >= rates_total - LookbackBars && i >= 2; i--)
    {
        bool isUp = close[i] > open[i];
        bool isDown = close[i] < open[i];

        int found = 0;
        int last1 = -1, last2 = -1;

        // Search backwards for last two matching bars (same direction)
        for (int j = i - 1; j >= 0 && found < 2; j--)
        {
            if (isUp && close[j] > open[j])
            {
                if (last1 == -1) last1 = j;
                else last2 = j;
                found++;
            }
            else if (isDown && close[j] < open[j])
            {
                if (last1 == -1) last1 = j;
                else last2 = j;
                found++;
            }
        }

        // Proceed only if both previous same-direction bars found
        if (last1 != -1 && last2 != -1)
        {
            if (volume[i] > volume[last1] && volume[i] > volume[last2])
            {
                string objName = "COB_" + IntegerToString(i);

                // Fix ObjectFind() logic
                if (ObjectFind(objName) == -1) // Correct way to check if object exists
                {
                    bool success = ObjectCreate(objName, OBJ_TEXT, 0, time[i], 0); // Y set to 0, we'll adjust using YDISTANCE
                    if (success)
                    {
                        ObjectSetText(objName, "l", FontSize, "Wingdings", clrRed);  // 'l' in Wingdings is a solid circle
                        ObjectSetInteger(ChartID(), objName, OBJPROP_YDISTANCE, TextOffset); // Ensuring correct Y distance positioning
                    }
                    else
                    {
                        Print("Failed to create object: ", objName);
                    }
                }
            }
        }
    }

    return(rates_total);
}

//+------------------------------------------------------------------+