Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Processing HandDrawn Lines/Rays in a large collection of Draw Objects

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

    Processing HandDrawn Lines/Rays in a large collection of Draw Objects

    I have quite a large number of Ninjascript generated draw objects, and just a few Hand Drawn Objects at any time.

    However, I need to scan for these hand drawn objects often and am finding that there is a performance issue here.

    In that I have to loop through the entire collection to find one or two HandDrawn objects.

    Any ideas?


    One of my exit methods is to use HandDrawn Horizontal and Ray lines as a Price Target.. When the price hits the line, it exits the position. Works really well.

    #2
    Hello llanqui,

    Thank you for your post.

    If you have the tag name of the drawing object, you can look up the drawing object directly using the tag name.

    Code:
    protected override void OnBarUpdate()
    {
    if (DrawObjects["someTag"] != null && DrawObjects["someTag"] is DrawingTools.Line)
    {
    // Do something with the drawing tool line
    }
    
    // An alternative approach to find the draw object by a tag
    if (DrawObjects["someTag"] as DrawingTools.Line != null)
    {
    // Do something drawing tool line
    }
    
    // Yet another way to find a drawing tool by a tag
    if (DrawObjects["someTag"].GetType().Name == "Line")
    {
    // Do something drawing tool line
    }
    }
    Otherwise, if you do not have the tag name or this approach won't work for you, the only alternative I can think of is looping through the collection of drawing objects and checking if they are user drawn or not.

    Please let us know if you have any further questions. ​
    Last edited by NinjaTrader_Gaby; 05-07-2024, 06:15 AM.

    Comment


      #3
      that should work, thanks

      Comment


        #4
        will wild card work?

        Comment


          #5
          1) I have a request....that the Hand Drawn lines have their own collection....they could remain in the current collection but the new collection would only contain hand drawn....the two lists would be kept in synch automatically

          2) provide Events when a Draw Object is Hand Drawn or Removed, with access to its properties

          Comment


            #6
            Hello llanqui,

            I don't believe there is a built-in way to reference an drawing object by the use of a wild card. The tag name of the drawing object must be referenced.

            Thank you for your suggestion. I will submit a feature request to our team and follow up with the tracking number once it has been created.

            Comment


              #7
              Hello llanqui,

              Your first request is being tracked with SFT-6295 and your second request is being tracked at SFT-6296.

              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 on the Release Notes page of the Help Guide.

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

              Additionally, my colleague informed me that you can use the following to get just user drawn objects out of the collection:

              Code:
              List<IDrawingTool> objects = DrawObjects.Where(t => t.IsUserDrawn).ToList();

              Comment


                #8
                ok, thank you

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                558 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                324 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                545 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                547 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X