Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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
    Brandon H.NinjaTrader Customer Service

    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
        Brandon H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Pep de lou, Today, 08:14 PM
        2 responses
        12 views
        0 likes
        Last Post bltdavid  
        Started by fingers, 12-15-2023, 08:44 AM
        6 responses
        133 views
        0 likes
        Last Post bltdavid  
        Started by algospoke, 05-13-2024, 06:53 PM
        4 responses
        30 views
        0 likes
        Last Post algospoke  
        Started by dtl-saw, 12-29-2022, 09:12 AM
        46 responses
        3,191 views
        1 like
        Last Post sonia0101  
        Started by AlphaOptions, 06-18-2013, 08:24 AM
        7 responses
        2,186 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X