Mql4 EA unable to access multiple chart object properties

 
I am writing an mql4 EA that adds a custom indicator to multiple charts
Since mql4 does not have ChartIndicatorAdd(), I used a .dll work-around for the first chart, then saved template and applied template to other subsequent charts
Now I intend to study the nature of the objects the indicator draws on the charts
ObjectsTotal returns the right amount of objects using the chart ids, however, I am unable to loop through the objects or even get the object's name
I could see the object name in the object list and I use that to try access the object properties, but still nothing
            // Function to check for new PSF arrows
            bool CheckForNewPSFArrows(long chartId, int &currentCount, bool &buySignal, bool &sellSignal)
            {
               // Update the count
               int prev = currentCount;
               currentCount = ObjectsTotal(chartId);
               
               if(currentCount > prev)
               {
                  
                  for(int i = currentCount; i > prev; i--)
                  {
                     int shift = InpExecutionMode == IMMEDIATE ? 0 : 1;
                     string objectName = "PSF arrows: " + IntegerToString((long)iTime(TradedSymbol,TimeFrame,shift));
                     int find = ObjectFind(chartId, objectName);
                     ENUM_OBJECT type = (ENUM_OBJECT)ObjectGetInteger(chartId, objectName, OBJPROP_TYPE);
                     ObjectSetInteger(chartId, objectName, OBJPROP_HIDDEN, false);
                     ObjectSetInteger(chartId, objectName, OBJPROP_READONLY, false);
                     ObjectSetInteger(chartId, objectName, OBJPROP_SELECTABLE, true);
                     ObjectSetInteger(chartId, objectName, OBJPROP_SELECTED, true);
                     ObjectSetInteger(chartId, objectName, OBJPROP_TIMEFRAMES, OBJ_ALL_PERIODS);
                     long objectTime = ObjectGetInteger(chartId, objectName, OBJPROP_TIME);
                     if(true)
                     {
                        // Check the color of the arrow
                        color arrowColor = (color)ObjectGetInteger(chartId, objectName, OBJPROP_LEVELCOLOR);
                        ENUM_OBJECT type;
                        type = (ENUM_OBJECT)ObjectGetInteger(chartId, objectName, OBJPROP_TYPE);
                        if(arrowColor == clrGreen || arrowColor == clrDarkGreen)
                        {
                           buySignal = true;
                           Print("PSF Buy signal detected on ", TradedSymbol, " ", EnumToString(TimeFrame));
                        }
                        else if(arrowColor == clrRed || arrowColor == clrCrimson)
                        {
                           sellSignal = true;
                           Print("PSF Sell signal detected on ", TradedSymbol, " ", EnumToString(TimeFrame));
                        }
                        return true;
                     }
                  }
               }
               
               return false;
            }
 
Valentine Chibuike Ozoigboanugo:
I am writing an mql4 EA that adds a custom indicator to multiple charts
Since mql4 does not have ChartIndicatorAdd(), I used a .dll work-around for the first chart, then saved template and applied template to other subsequent charts
Now I intend to study the nature of the objects the indicator draws on the charts
ObjectsTotal returns the right amount of objects using the chart ids, however, I am unable to loop through the objects or even get the object's name
I could see the object name in the object list and I use that to try access the object properties, but still nothing

try the link below your msg "Object created but unable to find".

 
Michael Charles Schefe #:

try the link below your msg "Object created but unable to find".

Original code before my manipulations:

            // Function to check for new PSF arrows
            bool CheckForNewPSFArrows(long chartId, int &currentCount, bool &buySignal, bool &sellSignal)
            {
               // Update the count
               int prev = currentCount;
               currentCount = ObjectsTotal(chartId);
               
               if(currentCount > prev)
               {
                  
                  for(int i = currentCount-1; i >= prev; i--)
                  {
                     string objectName = ObjectName(chartId, i);
                     long objectTime = ObjectGetInteger(chartId, objectName, OBJPROP_TIME);
                     int shift = InpExecutionMode == IMMEDIATE ? 0 : 1;
                     if(StringFind(objectName, "PSF arrows:") >= 0 && objectTime == iTime(TradedSymbol, TimeFrame, shift))
                     {
                        // Check the color of the arrow
                        color arrowColor = (color)ObjectGetInteger(chartId, objectName, OBJPROP_COLOR);
                        
                        if(arrowColor == clrGreen || arrowColor == clrDarkGreen)
                        {
                           buySignal = true;
                           Print("PSF Buy signal detected on ", TradedSymbol, " ", EnumToString(TimeFrame));
                        }
                        else if(arrowColor == clrRed || arrowColor == clrCrimson)
                        {
                           sellSignal = true;
                           Print("PSF Sell signal detected on ", TradedSymbol, " ", EnumToString(TimeFrame));
                        }
                        return true;
                     }
                  }
               }
               
               return false;
            }

Still same result with the right indexing

 

Problem solved

The problem was actually the indexing then the actual property type I was checking.

Thank you Michael Charles Schefe