Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Modify ChartObjects programmatically

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

    Modify ChartObjects programmatically

    Hello!

    I need to scan all the text ChartOjects drawn by an indicator and change their outline and area brushes on some conditions.

    I was considering starting with the following:
    Code:
    foreach (DrawingTool text in DrawObjects.ToList())
    but then I don't know how to access those attributes.

    In general, how can I change text box attributes from a script?

    #2
    Hello Gianpiero,

    Thanks for your post.

    To find specific draw objects on a chart you could loop through the DrawObjects collection. It would also be possible to loop through the DrawObjects collection to find a drawing object by a specific tag name. Once you find the drawing object you want, you could modify that drawing object's properties.

    See this help guide page for more information about the DrawObjects collection and sample code for looping through this collection to find drawing objects on a chart window: https://ninjatrader.com/support/help...rawobjects.htm

    You could also view the attached example script that demonstrates getting specific properties of a drawing object which you might find helpful.

    Please let me know if I may assist further.
    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
      Thank you, that helped me a lot. However, something still doesn't add up.

      I wrote this simple code:
      Code:
              protected override void OnBarUpdate()
              {
                  foreach    ( DrawingTool draw in DrawObjects.ToList())
                  {
                      if ( draw is DrawingTools.Text)
                      {
                          DrawingTools.Text testo = draw as DrawingTools.Text;
                          Print("Tag: " + testo.Tag );
                      }
                  }
              }​
      , still nothing prints in the NinjaScript output window.

      What am I missing?

      Comment


        #4
        Hello Gianpiero,

        Thanks for your note.

        I do not see anything incorrect standing out in the code you shared. That said, I do not see where you are calling Draw.Text() to draw text on a chart. Keep in mind that if there is no text drawn on the chart, no prints will appear in the Output window when running the script.

        Attached you will find a sample script demonstrating how to print out the Tag name of Text drawing objects that are drawn from the script or manually drawn. You could compare this script to your script to see where the differences might be.

        Please let me know if I may assist further.
        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

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        637 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        366 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        107 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        569 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        571 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X