Number of indicators on chart?

 

Hello

I want to count how many indicators on window 0 (not sub window), i searched for an instruction to show that, but i did not find. So any help to count no. of indicators on the main chart?

Thanks.

 
fx2013: I want to count how many indicators on window 0 (not sub window), i searched for an instruction to show that, but i did not find.
  1. Why do you want to know?
  2. There isn't any.
 
WHRoeder:
  1. Why do you want to know?
  2. There isn't any.

I am doing indicator and that has objects and as you know the object has its won name. when i drop the indicator on the chart and drop it again it will not, because the indicator see the same object name, so the solution is to make external variable to change the object name, but i want to make automatically, how?, it will counting the same indicator name and add it as a variable to the object name, when deinitialize indicator it will decrease the number of indicators with same name.

for that reason i want instruction.

 
fx2013:

I am doing indicator and that has objects and as you know the object has its won name. when i drop the indicator on the chart and drop it again it will not, because the indicator see the same object name, so the solution is to make external variable to change the object name, but i want to make automatically, how?, it will counting the same indicator name and add it as a variable to the object name, when deinitialize indicator it will decrease the number of indicators with same name.

for that reason i want instruction.

Look at the Objects already on the chart and name the new Objects accordingly.
 
fx2013: I am doing indicator and that has objects
Why are you using objects instead of buffers?
 
WHRoeder:
Why are you using objects instead of buffers?

Because i am drawing one vertical line at certain date and few of short trend lines but horizontally.
 
double Var;
 
int init()

{
if(GlobalVariableCheck("count")==true)
 {
 
   Var=GlobalVariableGet("count");
   Var=Var+1;
   GlobalVariableSet("count",Var);
 }
  else
  {
  Var=1;
  GlobalVariableSet("count",Var);
  }
 
 
   return(0);
  }



int deinit()
  {

   ObjectsDeleteAll();
   Var=Var-1;
   
   return(0);
  }

Look at the codes above, that is a one solution i had to count the same indicator dropped on the chart and to change the object name, but the problem is, when i change from timeframe to another the variable increases its value .

So, how to make the variable to be constant and does not change with timeframe

 
RaptorUK:
Look at the Objects already on the chart and name the new Objects accordingly.

When you drop the Indicator on the chart it looks for Text Objects whose name starts with Index, it loops through these until it finds Index_xxx where xxx is the highest value, it then uses xxx+1 as it's index for its Object names and draws a new Text Object at price = 0.0 Time = 0 with a name of Index_yyy where yyy = xxx+1

The issue with a scheme like this is that when MT4 is restarted all the Indicators will be trying to do the same thing, find out what Objects are on the chart and take the next index, the issue is that two or more will get the same Index, you could use a mutex to handle this or perhaps a very short random delay within init()
Reason: