drawTextRelative()

eSignal EFS

drawTextRelative()

 

drawTextRelative(xBar, yValue, Text, [FGColor], [BGColor], [Flags], [FontName], [FontSize], [TagName], [cx], [cy])

 

This function is used to draw text on the chart. Unlike the drawTextAbsolute() function, the text will 'stick' to the x-axis position that it was originally written to. As new bars come in, the text will shift to the left along with the bars. The TagName parameter must be unique for each text object that is drawn on the chart. If, for example, you call the drawText() functions repeatedly in your script but you always use a TagName of "1", then only one text object will appear on your chart (the last one drawn). 

 

  • xBar:  Relative position where text should appear.
  • yValue:  y-axis value where text should appear
  • Text:  The text that should be displayed
  • FGColor:  Optional. If not provided, pass null. Foreground color of the text.
  • BGColor:  Optional. if not provided, pass null. Background color of the text
  • Flags:  Text Flags (these can be ORd together). Pass null if not using flags.
  • FontName:  Optional. If not provided, pass null. Otherwise, pass a font name (e.g, "Courier" or "Arial").
  • FontSize:  Optional. If not provided, pass null. Otherwise, pass the font size to use (e.g., 11 or 15 or 8, etc.)
  • TagName:  A unique identifier for this text object. 
  • cx:   Optional. Pixel spacing control.
  • cy:   Optional. Pixel spacing control.

 

Note re cx/cy:

 

The cx and cy parameters control the width (cx) and height (cy) of the text label. They are not very useful unless you are using them in conjunction with the text flags RELATIVETOTOP, RELATIVETOLEFT and RELATIVETOBOTTOM. Without these flags the parameters will be relative to the bar index for cx and the price scale for cy.

 

Both cx and cy require whole numbers.

 

You can pass positive or negative numbers to these parameters. If you use positive whole number then the size is based on that number of pixels:

 

cx of 15 will be the width of the text label of 15 pixels

cy of 15 will be the height of the text label of 15 pixels

 

If you use negative whole numbers then the size is relative to the specified font size:

 

cx of -15 will be the approximate width of 15 characters of the specified font

cy of -2 will be 2 times the height of the specified font. -3 would be 3 times the height, etc.

 

 

Example:

 

//This will print the word "Dog" at the $55 price level for each of the most recent 10 bars

//When new bars come in, this text will then shift to the left and remain in position with the

//10 bars it was originally displayed with.

 

for (x=0; x<10; x++) {

drawTextRelative( -x, 55.0, "Dog", Color.Blue, null, Text.ONTOP | Text.CENTER, "Courier", 10, x );

}

 

See drawTextAbsolute() for some more examples.

 

drawText Flags

drawText BUTTON Flags

Colors

drawTextAbsolute()

clearText()

removeText()