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

Order of DrawObjects

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

    Order of DrawObjects

    Hello,

    In the NinjaTrader documentation, it states that the collection DrawObjects is updated live. I have an indicator that pulls the last drawn object (DrawObjects.Last()). This works for user drawn objects, but objects that are drawn by the indicator do not get added last. Sequentially printing out the objects in DrawObjects, I notice that indicator drawn objects are always added first and user drawn objects last. Is there any way to shift the indicator drawn object to the back of the list?

    DrawObjects.Add() (which adds elements last) seems to be disabled, probably intentional as NT handles how objects are added to the list.
    Unsuitable
    NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

    #2
    Hello Unsuitable,

    Below is a link to the help guide on the DrawObjects collection.


    This collection will contain objects at the moment of time the collection is accessed.

    Be use to use .ToList() to ensure this is thread safe.

    You can sort a list once this is saved to a list. You could write a loop that passes twice and adds the items where IsUserDrawn is true, and then items where IsUserDrawn is false to sort these. You could write some custom linq in C# to sort by the IsUserDrawn property.

    It would not be supported to call DrawObjects.Add() to add to this collection. NinjaTrader does control adding objects this collection.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello ChelseaB we meet again,

      Well, it doesn't matter whether the objects are user drawn or not. In fact, I specifically set the DrawnBy to null on the items drawn by an indicator so that it stays on the chart when refreshing the indicator. That is a good point that I should make thread-safe by incorporating a list. With that said, does the draw objects contain any information when the object created? Because coverting the drawobject collection to a list will return the order the collection was in. For the list to be "sorted", it would need to be in order the items were created.

      Thanks
      Unsuitable
      NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

      Comment


        #4
        Hello Unsuitable,

        I am not aware of a CreationDate property for drawing objects. I could submit a feature request for this if you would like.

        Currently, objects are added to the collection as they are read from various sources such as workspaces and indicators. The order of these is not guaranteed as some things are happening asynchronously.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello ChelseaB,

          It's not a crazy feature that I need. The reason I ask this is my color picker tool changes the color of the last drawn object by default. So if an object is drawn by another indicator, then technically that's the last drawn object. With that said, a template can be set for the objects drawn by the indicator so in theory the user doesn't need to set that color. Plus if the user really wants to set the color of an object drawn by the indicators, they can select it. If an item's .isSelected is set to true it will change the color of that objects and not the last drawn object.

          It would be nice as the DrawObjects list is not sorted by creation date and .Last() does not refer to the last object drawn. Perhaps a feature request to find the last drawn object, user drawn, or indicator. Although, saving objects to the chart independent of an indicator is a much bigger priority (talking about another thread).

          Thanks
          Unsuitable
          NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

          Comment


            #6
            Hello Unsuitable,

            I'm not sure I am understanding.

            The user drawn objects are saved in the workspace and are saved in the order drawn in the workspace for that chart.

            The last drawn user object will be the last item in DrawObjects collection that has IsUserDrawn true. Is this what you are after?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hello ChelseaB,

              Kinda. Im after the last drawn object drawn by the indicator OR by the user. From my understading, the DrawObjects collection adds indicator drawn objects first then user drawn objects. Unfoutunatley, setting the DrawnBy property of an indicator's draw object doesn't make the DrawObjects collection treat the indicator draw object as a user drawn object.

              "DrawnBy: An object value indicating which type of NinjaScript the drawing tool originated (null if user drawn)"


              Here's what I mean:

              Click image for larger version

Name:	rhMDZ7K.gif
Views:	403
Size:	171.0 KB
ID:	1124804
              Unsuitable
              NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

              Comment


                #8
                Hello Unsuitable,

                There is no guaranteed order for these in the DrawObjects collection. You will have sort your list yourself.

                I am happy to submit a feature request for a date property accessible in NinjaScript if you would like.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Hello ChelseaB,

                  That would be great! I imagine nobody else has asked for that feature request before, so it may take a while :P
                  Unsuitable
                  NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

                  Comment


                    #10
                    Hello Unsuitable,

                    I will submit that for you. Once I have a tracking ID for this request I post in this thread for future reference.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Hello Unsuitable,

                      Thank you for your patience.

                      Chelsea is out of the office today, however, we have submitted a feature request for this on your behalf. This request may be tracked under the number SFT-5117.

                      As with all feature requests, interest is tracked before implementation is considered, so we cannot offer an ETA or promise of fulfillment. If implemented, it will be noted in the Release Notes page of the Help Guide.

                      Release Notes — https://ninjatrader.com/support/help...ease_notes.htm

                      Please let us know if we may be of further assistance to you.
                      Kate W.NinjaTrader Customer Service

                      Comment


                        #12
                        Hi Kate,

                        Sounds good. It would be nice if there was a way that users could track feature requests and sends them a notification when a feature request they follow is added. I suppose that would be another feature request as well :P

                        Anyways have a good weekend Kate and Chelsea_B, hope you're doing alright.

                        Thanks
                        Unsuitable
                        NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by kaywai, Today, 06:26 AM
                        0 responses
                        1 view
                        0 likes
                        Last Post kaywai
                        by kaywai
                         
                        Started by kevinenergy, 02-17-2023, 12:42 PM
                        118 responses
                        2,778 views
                        1 like
                        Last Post kevinenergy  
                        Started by briansaul, Today, 05:31 AM
                        0 responses
                        9 views
                        0 likes
                        Last Post briansaul  
                        Started by traderqz, Yesterday, 12:06 AM
                        11 responses
                        28 views
                        0 likes
                        Last Post NinjaTrader_Gaby  
                        Started by PaulMohn, Today, 03:49 AM
                        0 responses
                        9 views
                        0 likes
                        Last Post PaulMohn  
                        Working...
                        X