How to know the period at I drawn an object?

 

I draw some Fibos at 5Min, 15Min, 1H and 1Day, I use the function ObjectsTotal() and it sends me 12 and it's OK, but I want to know for example:

Fibo1677 was draw at 5Min Period

Fibo 1900 was draw at 1H Period

Fibo 1873 was draw at 15Min Period

Fibo 1123 was draw at 5Min Period

Fibo 7125 was draw at 1H Period.... etc etc

 Beforehand, thank you

 

The only ways I can think of doing this are:

  • Store the fib name and current timeframe when you create each fib. Your method of storage will have to cope with terminal restarts and chart timeframe changes. So maybe look at global variables or writing to file.
  • Change the fib name when you create it to include the timeframe e.g. Fibo1677 becomes Fibo1677 - PERIOD_H1.
  • Add the current timefame to the description when you create the fib. But, this may be a problem if you display object descriptions. Or maybe a bonus if you want to be reminded visually?
  • Set the visibility of the fib to the current timeframe when you create it. This will then be your reference for the timeframe it was created on. But, this is a problem if you want to see your fib on other timeframes.
 Edited to remove inaccurate info (thank you Keith Watford)
 
honest_knave:

  • Change the fib name when you create it to include the timeframe e.g. Fibo1677 becomes Fibo1677 - PERIOD_H1. You can't actually rename an object, so you will need to create a new object with the new name and then delete the old one.

You can't rename an object?

You can in mq4, don't know about mq5

 
Keith Watford:

You can't rename an object?

You can in mq4, don't know about mq5

Well, quite possibly I am wrong...? BTW I'm talking about doing it from code, not from the properties window (perhaps I should have made that clearer)
 
ObjectSetString() with OBJPROP_NAME  in mq4
 
Keith Watford:
ObjectSetString() with OBJPROP_NAME  in mq4

Haha, thank you very much! Every day is a school day.

Very early on I had read that you couldn't rename objects and I just took that as a given from that point forward. With no real need for it, I never explored it.

 
honest_knave:

Haha, thank you very much! Every day is a school day.

Very early on I had read that you couldn't rename objects and I just took that as a given from that point forward.

It's great that we can still learn from each other.
 
Thank you honest_knave, it works! ^^ 
 
honest_knave:

Haha, thank you very much! Every day is a school day.

Very early on I had read that you couldn't rename objects and I just took that as a given from that point forward. With no real need for it, I never explored it.

Having explored this a little more today, it would seem that OBJPROP_NAME does trigger a CHARTEVENT_OBJECT_DELETE followed by a CHARTEVENT_OBJECT_CREATE.

So, the "renaming" is actually just a convenient way of deleting the old object and creating a new one.

Reason: