> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ninjatrader.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ninjatrader.com/_mcp/server.

# ChartAnchor

## Definition

Defines objects used by Drawing Tools which represent a point on the chart where the Drawing Tool is located.

## Syntax

`class ChartAnchor`

## Constructors

| Constructor                                                                                                                                     | Description                                                                                                                  |
| ----------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| **new ChartAnchor()**                                                                                                                           | Initializes a new instance of the ChartAnchor object                                                                         |
| **new ChartAnchor(DateTime time, double price, [ChartControl](/developer/desktop-sdk/references/common/charts/chartcontrol))**                  | Initializes a new instance of the ChartAnchor object using time, price, and relative chart control                           |
| **new ChartAnchor(DateTime time, double yValue, int currentBar, [ChartControl](/developer/desktop-sdk/references/common/charts/chartcontrol))** | Initializes a new instance of the ChartAnchor object using time, y-axis coordinates, current bar, and relative chart control |

## Methods and Properties

| Method/Property                                                                                             | Description                                                                              |
| ----------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| **[CopyDataValues()](/developer/desktop-sdk/references/drawing-tools/chartanchor/copydatavalues)**          | Copies the ChartAnchor time and price values from one anchor to another                  |
| **[DisplayName](/developer/desktop-sdk/references/drawing-tools/chartanchor/displayname)**                  | A **string** value which sets the name prefix used for all properties for a chart anchor |
| **[DrawingTool](/developer/unsorted/drawingtool)**                                                          | The drawing tool which owns a chart anchor                                               |
| **[DrawnOnBar](/developer/desktop-sdk/references/drawing-tools/chartanchor/drawnonbar)**                    | Gets the current bar value that the chart anchor is drawn by a NinjaScript object.       |
| **[GetPoint()](/developer/desktop-sdk/references/drawing-tools/chartanchor/getpoint)**                      | Returns a chart anchor's data points.                                                    |
| **[IsBrowsable](/developer/desktop-sdk/references/drawing-tools/chartanchor/isbrowsable)**                  | A bool value determining if the anchor is visible on the UI.                             |
| **[IsEditing](/developer/desktop-sdk/references/drawing-tools/chartanchor/isediting)**                      | A bool value determining if the anchor is currently being edited                         |
| **[IsNinjaScriptDrawn](/developer/desktop-sdk/references/drawing-tools/chartanchor/isninjascriptdrawn)**    | Indicates if the chart anchor was drawn by a NinjaScript object                          |
| **[IsXPropertiesVisible](/developer/desktop-sdk/references/drawing-tools/chartanchor/isypropertyvisibile)** | A bool value determining if the X properties are visible on the UI                       |
| **[IsYPropertyVisible](/developer/desktop-sdk/references/drawing-tools/chartanchor/isypropertyvisibile)**   | A bool value determining if the Y data value is visible on the UI                        |
| **[MoveAnchor()](/developer/desktop-sdk/references/drawing-tools/chartanchor/moveanchor)**                  | Moves a Chart Anchor's x and y values from start point by a delta point amount.          |
| **[MoveAnchorX()](/developer/desktop-sdk/references/drawing-tools/chartanchor/moveanchorx)**                | Moves an anchor's x values from start point by a delta point amount                      |
| **[MoveAnchorY()](/developer/desktop-sdk/references/drawing-tools/chartanchor/moveanchory)**                | Moves an anchor's y values from start point by a delta point amount                      |
| **[Price](/developer/desktop-sdk/references/drawing-tools/chartanchor/price)**                              | Determines the price value the chart anchor is drawn.                                    |
| **[SlotIndex](/developer/desktop-sdk/references/drawing-tools/chartanchor/barindex)**                       | Indicates the nearest bar slot where the anchor is drawn.                                |
| **[Time](/developer/desktop-sdk/references/drawing-tools/chartanchor/chartanchor-time)**                    | Determines the date/time value the chart anchor is drawn.                                |
| **[UpdateFromPoint()](/developer/desktop-sdk/references/drawing-tools/chartanchor/updatefrompoint)**        | Updates an anchor's x and y values from a given point (in device pixels)                 |
| **[UpdateXFromPoint()](/developer/desktop-sdk/references/drawing-tools/chartanchor/updatexfrompoint)**      | Updates an anchor's X values from a given point (in device pixels)                       |
| **[UpdateYFromPoint()](/developer/desktop-sdk/references/drawing-tools/chartanchor/updateyfrompoint)**      | Updates an anchor's Y value from a given point (in device pixels)                        |

## Examples

```csharp

public ChartAnchor MyAnchor { get; set; } // declares the "MyAnchor" ChartAnchor object
public override IEnumerable<chartanchor> Anchors { get { return new[] { MyAnchor }; } } //adds the "MyAnchor" ChartAnchor object to a collection of anchors used to interact with your anchors
protected override void OnStateChange()
{
   if (State == State.SetDefaults)
   {
     Description = @"Drawing tool example";
     Name = "SampleDrawingTool";

     MyAnchor = new ChartAnchor(); //creates a new instance of the ChartAnchor object
     MyAnchor.IsEditing = true;
     MyAnchor.DrawingTool = this;
     MyAnchor.IsBrowsable = false;
   }
}

public override void OnMouseUp(ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale, ChartAnchor dataPoint)
{
   if (DrawingState == DrawingState.Editing)
   {
     if (MyAnchor.IsEditing)
     {
         //if anchor is editing, update anchor point
         dataPoint.CopyDataValues(MyAnchor);
     }
   }

```