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

remove drawing object

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

    remove drawing object

    Hallo.

    How can I remove one specific drawing object? I want to remove one horizontal line not all horizontal lines.

    Thanks so far.

    Regards,

    Theo

    #2
    Hello Theo,
    While drawing the draw object please assign a object to it
    Code:
    IHorizontalLine hLine = this.DrawHorizontalLine("line", Close[0], Color.Green);


    You can then remove the specific draw object using the below code.
    Code:
    this.RemoveDrawObject(hLine);
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      thanks for the reply

      Comment


        #4
        Note, you can remove that only using tag-name too:

        Code:
        RemoveDrawObject("line1");

        Comment


          #5
          Hello,

          I can´t find in the forum an information to remove lines when price crosses the specific drawing tool

          Now with DrawRay("Ray" + CurrentBar,.....) I draw a ray at the high of a bar when specific condition is true, I add " +CurrentBar" because there are more Rays or Lines drawn during the day. How can I remove one by one when price touches or crosses that price where it is drawn please?

          From another thread I got already the idea to use the price where it is drawn as the name of the drawing object and then to do in the code eg if(Close[0]>"Rayprice") RemoveDrawingObject("Rayprice"). But also this I dont know how to do correctly.

          Thank you!
          Tony
          Last edited by tonynt; 01-14-2018, 08:29 AM. Reason: tranlation error

          Comment


            #6
            Hello,

            Thank you for the post.

            The correct answer would be to use RemoveDrawObject("line1"); with the name of the tag needing to be removed. If this was the last bar, you could just subtract 1 from the CurrentBar value. If you need to remove more than that, you may need to use a loop or other logic to do this.

            Please let me know if I may be of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Hello Jesse,

              thank you for your reply. This is clear and I´m doing all the time - when I know which bar or drawing object it is. But what I mean with my question is that lines are plotted during the day and I dont know when and I do not know how many. But if a line is plotted eg at the high of a pivot bar and Price goes there again and higher then the line should be removed. This can be every bar and every minute of the day.

              For example a script drawing eg cycle high and cycle low a ray and when it is broken then it is removed.

              I hope I could explain what I mean. (the question is not about conditions or cycles or how to draw, the question is only how to assign a name to a drawing object so that it can be removed then by referring to this Name - so I thought maybe the price (high or low) where it is drawn might give an idea for a solution (because it will not be the same order as drawn to be removed)

              Thank you
              Tony

              Comment


                #8
                Hello,

                Thank you for the reply.

                The core part of your problem would be the following:

                But what I mean with my question is that lines are plotted during the day and I dont know when and I do not know how many
                If you are drawing lines they would be for some reason, for example, the condition you had created to draw them. In that condition, you would need to implement some way to track tags you have used if you need to later remove them and they are not in a specific order. If they are in a specific order for example, for every bar, the CurrentBar index would be a good count for a loop to loop over all bars if needed.

                The RemoveDrawObject method would still be used in both cases, you would need to use it logically that works in the way you want to remove the objects. Otherwise, you can clear all objects using RemoveDrawObjects().

                Please let me know if I may be of further assistance.
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  Hello,

                  yes, of course. You describe what I do in a question. I was asking how one can work with the tags of the drawing objects to resolve this and to provide an idea I asked if its possible to assign eg the High 2798.75 to the tag of the drawing object so that when marketprice touches eg this Highprice 2798.75 again then one can do "RemoveDrawObject("2798.75");"

                  Thank you
                  Tony

                  Comment


                    #10
                    Hello,

                    Thank you for the reply.

                    As long as you supply a unique/valid C# string, you can use pretty much whatever you would like the tag name which would include prices or numbers in general. I would suggest testing what you have asked in a separate indicator to confirm it works for you.

                    I look forward to being of further assistance.
                    JesseNinjaTrader Customer Service

                    Comment


                      #11
                      Hello,

                      thank you for your reply.

                      Yes, of course. Could you please give me and idea about the snippet to assign the high[0] to a tagname and then in the other direction when a price is matching with a tagname then do...

                      Thank you!
                      Tony
                      Last edited by tonynt; 01-17-2018, 08:47 AM. Reason: typing error

                      Comment


                        #12
                        Hello,

                        In C# to make an object into a string, you can use its .ToString() method.

                        Code:
                        High[0].ToString()
                        or just append the value to an existing string

                        Code:
                        "Tag" + High[0]
                        This is no different than using any number like many of the examples showing
                        Code:
                        "Tag" + CurrentBar
                        You would do the same process in the Remove syntax, just make a string with the tag you need and supply it to the method.

                        Code:
                        RemoveDrawObject("Tag" + High[0]);
                        Please let me know if I may be of further assistance.
                        JesseNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by CortexZenUSA, Today, 12:53 AM
                        0 responses
                        1 view
                        0 likes
                        Last Post CortexZenUSA  
                        Started by CortexZenUSA, Today, 12:46 AM
                        0 responses
                        1 view
                        0 likes
                        Last Post CortexZenUSA  
                        Started by usazencortex, Today, 12:43 AM
                        0 responses
                        5 views
                        0 likes
                        Last Post usazencortex  
                        Started by sidlercom80, 10-28-2023, 08:49 AM
                        168 responses
                        2,266 views
                        0 likes
                        Last Post sidlercom80  
                        Started by Barry Milan, Yesterday, 10:35 PM
                        3 responses
                        13 views
                        0 likes
                        Last Post NinjaTrader_Manfred  
                        Working...
                        X