AnchorPoint

An enumeration that defines the text anchor point used for positioning text objects relative to their coordinates.

Values

Value
Description

LEFT_TOP

Anchor at the top-left corner of the text (default)

LEFT_CENTER

Anchor at the left center of the text

LEFT_BOTTOM

Anchor at the bottom-left corner of the text

CENTER_BOTTOM

Anchor at the bottom center of the text

RIGHT_BOTTOM

Anchor at the bottom-right corner of the text

RIGHT_CENTER

Anchor at the right center of the text

RIGHT_TOP

Anchor at the top-right corner of the text

CENTER_TOP

Anchor at the top center of the text

CENTER

Anchor at the center of the text

Example Usage

// Create a text object anchored at top-left
this.api.CreateChartObject('MyText', TObjectType.TEXT, 0, this.api.Time(0), this.api.Close(0))
this.api.SetObjectProperty('MyText', ObjProp.OBJPROP_ANCHOR_POINT, AnchorPoint.LEFT_TOP)
this.api.SetObjectProperty('MyText', ObjProp.OBJPROP_TEXT, 'Price Level')

// Create a text object anchored at center
this.api.CreateChartObject('CenterText', TObjectType.TEXT, 0, this.api.Time(0), this.api.Close(0))
this.api.SetObjectProperty('CenterText', ObjProp.OBJPROP_ANCHOR_POINT, AnchorPoint.CENTER)
this.api.SetObjectProperty('CenterText', ObjProp.OBJPROP_TEXT, 'Center Label')

// Create a text object anchored at bottom-right
this.api.CreateChartObject('BottomRightText', TObjectType.TEXT, 0, this.api.Time(0), this.api.Close(0))
this.api.SetObjectProperty('BottomRightText', ObjProp.OBJPROP_ANCHOR_POINT, AnchorPoint.RIGHT_BOTTOM)
this.api.SetObjectProperty('BottomRightText', ObjProp.OBJPROP_TEXT, 'Bottom Right Label')

Last updated