drawTextAbsolute()
drawTextAbsolute(xBar, yValue, Text, [FGColor], [BGColor], [Flags], [FontName], [FontSize], [TagName], [cx], [cy])
This function is used to draw text on the chart. Unlike the drawTextRelative() function, the text will remain at the xBar position you specify. As new bars come in, the text will remain in place even as the bars shift to the left. 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 combination with 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 numbers 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.
- cy == 0 uses size of text.
See PixelSpacingEx.efs in the Help Examples from the EFS Library for a detailed formula example.
Examples:
//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 remain at bar positions 0 through -9 for (x = 0; x < 10; x++) { drawTextAbsolute( -x, 55.0, "Dog", Color.blue, null, Text.ONTOP | Text.CENTER, "Courier", 10, x ); } //This will display the text in the form of a frame on your chart drawTextAbsolute( -x, 55.0, "Dog", Color.blue, null, Text.FRAME, "Courier", 10, x ); //This will display the text in the form of a button on your chart drawTextAbsolute( -x, 55.0, "Dog", Color.blue, null, Text.BUTTON, "Courier", 10, x ); //This will display a button that, when clicked, takes the user to a web site drawTextAbsolute( -x, 55.0, "eSignal@URL=http://www.esignal.com", Color.blue, null, Text.BUTTON, "Courier", 10, x ); //This will display a button that, when clicked, calls a button-handler function drawTextAbsolute( -x, 55.0, "Move Bar@URL=EFS:MyCallBack1", Color.blue, null, Text.BUTTON, "Courier", 10, x ); //Elsewhere in your EFS script you would write your button-handler functions as follows: function MyCallBack1(nButtonPressed) { if (getButtonPressed(nButtonPressed) == 1) { //Our button was pressed so do something here } return; } function getButtonPressed(nButtonPressed) { //We only want to know if left mouse button was pressed if (nButtonPressed == BUTTON_LEFT) { return 1; } return 0; }