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

DrawingObject Index

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

    DrawingObject Index

    Hello,

    how can one have for drawing object the high or low as reference instead of current bar...
    Draw.Line(this, "tag1"+CurrentBar, false, 0, Highs[1][0], -100, Highs[1][0], Brushes.Red, DashStyleHelper.Dash, 2);
    Draw.Line(this, "tag1"+Highs[1][0]....?
    so that one can refer to that drawingobject by price and not by bar.

    Thank you!
    Tony


    #2
    Hello Tony,

    A chart is a grid of bar slots (x axis) and time slots (y axis).

    Unless you are drawing in a fixed corner with Draw.TextFixed() you will need to choose a bar and a time.

    The tag name names identify that drawing object. There can be only one of each tag name at a time.

    To draw multiple objects they need to have unique tag names. We add current bar to the tag string so that the string is unique on each new bar.

    To confirm, you want to draw multiple objects on the same bar at different prices, correct?

    Adding the price to the tag string is fine to have multiple unique strings on the same bar.
    Last edited by NinjaTrader_ChelseaB; 10-13-2020, 02:17 PM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      thank you fro your reply. Yes, I use this long time with "tagname"+Currentbar.

      But this doesnt help me when I want to find a drawing object starting eg on a high of a bar. We do not know later in the day the bar where it occurred. But if have as index/reference the high I could refer to this. And its ok when at same high/price during the day there are 2 drawing objects.

      How can I please use the high (instead of +CurrentBar) with eg Draw.Line so that I can refer later to this drawing object by price.

      Thank you!
      Tony

      Comment


        #4
        Hello Tony,

        If you call
        Draw.Line(this, "myline" + High[0].ToString(), 1, High[0], 0, High[0], Brushes.Blue);
        Draw.Line(this, "myline" + (High[0] + 2 * TickSize).ToString(), 1, High[0], 0, High[0]+ 2 * TickSize, Brushes.Blue);

        You will see both lines on the same bar, one above the other. The price added makes the tag names strings unique.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello,

          great. Thank you!

          And for finding this drawing object to remove it what need to be modified please

          if (State == State.Realtime)
          {for (int index = 0; index < myLine.Count(); ++index)
          {
          if (Close[0]<=???)
          {RemoveDrawObject(myLine.Tag);}

          Thank you!
          Tony

          Comment


            #6
            Hello Tony,

            Are you having an issue I can assist with?

            It looks like you want to remove all objects where the close value is null... I think..
            The Close[0] series will never have a null value.
            I honestly wouldn't expect this code to compile. This doesn't seem like valid C# to me.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hello,

              agree, this would not make sense. These are few lines I copied and pasted becauese of the RemoveDrawObject to show what I mean.

              I want to remove the drawingobject where the Close[0] is higher than the High[0].ToString() we have in the drawingobject above in #4 "Draw.Line(this, "myline" + High[0].ToString(),..."

              Thank you!
              Tony

              Comment


                #8
                Hello Tony,

                If you want to remove a drawing object, you need to call RemoveDrawObject with the tag you want to remove.

                If you drew a line with Draw.Line(this, "myline" + High[0].ToString(),... and "myline" + High[0].ToString() is your drawing tag, save "myline" + High[0].ToString() to a string and use that string when you call RemoveDrawObject.
                JimNinjaTrader Customer Service

                Comment


                  #9
                  Hello Jim,

                  yes, theoretically all clear. But how?

                  Thank you!
                  Tony

                  Comment


                    #10
                    Hello Tony,

                    You can make a class level string and assign your drawing object's tag to the string when the Drawing object is drawn.

                    You can then reference that string in your RemoveDrawObject call.

                    Variable assignment and class level variables are C# concepts that will need to be known in order to write the code. You may find some publicly available resources on C# below.

                    W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.


                    A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
                    JimNinjaTrader Customer Service

                    Comment


                      #11
                      Hello,

                      thank you for your reply. I cant find a solution there (because I´m not a programmer)

                      Why cant you give me the few lines, as you know exactly what I need.

                      I want to remove the one drawingobjects (or all drawing objects) when price touches the high that is in the tag of the drawing object.

                      I could modify me an indicator to plot what I need, but I can not remove it as I need and I described here few times already. I will try untill post #3000.

                      Thank you!
                      Tony

                      Comment


                        #12
                        Hello Tony,
                        I guess something is missing, I don't understand why you're using "myline"+High[0].ToString() as tag, actually you can simply use "myline"+High[0] & then use RemoveDrawObject("myline"+High[0]), it will work. This works for me.

                        Comment


                          #13
                          Hello s.kinra,

                          thank you for your reply. This was given to my by NT-support.
                          How to you scan/loop for it so that you can remove it?

                          Thank you!
                          Tony

                          Comment


                            #14
                            Hello Tony,
                            I use this similar to Current Bar which concatenate the Bar index & this does the price, so basically for every new High I have a new tag & when I call remove based on condition it retains the latest high. However, I don't use them very frequently but things are working for me so far. I don't know your exact issue & that's why I said something seems to be missing, I would suggest you to try removing the draw object in a new indicator with the logic & then you can include it in main code so it keeps things simple & easy for you to understand the behavior. This is how I get the things working for me & I am sure your things would be much more complex. I just try to keep it as simple as I can.

                            Comment


                              #15
                              Hello s.kinra,

                              when you reply here that you use the High[0] to remove the bar then please post me how you do. A philosopical discussion doesent help in trading and coding.
                              Why do you have for every new High a new tag? You are referring to the "latest high". This I do in a different way. But I assume this has nothing to do with my question to find a drawing object which is tagged by price. (?)

                              Thank you!
                              Tony

                              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