drawTextPixel()

ICE Data Services -

drawTextPixel()
Previous  Top  Next


drawTextPixel( xVal, yVal, text, fgColor, bgColor, Flags, fontName, fontSize [, tagID] [, cx] [, cy] )

The drawTextPixel function allows you to draw text objects at any location on your chart. Any text object created with drawTextAbsolute will remain at its designated relative pixel offset from the chart margins.

Parameters

xVal
pixel offset for the text object (x-axis)
yVal
pixel offset for the text object (y-axis)
text
the symbol or text string to draw
fgColor
optional. the foreground color to use or null
bgColor
optional. the background color to use or null
Flags
optional. see Text Flags below or use null
fontName
optional. the font to use when creating the text object or null
fontSize
optional. the size of the font to use or null
tagID
optional. a unique identifier for this text object or null
cx
optional. pixel spacing control - or omitted
cy
optional. pixel spacing control - or omitted


Text Flags

Text.BOLD
display the text in bold
Text.ITALIC
display the text in italics
Text.UNDERLINE
underline the text
Text.LEFT
align the text to the left
Text.RIGHT
align the text to the right
Text.TOP
align the text to the top
Text.BOTTOM
align the text to the bottom
Text.ONTOP
draw the text on top of the study
Text.FRAME
draws a frame around the text using fgColor as the frame color
Text.BUTTON
draws the text as a button. fgColor and bgColor are ignored
Text.RELATIVETOLEFT
keeps the text fixed at a relative pixel distance from the left chart axis
Text.RELATIVETOBOTTOM
keeps the text fixed at a relative pixel distance from the bottom chart axis
Text.RELATIVETOTOP
keeps the text fixed at a relative pixel distance from the top chart axis
Text.CENTER
horizontally center the text over the bar
Text.VCENTER
vertically center the text at the series value
Text.PRESET
(new in EFS2) allows drawTextRelative to use the location flags described in the drawText function.
Note: Text flags can be ORed together to combine various attributes (e.g., Text.ITALIC | Text.BOLD | Text.UNDERLINE)


Notes re the cx and cy parameters

· 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. 


Usage

   //draw the string "My Trading System" at the lower-left corner of the chart. The text will remain fixed at a 1 pixel offset from the 
   
//left margin and a 13-pixel offset from the bottom margin. We have a assigned a unique tagID of -200 so that only one instance
   
//of this text object will be created (any new instances will automatically delete the older instances).
   drawTextPixel( 
113"My Trading System", Color.blue, null, Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM, null12, -200 );


Notes
It’s possible to use labels created by drawTextPixel as a hyperlink. To do this you should set the parameter text as 'Text  @URL = website', where website is the URL of website.

It’s possible to define mouse-button handler function for labels created by drawTextPixel. To do this you should set the parameter text as 'Text @URL = EFS:functionName', where functionName is the caption of handler, which should be defined in script, Text is text of label.
 
Note, starting with version 11.1 all mouse functions require the use of the Shift key when called from the chart. This change was done to avoid conflicts between EFS and chart mouse events (such as right clicking or double clicking) without compromising any backwards compatability.