Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Anchor Y value from Text object

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Anchor Y value from Text object

    I'm just trying to store the Anchor Y price value so I can store it as a variable...

    Code:
    // this works:
    DrawObjects["theObjectName"].Tag
    DrawObjects["theObjectName"].GetType().Name
    
    // doesn't work:
    DrawObjects["theObjectName"].Anchor.Price
    I spent hours searching & reading through these articles, but too noob to figure it out... this got me close but still no luck:


    Thanks

    #2
    Hello squarewave,

    Thanks for your post.

    I have attached a simple example script to this forum post that you could view which demonstrates getting the Anchor.Price from a Draw.Text() object drawn on the chart.

    Or, you could loop through the DrawObjects collection to find specific Draw objects and then print out the Anchor.Price of that specific Draw object. An example of this could be found in the third sample code section of the DrawObjects help guide page below.

    DrawObjects: https://ninjatrader.com/support/help...sub=DrawObject
    Attached Files
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Thanks, I'll go through that script to see what I can learn & improve on!

      Since my initial post I kept trying to figure it out, and finally got something that worked. The main issue was the text was being loaded onto my chart from a different indicator that I didn't code & don't have access to.

      But the below worked, although not sure how efficient it is since it loops through several anchors but they are all the same value in this scenario so it works for me:

      Code:
      foreach (ChartAnchor anchor in DrawObjects["theObjectName"].Anchors)
      { myVariable = anchor.Price; }

      Comment


        #4
        Adding this here for future personal reference, I was trying to reference a tag name in a strategy I was coding. I had manually transcribed the tag name from the chart (since I needed an objects anchor value derived from an indicator that I didn't write or have access to).

        But my code to reference the tag name wouldn't work. Eventually I figured out the tag name that I had manually transcribed from the chart tricked me (or rather the stupid font).

        The chart font made the stinking (i) look like an (L)... except it was capital (I) mistaken for lower case (l)

        Finally figured it out after troubleshooting for a bit, eventually solved by using the code below to output the tag name to output window, where I could actually copy & paste the tag name:

        Code:
        // fetch all draw object items (type name & object tag name)
        foreach ( DrawingTool draw in DrawObjects.ToList() )
        { Print( "Type = " + draw.GetType().Name + " // Tag = " + draw.Tag ); }

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        633 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        364 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        567 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        568 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X