how to use IfObjectExist

 

Hi 

is any can help how to code if and object exist do next?  example code:

void Arrow()
{
    ObjCount += 1;
    string objName = "EAChart_" + ObjCount;
    ObjectCreate(objName, OBJ_ARROW, 0, Time[0], Bid);
    ObjectSet(objName, OBJPROP_COLOR, White);
    ObjectSet(objName, OBJPROP_ARROWCODE, SYMBOL_ARROWUP);
    IfOrderExists18();
    
}

void IfObjectExists()
{
    bool exists = false;
    for (int i=ObjectsTotal()-1; i >= 0; i--)
    if (ObjectGet(i,OBJPROP_ARROWCODE))
    {
        if (ObjectType(OBJ_ARROW) == OBJ_ARROW_UP)
        {
            exists = true;
        }
    }
    else
    {
        Print("ObjectName() error - ", ErrorDescription(GetLastError()));
    }
    
    if (exists)
    {
        BuyOrder();.......
 
  1.    for (int i=ObjectsTotal()-1; i >= 0; i--)
        if (ObjectGet(i,OBJPROP_ARROWCODE))

    You can't use ObjectsTotal() and ObjectGet(i, type)

    Perhaps you should read the manual. ObjectsTotal - Object Functions - MQL4 Reference
       How To Ask Questions The Smart Way. 2004
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.

  2.         if (ObjectType(OBJ_ARROW) == OBJ_ARROW_UP)

    You need to read the documentation. ObjectType() takes an object name.

  3. if (ObjectType(OBJ_ARROW) == OBJ_ARROW_UP)

    You need to read the documentation. An Arrow is a different type than Arrow Up.