Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to stop Drawing Tool Anchor from dragging further than a specific barIdx

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

    How to stop Drawing Tool Anchor from dragging further than a specific barIdx

    Hello all,

    My drawing tool has two anchor points. The tool is point and click that plots a moving average starting from the users bar of choice, then automatically sets the endAnchor at the current bar; however, the user can click and move either start or endAnchor after they have been set. The issue arising is when I grab the startAnchor and move it further right, past the endAnchor the drawing disappears an I cannot click it anymore and vice versa with dragging the endAnchor further left, past the startAnchor.

    What I am aiming for is not allowing the anchors to cross each other. I was thinking doing something like creating a barrier where the anchor cannot move past a bar index no matter how much you try to drag it past. I am not even sure if that is possible but I would like to hear any suggestions or examples of how I might accomplish this. Thanks.

    #2
    Hello Don22Trader1,

    Thank you for your post.

    What if you add some sort of check when an anchor is clicked where first, you save the current anchor location. Next, you compare the new location and compare it to see if it is beyond the desired value (such as moving the startAnchor to an x value greater than the endAnchror or moving the endAnchor to an x value less than the startAnchor) and, if so, rather than confirming the new anchor value you could set the logic to keep the anchor in place at the current anchor location when it was first clicked.

    This is just conceptual; please feel free to share a snippet of your script so we can get a better understanding of how your script works and assist you further.

    Thank you for using NinjaTrader.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    597 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    343 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    556 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    555 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X