IDrawingTool

View as Markdown

Definition

Represents an interface that exposes information regarding a drawn chart object.

IDrawingTool Properties are standard properties that are shared by all drawing tools.

Each specific IDrawingTool will have its own uniquely named ChartAnchor representing where the object was drawn on the chart. The name and number of ChartAnchors will be specific to that drawing tool (e.g., StartAnchor, EndAnchor, etc.), however the fields available will be the same (e.g., BarsAgo, DrawnOnBar, etc.). Details on those shared fields are outlined in the ChartAnchor Properties section toward the bottom of this topic.

For implementing a custom Drawing Tool project, please see the DrawingTools section of this help guide.

IDrawingTool Properties

ParameterDescription
AnchorsA read-only collection of all of the IDrawingTool’s ChartAnchor
AttachedToAn enum determining where the drawing tool is attached. Possible values are: AttachedToType.Bars, AttachedToType.GlobalInstrument, AttachedToType.Indicator, AttachedToType.Strategy
DrawingStateThe current DrawingState of the drawing tool
DrawnByAn object value indicating which type of NinjaScript the drawing tool originated (null if user drawn)
IsAttachedToNinjaScriptA read-only bool indicating if the drawing tool is attached to an indicator or strategy
IgnoresUserInputA read-only bool determining if the drawing tool can be interacted with by the user.
IsGlobalDrawingToolA bool determining if the drawing tool displays on all charts of the instrument
IsLockedA bool determining if the drawing tool can be moved
IsSeparateZOrderA bool determining if the drawing tool will reside on a different ZOrder from the NinjaScript object it was drawn
IsUserDrawnA read-only bool indicating if drawing tool was manually drawn by a user
PanelIndexAn int value representing the panel the drawing tool resides
SupportsAlertsA read-only bool indicating if the drawing tool can be used for creating an alert
TagA string value representing the unique ID of the draw object. (Global draw objects will have an ”@” added as a prefix to the string)
ZOrderTypeAn enum indicating the order in which the drawing tool will be drawn. Possible values are: DrawingToolZOrder.Normal, DrawingToolZOrder.AlwaysDrawnFirst, DrawingToolZOrder.AlwaysDrawnLast

ChartAnchor Properties

ParameterDescription
<chartanchor>.BarsAgoAn int representing the “barsAgo” value that was passed to the Draw method. Note: This value will NOT be set for objects drawn manually
<chartanchor>.DisplayNameA string representing name of the DrawingTool’s chart anchor that is displaying on the UI
<chartanchor>.DrawingToolThe IDrawingTool object which created the DrawingTool’s chart anchor object
<chartanchor>.DrawnOnBarAn int representing the CurrentBar value that the DrawingTool’s chart anchor was drawn
<chartanchor>.IsNinjaScriptDrawnA bool indicating the object was drawn programmatically
<chartanchor>.PriceA double representing the price the DrawingTool’s chart anchor was drawn
<chartanchor>.SlotIndexA double representing the DrawingTool’s chart anchor index value the anchor was drawn
<chartanchor>.TimeA DateTime representing the time value the DrawingTool’s chart anchor was drawn

Examples

1Text myText;
2protected override void OnBarUpdate()
3{
4 if(CurrentBar == 50)
5 myText = Draw.Text(this, "tag", "test", 0, High[0]);
6
7 if(myText != null)
8 {
9 Print(myText.Anchor.DrawnOnBar); // drawn on bar 50
10 }
11}