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

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 fx.practic, 10-15-2013, 12:53 AM
    5 responses
    5,406 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by Shai Samuel, 07-02-2022, 02:46 PM
    4 responses
    98 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by DJ888, Yesterday, 10:57 PM
    0 responses
    8 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by MacDad, 02-25-2024, 11:48 PM
    7 responses
    160 views
    0 likes
    Last Post loganjarosz123  
    Started by Belfortbucks, Yesterday, 09:29 PM
    0 responses
    9 views
    0 likes
    Last Post Belfortbucks  
    Working...
    X