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 jxs_xrj, 01-12-2020, 09:49 AM
    6 responses
    3,290 views
    1 like
    Last Post jgualdronc  
    Started by Touch-Ups, Today, 10:36 AM
    0 responses
    8 views
    0 likes
    Last Post Touch-Ups  
    Started by geddyisodin, 04-25-2024, 05:20 AM
    8 responses
    61 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by Option Whisperer, Today, 09:55 AM
    0 responses
    8 views
    0 likes
    Last Post Option Whisperer  
    Started by halgo_boulder, 04-20-2024, 08:44 AM
    2 responses
    24 views
    0 likes
    Last Post halgo_boulder  
    Working...
    X