How to Find Objects with timestamp name in the Chart Created by an Indicator

To add comments, please log in or register
M4STR0
22
M4STR0  

Hello, 

I am pretty noob in MQL4 and I am walking a bit in the darkness when working with Objects Functions and Time for an EA.

I am writing an EA that has to do something when he finds that an Arrow object with a defined Arrow code that has been created by an Indicator in the Chart.

This is what I have in the Ontick() of the EA:

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
      if (NewCandle())
      {
         CheckArrowSignal()
      } 
  }

This is the NewCandle() function I am using to run commands after a new candle is done:

//+------------------------------------------------------------------+
//| Expert New Candle Function                                       |
//+------------------------------------------------------------------+  
bool NewCandle()
  {
     static datetime lastbar;
     datetime ourbar = Time[0];
      
        if (lastbar != ourbar)
        {
           lastbar=ourbar;
           return (true);
        }
        else
        {
           return (false);
        }
  }

And this is the function I am writing to check if the Arrows I am looking for have been created:

//+------------------------------------------------------------------+
//| Expert Check Arrow Signal Function                               |
//+------------------------------------------------------------------+  
void CheckArrowSignal()
  {
      if(ObjectFind("Arrows:"+Time[0]))
      Print("Found");
      else
      Print("Not found");
  }

Unfortunately I get always "found" in the journal, but I think I am doing something wrong, as this arrows are not in every candle that are generated, I tryed also to use CheckArrowSignal() just in the Ontick() but with same result.

The name of the arrows are something like this: "arrows:1575518400","arrows:1575590400" et cet. I guess the numbers are the time, that is why I use +Time[0]. 
Another thing I would like to check also is the parameter Arrow Code of the arrows that are created.

Somebody has any suggestions or guidelines about this topic?

Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types
  • www.mql5.com
When a graphical object is created using the ObjectCreate() function, it's necessary to specify the type of object being created, which can be one of the values of the ENUM_OBJECT enumeration. Further specifications of object properties are possible using functions for working with graphical objects.
William Roeder
20250
William Roeder  
M4STR0: Unfortunately I get always "found" in the journal, but I think I am doing something wrong, a
      if(ObjectFind("Arrows:"+Time[0]))
Perhaps you should read the manual. ObjectFind does not return a bool.
          ObjectFind - Object Functions - MQL4 Reference
To add comments, please log in or register