counting objects by time (past to present)

 
I'm struggling with understanding how to count bars and objects. I see bars are counted right to left (present to past) by default and I know how to count objects based on their insertion order index (which isn't always past to present on manually inserted objects). However, I don't know how to count bars or objects left to right (past to present).

I'd like to be able to count objects as described in the attached chart where objects are counted left to right starting with 1 for each new period (e.g. new day or month). How do I do this?

Thanks in advance for any assistance with this.

Bill

 
Objects are listed in appearance mode. First created object is first in the list
 
stringo wrote:
Objects are listed in appearance mode. First created object is first in the list

Yes I got that (as stated in my message). I just don't know how to code a routine based on the date an object is inserted as opposed to its creation order. In the screen shot above, how do I code it so that the numbered text objects get inserted by a script similar to how they've been manually drawn above to indicate the number of arrows that get drawn each day? The objects index needs to be sorted by day and then by bars in chronological order for each day. I just don't know how to code it. If the use of a proper shift value and the time access functions are required, I'm not currently understanding how to put them together to get the desired result. An example of how to do this would help.
 
for example
int ObjectsArray[][2];
int total=ObjectsTotal();
if(total>1)
  {
   ArrayResize(ObjectsArray,total);
   for(int i=0; i<total; i++)
     {
      string name=ObjectName(i);
      ObjectsArray[i][0]=ObjectGet(name,OBJPROP_TIME1);
      ObjectsArray[i][1]=i;
     }
   ArraySort(ObjectsArray);
   for(i=0; i<total; i++)
      Print(ObjectName(ObjectsArray[i][1]));
  }
 

Thanks, but, this is not working. It's still printing the objects in the order in which they were created rather than the order they appear (left to right) on the chart.

To illustrate, in the chart below, the numbers below the bar represent the order in which the objects were inserted onto the chart manually. The number above represents a count of the objects left to right across two days. The uppermost numbers in brackets count the objects left to right and reset back to 1 at the beginning of the day. I'd eventually like to accomplish what's illustratrated in the bracketed numbers, however, we're not even getting the proper left-right count.

Please see what is printed to the Experts tab below. I've added Price: and Time: to the Print() statement to ease association with objects on the chart.

Still lost on how to do this.

stringo wrote:
for example
int ObjectsArray[][2];
int total=ObjectsTotal();
if(total>1)
  {
   ArrayResize(ObjectsArray,total);
   for(int i=0; i<total; i++)
     {
      string name=ObjectName(i);
      ObjectsArray[i][0]=ObjectGet(name,OBJPROP_TIME1);
      ObjectsArray[i][1]=i;
     }
   ArraySort(ObjectsArray);
   for(i=0; i<total; i++)
      Print(ObjectName(ObjectsArray[i][1]));
  }

 

Okay. I've looked into this a bit more and see that it IS working. The problem I has was in the additional code I added to Print() the price and time of the objects. I needed to reference their names from within the ObjectArray rather than the plain old ObjectName(i) to get the right time/price info. Makes complete sense now. Thanks for the help Stringo.

Reason: