Display some text on top of each bar on chart

 

Hi,

Can someone please tell how to put some text vertically or diagnolly starting from the High of each bar on the current chart

I tried below code but it it showing somewhere in the middel of chart.

ObjectCreate("test",OBJ_LABEL,0,Time[1],Close[1]);
ObjectSetText("test",DoubleToStr(AccountBalance(),2),10,"Times New Roman", Red);

I can use ObjectSet but how do i know the x and y coordinates of each bar's High ?

thanks

 
A Label uses coordinates in pixels not price and time . . . OBJ_LABEL use OBJ_TEXT instead
 
And the labels don't move as new bars are created. The Text is fixed to the bar by time.
 

Hi,

I found it. Works well. thanks for all your reply

   double Vertical_Offset= Point*15;
   string Horizontal_Offset = "      ";
   ObjectCreate("data", OBJ_TEXT, 0, Time[1], High[1]+ Vertical_Offset);
   ObjectSetText("data",Horizontal_Offset+DoubleToStr(AccountBalance(),2),10,"Times New Roman", Red);
   ObjectSet("data",OBJPROP_ANGLE,50);
 

If your text varies in size there are differences in the placement. I think because of the alignment that cannot be changed. So you have to fill it up with spaces. I have been trying to get it EXACTLY above the bar in question but it does not seem to be possible. The below is the best I could do.



void alert(string message, color kleur)
  {


   double Vertical_Offset= Point*80;
   int TextLen=StringLen(message);
   for(int i=1; i<TextLen; i++)
      message = message+" ";

   if(!kleur)
     {
      kleur = Black;
     }
   string Horizontal_Offset = "";
   string objectname = "textabove" + TimeCurrent();
   ObjectCreate(objectname, OBJ_TEXT, 0, Time[0], High[0]+ Vertical_Offset);
   ObjectSetText(objectname,Horizontal_Offset+message,7,"Arial Bold", kleur);
   ObjectSet(objectname,OBJPROP_ANGLE,90);
   ObjectSetInteger(0,objectname,OBJPROP_ANCHOR,ANCHOR_LEFT_UPPER);

  }
 

Hi everyone,


I am trying to display pattern name on candlestick once found. I have tried hard but as I am not familiar with Objects/buffers I end up with nothing working out for me. I would be very grateful if someone help me to implement either a arrow or text on candlestick pattern preferably through buffers.


       double H1 = iHigh(Symbol(), TimeFrame(i),1);

         double L1 = iLow(Symbol(),  TimeFrame(i),1);

         double O1 = iOpen(Symbol(), TimeFrame(i),1);

         double C1 = iClose(Symbol(),TimeFrame(i),1);

if(Doji_Alert)

              {


               if(MathAbs(C1-O1)/(H1-L1)<0.1 && (H1-MathMax(C1,O1))>(3*MathAbs(C1-O1)) && (MathMin(C1,O1)-L1)>(3*MathAbs(C1-O1)))

                 {

                 

// DRAW ARROW OR TEXT ON CANDLESTICK

                                                              

                    Alert(EnumToString(TimeFrame(i))," ",Symbol()," DOJI ",TimeToString(tim));


                 }


               break;


              }



Thank you.

Documentation on MQL5: Constants, Enumerations and Structures / Indicator Constants / Drawing Styles
Documentation on MQL5: Constants, Enumerations and Structures / Indicator Constants / Drawing Styles
  • www.mql5.com
When creating a custom indicator, you can specify one of 18 types of graphical plotting (as displayed in the main chart window or a chart subwindow), whose values are specified in the ENUM_DRAW_TYPE enumeration. Depending on the drawing style, you may need one to four value buffers (marked as INDICATOR_DATA). If a style admits dynamic...
 
Ivo Bieleveldt thank you so much for your lovely answer. You saved my day.
Reason: