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

DrawingTools.Line Documentation

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

    DrawingTools.Line Documentation

    Hi,

    Is there a documentation I can use for using DrawingTolls.Line or sample code on how to manipulate line like price at a given time or barsAgo, start and end? I am trying to search in NinjaScript Help but I can not find any useful documentation for this.

    Thanks.
    Last edited by kezyclaire; 03-26-2023, 09:09 AM.

    #2
    Hello kezyclaire,

    Thanks for your post.

    To modify a drawing object that is drawn on the chart using Draw.Line(), you could call the Draw.Line() method again in the script using the same exact Tag name and specifying a different startBarsAgo, start y, endBarsAgo, or endY parameter value.

    From the Draw.Line() help guide: "if you pass in a value of "myTag", each time this tag is used, the same draw object is modified."

    See this help guide page for more information: https://ninjatrader.com/support/help.../draw_line.htm

    Please let me know if I may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Hi Brandon,

      I would like to get the price of 2 barsAgo, how would I do that?

      Thanks.

      Comment


        #4
        Hello kezyclaire,

        Thanks for your note.

        A barsAgo value of 2 could be passed into the PriceSeries you are wanting to access to get that price 2 bars ago.

        For example, to get the Close price 2 bars ago, Close[2] should be used. To get the Open price 2 bars ago, Open[2] should be used.

        See this help guide page for more information about the available PriceSeries: https://ninjatrader.com/support/help...riceseries.htm

        Let me know if I may assist you further on this.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Hi Brandon,

          I mean the price of Line using BarsAgo or Time, how do I get it? I am currently using Slope to get the price in a specific barsAgo but there should be a simplest way to get it.

          m = (Y2 - Y1) / (X2 - X1) then I add if positive or subtract if negative to the start of Line multiply to how many bars from the start of line.

          Thanks
          Last edited by kezyclaire; 03-27-2023, 02:52 PM.

          Comment


            #6
            Hello keyzclaire,

            Thanks for your note.

            Are you referring to getting the price of a line that you drew using Draw.Line()?

            Or, are you referring to trying to get the price of a line that was manually drawn on a chart window?

            If possible, please send me a screenshot demonstrating exactly what value you are trying to get in your script.

            I look forward to assisting further.
            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              Hi Brandon,

              I am trying to get the price which I have drawn using below. I want to get the price at a specific barsAgo/CurrentBar/Time using the Line below. I can get the price of endanchor or startAnchor but I want to get the price in between start and end Anchor. Example I have a Line, half the Line is 2 BarsAgo, how do I get the price of the Line 2 barsAgo.

              myBuyLine = Draw.Line(this, "@LineBuy", false, startBarsAgo, startPrice, endBarsAgo, endPrice, true, "");

              Getting the start Price of the line is myBuyLine.StartAnchor.Price. What about getting the price in a specific point in the Line.

              myBuyLine.?




              Another question, how do I filter below condition to get only Line, excluding other DrawObjects with below foreach statement.

              foreach (DrawingTool draw in DrawObjects.ToList())


              I tried below but it doesnt work
              foreach (DrawingTools.Line draw in DrawObjects.Where(x => x is DrawingTools.Line).ToList())​
              Last edited by kezyclaire; 03-27-2023, 04:24 PM.

              Comment


                #8
                Hello kezyclaire,

                Thanks for your note.

                You would only be able to get the price value of the StartAnchor and EndAnchor of the line drawing object. There are no supported methods or properties for getting the price at a specific point in the line drawing object.

                For your second question, you could loop through the DrawObjects collection and then find line objects that are on the chart.

                Code:
                foreach (DrawingTool draw in DrawObjects.ToList())
                {
                    if (draw is DrawingTools.Line)
                    {
                        //do something here
                    }
                }
                See the third sample code section in the DrawObjects help guide page linked here: https://ninjatrader.com/support/help...rawobjects.htm

                Please let me know if I may assist further.​
                Brandon H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by pibrew, Today, 06:37 AM
                0 responses
                0 views
                0 likes
                Last Post pibrew
                by pibrew
                 
                Started by rbeckmann05, Yesterday, 06:48 PM
                1 response
                12 views
                0 likes
                Last Post bltdavid  
                Started by llanqui, Today, 03:53 AM
                0 responses
                6 views
                0 likes
                Last Post llanqui
                by llanqui
                 
                Started by burtoninlondon, Today, 12:38 AM
                0 responses
                11 views
                0 likes
                Last Post burtoninlondon  
                Started by AaronKoRn, Yesterday, 09:49 PM
                0 responses
                15 views
                0 likes
                Last Post AaronKoRn  
                Working...
                X