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

Getting all manually drawn objects on a chart using C#

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

    Getting all manually drawn objects on a chart using C#

    Hi!

    I am trying to figure out if there is a way to get all manually drawn objects (or just lines) on a chart using C# so I can relay that to a db for other users to see.

    Is there a way to do the detection part ? The second part, db population, is not a problem.

    Thanks​​

    #2
    Hello z679Gju,

    Thanks for your post.

    You could loop through the DrawObjects collection to get manually drawn objects on a chart window.

    See the help guide documentation below for more information about the DrawObjects collection and sample code demonstrating looping through the collection to find specific draw objects.

    DrawObjects: https://ninjatrader.com/support/help...rawobjects.htm
    IDrawingTool: https://ninjatrader.com/support/help...rawingtool.htm
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Excellent this is exactly what I was looking for thanks!

      Comment


        #4
        It seems this collection gets all objects created after the indicator was loaded. Is there a way to load all objects even those created before adding the indicator ? I would like this to be persistent.

        Comment


          #5
          Hello z679Gju,

          Thanks for your notes.

          Looping through the DrawObjects collection will get all lines drawn on the chart both before the indicator was added to the chart and after the indicator is added to the chart.

          For example, if we draw two lines on the chart manually, the tag name of this first line would be "Line" and the tag name of the second line would be "Line 2".

          If we enable the indicator that loops through the DrawObjects collection on the chart after drawing the lines we could see the information of both lines drawn before the indicator was added.

          The prints might look something like:

          Line Object: Line Manually Drawn: True
          Line Object: Line 2 Manually Drawn: True


          Here is a demonstration video showing this: https://brandonh-ninjatrader.tinytak...MF8yMjk1OTg0Mw

          Please also note the following from the DrawObjects help guide:

          "When reloading NinjaScript, all objects (including manual drawing tools) are reloaded at the same time. There is no guarantee a manually drawn object will be added to the DrawObjects collection before an indicator starts processing data."

          "DrawObjects.ToList() is thread safe. DrawObjects collection itself is still dynamic (meaning it updates live) and as a result you can still run the risk of the collection being modified while you try to read it (and thus would see the related C# log entry) However, DrawObjects.ToList() is a snapshot of DrawObjects collection at the time the call is made."

          DrawObjects: https://ninjatrader.com/support/help...rawobjects.htm
          Brandon H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Jimmyk, 01-26-2018, 05:19 AM
          6 responses
          835 views
          0 likes
          Last Post emuns
          by emuns
           
          Started by jxs_xrj, 01-12-2020, 09:49 AM
          6 responses
          3,291 views
          1 like
          Last Post jgualdronc  
          Started by Touch-Ups, Today, 10:36 AM
          0 responses
          11 views
          0 likes
          Last Post Touch-Ups  
          Started by geddyisodin, 04-25-2024, 05:20 AM
          11 responses
          62 views
          0 likes
          Last Post halgo_boulder  
          Started by Option Whisperer, Today, 09:55 AM
          0 responses
          9 views
          0 likes
          Last Post Option Whisperer  
          Working...
          X