How to pick up the newest object property?

 

Hi, I want to pick up the most recent object color.

I have the indicator of rectangle. and I can read the color of the object and time of object draw.

  string name;
 for(int i=ObjectsTotal()-1;i>=0;i--){
    name = ObjectName(i);
   
     if (ObjectType(name) == OBJ_RECTANGLE) {
        static double rctime = ObjectGet(name,OBJPROP_TIME1);
         double V=rctime;
         rctime =ObjectGet(name,OBJPROP_TIME1);
       color rectColor = color(ObjectGetInteger(0,name,OBJPROP_COLOR));
        
  if(rctime>V){ 
    
  
}
      if(rectColor==Red){Print("RED");}
      if(rectColor==Green){Print("GREEN");}
      
 }
  

}


What I want is to scan all Rectangle objects in the chart and find the most recent object color.

But I can not make it. Maybe to order the object time is not correct?

I used static value to compare the previous time and newer time and pick the most recent object color.

If the last color is red, then I will place sell order.

If the last color is green, then I will place buy order.


Can you point out the error of my code?

 
Cromo: What I want is to scan all Rectangle objects in the chart and find the most recent object color. But I can not make it. Maybe to order the object time is not correct?
  1. Do you mean the "most recent object's color?"
    1. Objects do not have creation/modification times.
    2. They do have 1-3 coordinates (except for HLine) but which one to use? Did you draw your rectangle left to right or the other way?
    3. Where is your code remembering the newest coordinate and object's name?
  2. Or the "most recent color of an object?" There is only current color; recent implies history and that doesn't exist.