Hi all,
I need some programming help. What I want to do is kind of trivial to do if done graphically, but I haven't figured out how to do it inside an indicator program.
1. Rename objects:
I want to rename chart objects such as an OBJ_FIBO so that it has a different "ObjectName". (NOT ObjectDescription which is different).
Graphically, if I place a fibo object on my chart and select it, it is trivial to change it's ObjectName:
Select the object. Right-click. Fibo Properties -> Common tab -> Name (edit, then OK to save. Unless another object by the new name exists, it will save it, no problem.)
However, I cannot find an appropriate MQL function to do this. I can see "ObjectName" which retrieves the name. But there is no "ObjectRename" nor "ObjectSetName" nor do I see that ObjectSet can be used for this purpose, nor anything else. The ObjectSetText changes the "Description" field for the object just fine, but again, that's not the "Name" field.
My only workaround would seem to be to do an ObjectCreate, and copy every single object property value (which seems rather tedious to me), and when finished creating the new object, delete the old object. Is there a better way?
2. Copy objects:
I'd also like an easy way to Copy an object with all its properties intact.
Graphically this is trivial to do as well. (Actually it's a neat trick that I just recently learned). In a chart, select an object. Now hold down the Control key at the same time as a left-click over that object and drag it elsewhere on the chart. This copies the object!
However, as before, I can find no easy MQL function to do this. There is no ObjectCopy function. Once again, I'm left with my workaround which is to ObjectCreate a new object and copy each of the many property values over from the original object to the new.
Is there an easier way?
3. If I still have your attention, let me explain my idea, and you can help me to know if there's any serious drawbacks to it.
I'd like to create objects graphically and then edit the Description to add a keyword. I'll add an indicator that in the "start" function (every tick), it will run through a foreach-object loop. If it detects the Description keyword, it will modify some properties on that object. However, when finished, change the NAME of that object to add a new keyword. Then the next time through the loop as it detects the Description keyword again, it will first check the Name field and if the same keyword exists there, it will leave the object alone.
By this method, I'd like to use the Description field to give commands to modify the object, but I'd like to use the Name field to store some of the key data, including my keywords as well as time/value points.
I know I'm limited to 62-characters for both the Description and Name fields, and I know that every Object "Name" must be unique. I am unaware of other other object string property which I could use for this purpose but if there is, please tell me more.
My concerns before I do this:
a. Will I blow up my virtual memory if I delete/create too many objects?
Because this is every tick, will I radically slow down my session if I get a lot of objects?
b. Is there a more efficient method to determine whether any OBJECT has changed since the last time a program ran? Every new bar is too slow. Every new tick is excessive. I need something in between... alas.
4. While we're on the topic, I'm also looking for some way to pass chart objects between charts. I presume this means I must us an indicator to write out object descriptions to some file from one chart, and read that file using an indicator running on another chart. However, I'd also like bi-directional capabilities, so reading and writing from the SAME file simultaneously isn't possible, so... any suggestions? I guess each chart could write its own unique file, but read every other file.
Are there any programming examples of this kind of idea?
Thanks in advance for any hints or solutions,
Pips4life (Kent)
I need some programming help. What I want to do is kind of trivial to do if done graphically, but I haven't figured out how to do it inside an indicator program.
1. Rename objects:
I want to rename chart objects such as an OBJ_FIBO so that it has a different "ObjectName". (NOT ObjectDescription which is different).
Graphically, if I place a fibo object on my chart and select it, it is trivial to change it's ObjectName:
Select the object. Right-click. Fibo Properties -> Common tab -> Name (edit, then OK to save. Unless another object by the new name exists, it will save it, no problem.)
However, I cannot find an appropriate MQL function to do this. I can see "ObjectName" which retrieves the name. But there is no "ObjectRename" nor "ObjectSetName" nor do I see that ObjectSet can be used for this purpose, nor anything else. The ObjectSetText changes the "Description" field for the object just fine, but again, that's not the "Name" field.
My only workaround would seem to be to do an ObjectCreate, and copy every single object property value (which seems rather tedious to me), and when finished creating the new object, delete the old object. Is there a better way?
2. Copy objects:
I'd also like an easy way to Copy an object with all its properties intact.
Graphically this is trivial to do as well. (Actually it's a neat trick that I just recently learned). In a chart, select an object. Now hold down the Control key at the same time as a left-click over that object and drag it elsewhere on the chart. This copies the object!
However, as before, I can find no easy MQL function to do this. There is no ObjectCopy function. Once again, I'm left with my workaround which is to ObjectCreate a new object and copy each of the many property values over from the original object to the new.
Is there an easier way?
3. If I still have your attention, let me explain my idea, and you can help me to know if there's any serious drawbacks to it.
I'd like to create objects graphically and then edit the Description to add a keyword. I'll add an indicator that in the "start" function (every tick), it will run through a foreach-object loop. If it detects the Description keyword, it will modify some properties on that object. However, when finished, change the NAME of that object to add a new keyword. Then the next time through the loop as it detects the Description keyword again, it will first check the Name field and if the same keyword exists there, it will leave the object alone.
By this method, I'd like to use the Description field to give commands to modify the object, but I'd like to use the Name field to store some of the key data, including my keywords as well as time/value points.
I know I'm limited to 62-characters for both the Description and Name fields, and I know that every Object "Name" must be unique. I am unaware of other other object string property which I could use for this purpose but if there is, please tell me more.
My concerns before I do this:
a. Will I blow up my virtual memory if I delete/create too many objects?
Because this is every tick, will I radically slow down my session if I get a lot of objects?
b. Is there a more efficient method to determine whether any OBJECT has changed since the last time a program ran? Every new bar is too slow. Every new tick is excessive. I need something in between... alas.
4. While we're on the topic, I'm also looking for some way to pass chart objects between charts. I presume this means I must us an indicator to write out object descriptions to some file from one chart, and read that file using an indicator running on another chart. However, I'd also like bi-directional capabilities, so reading and writing from the SAME file simultaneously isn't possible, so... any suggestions? I guess each chart could write its own unique file, but read every other file.
Are there any programming examples of this kind of idea?
Thanks in advance for any hints or solutions,
Pips4life (Kent)