1) There are numerous Objects in the chart, I am interested to get value of the object on a specific bar of the chart.
2) Object with the names, as an example, "XYZ04", "XYZ110", "XYZ005" appear on the chart, therefore I know the prefix, but I do not know the suffix which could be 112, 198, 110,13, etc.
The methodology could be:
1) Determine all the objects with suffix "XYZ" in the chart.
2) Check which one is on the specific bar and get its value.
I went through various ObjectGet, ObjectFind functions but could not put them together to get my desired result.
Appreciate help to resolve the problem
Thanks
int total=ObjectsTotal();
string obj_name="";string a1,a2;
for(int i=0;i<total;i++)
{
obj_name=ObjectName(i);
a1=StringSubstr(obj_name,0,3); // XYX
a2=StringSubstr(obj_name,3,StringLen(obj_name)-3); // 04
Print(a1," ",a2," ",ObjectDescription(obj_name)); // value XYZ04
if (obj_name=="XYZ04") Print(ObjectDescription(obj_name));
}
Amazing!! With the help of the codes and comments posted by all of you, I could come up with the required code.
Attaching a file that has the required code. If I key in the Prefix and the bar to look at, I get the value of the object if an object with the prefix is found on the specified bar.
I need the code to execute at the beginning of a new bar, after we are into the new bar for a specified time. (minutes/seconds as a variable). Some helpful code is available here, but beyond my understanding. https://www.mql5.com/en/forum/245598 - execute every minute.
Appreciate a second round of help from all of you.
Amazing!! With the help of the codes and comments posted by all of you, I could come up with the required code.
Attaching a file that has the required code. If I key in the Prefix and the bar to look at, I get the value of the object if an object with the prefix is found on the specified bar.
I need the code to execute at the beginning of a new bar, after we are into the new bar for a specified time. (minutes/seconds as a variable). Some helpful code is available here, but beyond my understanding. https://www.mql5.com/en/forum/245598 - execute every minute.
Appreciate a second round of help from all of you.
Thanks
//+------------------------------------------------------------------+//| .mq4 |//| |//+------------------------------------------------------------------+#property indicator_chart_windowexternint Shift = 15;
externstring Prefix="";
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+int init()
{
//---- indicatorsreturn(0);
}
//+------------------------------------------------------------------+//| Custom indicator deinitialization function |//+------------------------------------------------------------------+int deinit()
{
//---- //----return(0);
}
//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+bool NewBar()
{
staticdatetime lastbar;
datetime curbar = Time[0];
if(lastbar!=curbar)
{
lastbar=curbar;
return (true);
}
else
{
return(false);
}
}
int start() {
if(NewBar())
{
int length=StringLen(Prefix);
int total=ObjectsTotal();
string obj_name="";string a1,a2;
for(int i=0;i<total;i++)
{
obj_name=ObjectName(i);
a1=StringSubstr(obj_name,0,length); // XYX
a2=StringSubstr(obj_name,length,StringLen(obj_name)-length); // 04Comment("Sorry desired object not found!!");
if (a1 == Prefix && ObjectGetValueByShift(obj_name, Shift) >0){
Comment("Success!! value of ",obj_name, " = " ,ObjectGetValueByShift(obj_name,Shift));}
if (a1 == Prefix && ObjectGetValueByShift(obj_name, Shift) >0)
break ;
}
}
return(0);
}
//https://www.mql5.com/en/forum/245598 - execute every minute
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hi all,
I need help as follows:
1) There are numerous Objects in the chart, I am interested to get value of the object on a specific bar of the chart.
2) Object with the names, as an example, "XYZ04", "XYZ110", "XYZ005" appear on the chart, therefore I know the prefix, but I do not know the suffix which could be 112, 198, 110,13, etc.
The methodology could be:
1) Determine all the objects with suffix "XYZ" in the chart.
2) Check which one is on the specific bar and get its value.
I went through various ObjectGet, ObjectFind functions but could not put them together to get my desired result.
Appreciate help to resolve the problem
Thanks
int total=ObjectsTotal(); string obj_name="";string a1,a2; for(int i=0;i<total;i++) { obj_name=ObjectName(i); a1=StringSubstr(obj_name,0,3); // XYX a2=StringSubstr(obj_name,3,StringLen(obj_name)-3); // 04 Print(a1," ",a2," ",ObjectDescription(obj_name)); // value XYZ04 if (obj_name=="XYZ04") Print(ObjectDescription(obj_name)); }Amazing!! With the help of the codes and comments posted by all of you, I could come up with the required code.
Attaching a file that has the required code. If I key in the Prefix and the bar to look at, I get the value of the object if an object with the prefix is found on the specified bar.
I need the code to execute at the beginning of a new bar, after we are into the new bar for a specified time. (minutes/seconds as a variable). Some helpful code is available here, but beyond my understanding. https://www.mql5.com/en/forum/245598 - execute every minute.
Appreciate a second round of help from all of you.
Thanks
Amazing!! With the help of the codes and comments posted by all of you, I could come up with the required code.
Attaching a file that has the required code. If I key in the Prefix and the bar to look at, I get the value of the object if an object with the prefix is found on the specified bar.
I need the code to execute at the beginning of a new bar, after we are into the new bar for a specified time. (minutes/seconds as a variable). Some helpful code is available here, but beyond my understanding. https://www.mql5.com/en/forum/245598 - execute every minute.
Appreciate a second round of help from all of you.
Thanks