Requests & Ideas - page 683

 
mladen:
Check your LabelXDistance and LabelYDistance variables

Here in attachment the source of the code. Could you please have a look?

Many thanks 

Files:
 
zephyrus:

Here in attachment the source of the code. Could you please have a look?

Many thanks 

If you hide parameters, then they shall always have constant value

Use the attached and change in the parameters the distances to desired distances

Files:
 
mladen:

If you hide parameters, then they shall always have constant value

Use the attached and change in the parameters the distances to desired distances

To be honest the counter appear even with hide parameters. The problem is that values don'tupdate if I reload the indicator and the counter of the first chart (eur/usd) is replicate to the other charts:

 

 
zephyrus:

To be honest the counter appear even with hide parameters. The problem is that values don'tupdate if I reload the indicator and the counter of the first chart (eur/usd) is replicate to the other charts:

 

Please read my previous post : change the value of those two parameters the same as in any other indicator and you can place it anywhere you want

 
mladen:

Please read my previous post : change the value of those two parameters the same as in any other indicator and you can place it anywhere you want

I did as you suggested but nothing changed, the arrows appear but the counter not:

  

 

 
zephyrus:

I did as you suggested but nothing changed, the arrows appear but the counter not:

  

 

It works as it is supposed to work.

#property indicator_chart_window
#property indicator_buffers 0

extern color   LabelColor      = Yellow;
extern int     LabelFontWidth  = 16;
extern int     LabelCorner     =  1;
extern int     LabelYDistance  =  0;
extern int     LabelXDistance  =  0;

int init()   { return(0);}
int deinit() { return(0);}
int start()
{
   string counter="test",name="test";
   ObjectCreate(0,name,OBJ_LABEL,0,0,0);
   ObjectSetText(name,counter,LabelFontWidth,NULL,LabelColor);
   ObjectSet(name,OBJPROP_XDISTANCE,LabelXDistance);
   ObjectSet(name,OBJPROP_YDISTANCE,LabelYDistance);
   ObjectSet(name,OBJPROP_CORNER,LabelCorner);  
   return(0);


Check the rest of your code

 
mladen:

It works as it is supposed to work.

#property indicator_chart_window
#property indicator_buffers 0

extern color   LabelColor      = Yellow;
extern int     LabelFontWidth  = 16;
extern int     LabelCorner     =  1;
extern int     LabelYDistance  =  0;
extern int     LabelXDistance  =  0;

int init()   { return(0);}
int deinit() { return(0);}
int start()
{
   string counter="test",name="test";
   ObjectCreate(0,name,OBJ_LABEL,0,0,0);
   ObjectSetText(name,counter,LabelFontWidth,NULL,LabelColor);
   ObjectSet(name,OBJPROP_XDISTANCE,LabelXDistance);
   ObjectSet(name,OBJPROP_YDISTANCE,LabelYDistance);
   ObjectSet(name,OBJPROP_CORNER,LabelCorner);  
   return(0);


Check the rest of your code

Mladen, thanks for your support but maybe there was a misunderstanding. I'm able to add the text on the chart, it works...but what i'm trying to ask for is to implement a dynamic text (like the counter in the previous images) and not a static one (like "Text"). What I'm looking for is a counter that increase the number of the win trade if an arrow appear on the chart (for example).
 
zephyrus:
Mladen, thanks for your support but maybe there was a misunderstanding. I'm able to add the text on the chart, it works...but what i'm trying to ask for is to implement a dynamic text (like the counter in the previous images) and not a static one (like "Text"). What I'm looking for is a counter that increase the number of the win trade if an arrow appear on the chart (for example).
That is what I was telling to you : your original question was to place the label at any position on chart. That question of yours is answered and the solution works. So, the error is in the rest of the code and you should clean your code up
 
mladen:
That is what I was telling to you : your original question was to place the label at any position on chart. That question of yours is answered and the solution works. So, the error is in the rest of the code and you should clean your code up

The question was "If a special condition is satisfied then it should update the win and the percent global variable , otherwise it should only update the OTM. I would like this counter appear as soon as i put my indicator on the chart and that it updates itself for each satisfied conditions".

But it's ok, even though I don't understand how to clean up my code, otherwise i didn't ask for help

 
zephyrus:

Hi All,

 

I want to insert in my custom indicator a counter like this one:

 

 

If a special condition is satisfied then it should update the win and the percent global variable , otherwise it should only update the OTM.

 

I would like this counter appear as soon as i put my indicator on the chart and that it updates itself for each satisfied conditions.

 

I created something like the code below outside the start() function, then I call this custom function inside the start() before the return command:

 

void AddLabelsCounter(int limitj)
{  
   string name = StringConcatenate(UniqueID,"_Labels");
  
   for(int i=limitj; i>0; i--)
   {
      if(*special condition verified*)
      {
         count++;
         win++;
      }
      else
      {
         count++;
         lost++;
      }
      
      double perc_temp=win/count*100;
      perc=NormalizeDouble(perc_temp,2);
      
   string counter=StringConcatenate("Total: ",count," Win: ",win," Lost: ",lost," Perc: ",perc,"%");
  
   ObjectCreate(chart_id,name,OBJ_LABEL,0,0,0);
   ObjectSetText(name,counter,LabelFontWidth,NULL,LabelColor);
   ObjectSet(name,OBJPROP_XDISTANCE,LabelXDistance);
   ObjectSet(name,OBJPROP_YDISTANCE,LabelYDistance);
   ObjectSet(name,OBJPROP_CORNER,LabelCorner);  
   }
}

 But it seems doesn't work since the label appear at the beginning (the same label for each chart) and never change

 

What should I put under init(), deinit(),start() and out of them?