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

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.
    Emily C.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by rhyminkevin, Today, 04:58 PM
    3 responses
    47 views
    0 likes
    Last Post Anfedport  
    Started by iceman2018, Today, 05:07 PM
    0 responses
    5 views
    0 likes
    Last Post iceman2018  
    Started by lightsun47, Today, 03:51 PM
    0 responses
    7 views
    0 likes
    Last Post lightsun47  
    Started by 00nevest, Today, 02:27 PM
    1 response
    14 views
    0 likes
    Last Post 00nevest  
    Started by futtrader, 04-21-2024, 01:50 AM
    4 responses
    50 views
    0 likes
    Last Post futtrader  
    Working...
    X