for(int k=0;k<ObjectsTotal(0,0, OBJ_TEXT);k++) { string ob_name = ObjectName(k); if(StringFind(ob_name,"DE")!=0) continue; string text = ObjectGetString(0,ob_name,OBJPROP_TEXT); }
use this code
Hi,Trinh
I am still in trouble.
Please see below.
I want to read below Text which is "StopLoss 1.26168" from the object on the chart.
If text name contains "1651719720", then pick up the Text label from the object.
This is my code. But something wrong with it. It does not work properly. Can you point out why?
string text; string ob_name; for(int k=0;k<ObjectsTotal(0,0, OBJ_TEXT);k++) { ob_name = ObjectName(k); if(StringFind(ob_name,"1651719720")!=0)continue; } text = ObjectGetString(0,ob_name,OBJPROP_TEXT); Print(text); }
#define MAIN_WINDOW 0 for(int k=0;k<ObjectsTotal(0,MAIN_WINDOW, OBJ_TEXT);k++) { ob_name = ObjectName(k);You are getting the count of only text objects, but reading all objects.
Hi, William
Thank you for your advice.
I thought the object was text because it shows "Object Text" like below picture.
But when I changed like below, it worked!
The object was not text ?
#define MAIN_WINDOW 0 for(int k=0;k<ObjectsTotal(0,MAIN_WINDOW);k++)
Cromo #: I thought the object was text because it shows "Object Text" like below picture.
Irrelevant.
#define MAIN_WINDOW 0 for(int k=0;k<ObjectsTotal(0,MAIN_WINDOW, OBJ_TEXT);k++) { ob_name = ObjectName(k);
- Assume you have only some other objects (count ≥ 2) and then two text objects in that order.
- You ask for how many text objects; answer two.
- You loop from [0 … 1] (over two). How many text objects will you find?
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I want to pick up some text from the Object.
But Object name has some time stamp, so I just want to pick up if the label contains some letters.
For example,
Object name is "DE1200"
sometimes it is "DE1233"
So how can I read text from the object? It contains "DE", so my code is below.
Do you have a good solution ?