Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Simple Code to make an object disappear after being touched by price

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

    Simple Code to make an object disappear after being touched by price

    Hi there, I hope you are well.

    I was wondering if someone had an example of code that could be used to make an object disappear in case of price touching it.

    Example:
    Use case example: draw lines at resistance and support levels
    IF line is touched by price THEN make line disappear, and send out an alert.

    I know how to delete the object, but i am wondering if you have any advice on how you would approach storing the line price (array?) and comparing it with current price.

    Apologies if it's a bit of a newbie question, just trying to find the most efficient code to do so.

    Thanks in advance.

    Gabriele

    #2
    Hello Gabriele,

    Welcome to the NinjaTrader forums!

    I'm not aware of any examples with this exact custom logic you are describing. This thread will remain open for any community members that would like to provide sample code.

    If you have the drawing object saved to a variable, you can check the anchor price (or y-intercept between anchors) and then call RemoveDrawObject() with the tag name supplied.



    private Line myLine;

    myLine = (this, "tag1", false, 10, 1000, 0, 1001, Brushes.LimeGreen, DashStyleHelper.Dot, 2);

    if (myLine != null && Close[0] >= myLine.StartAnchor.Price)
    {
    RemoveDrawObject(myLine.Tag);
    }
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    648 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    369 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    108 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    573 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    575 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X