Text_FloatEx (Function)
The Text_FloatEx function is used to place text on a chart. The function creates and maintains the position of a text object based on the "XPercentFromRight" and "YPercentFromBottom" inputs. Inside the function, the XPercentFromRight and YPercentFromBottom inputs are used to create an XYPoint. This XYPoint is used to position the TextLabel that is created by the function.
Syntax
Text_Float(TextToFloat, TextColorString, TextFontName, TextFontSize, XPercentFromRight, YPercentFromBottom, ShowTextInSubgraph)
Returns (Integer)
The function always returns a value of 1 (as an integer).
Parameters
| Name | Expression | Description |
|
TextToFloat |
String | Text to be placed on the chart. |
| TextColorString | String | A string that represents the desired color of the text. See the KnownColor enum for a list of available colors. |
| TextFontName | String | The name of the font that is to be used for text objects. Example: Pass in "Arial" to have text objects appear in Arial font. |
|
TextFontSize |
Numeric | Pass in the point size of the desired font. Example: Pass in 10 for a 10 point font. |
|
XPercentFromRight |
Numeric | Pass in the percentage of the chart width that text should be offset from the right edge of the chart. Example: Pass in 60 to offset text 60% of the way from the right edge of the chart to the left edge. |
| YPercentFromBottom | Numeric | Pass in the percentage of the subgraph height that text should be offset from the bottom edge of the subgraph where the text is located. Example: Pass in 60 to offset text 60% of the way from the bottom edge of the subgraph to the top edge. |
| ShowTextInSubgraph | Boolean | Pass in true to plot text in the same subgraph as the study. Pass in false to plot in the price subgraph to which the study is applied ('Base study on' setting). |
Remarks
Every line of code that contains a call to Text_FloatEx will create a new TextLabel. So, if it is desired to change the text color, font name, font size, percent from right, or percent from bottom dynamically, then the function call should be made will variables or study inputs used as the parameters. The variables or inputs then can change, and the function called, without creating a new TextLabel. For example, if it is desired to change something like the color of the TextLabel created by this function, change the variable that specifies the color and then call the function with the variable as the color parameter (see Example section, below).
Example
This example creates a new text object with the text "Test", which has a color of White, a font of 16-point "Arial", that is located 10% of the distance from the right of the chart to the left of the chart and 80% of the distance from the bottom of the subgraph to the top of the subgraph, and is shown with the price data to which the study or strategy is applied.
Value1 = Text_FloatEx( "Test", "White", "Arial", 16, 10, 80, false);
In the following code, the color of the text is varied based on the relationship between the open and the close of the most recent bar.
variables: ColorToUseForText( "" );
if Close > Open then
ColorToUseForText = "Green"
else
ColorToUseForText = "Red";
Value1 = Text_FloatEx( "Test", ColorToUseForText, "Arial", 16, 10, 80, false);