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

Get draw line price value

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

    Get draw line price value

    Hi guys!

    Please give me an idea...how do i get a draw hline on chart actual price value?
    And get line tag name?

    thx

    w.

    #2
    Hello,

    The Line Alert Indicator in our Support forums will actually get the price and information of the lines that you may view for a reference at the following link.

    JCNinjaTrader Customer Service

    Comment


      #3
      Hi JC!

      Thanks for your reply. I checked it out. And create some own code aswell.
      I draw a line on the chart and add tag name "open" /this will be open line/ and get some values. It works properly....even if i moved...

      Now I'd like to /if DrawObject("open") is exist/ draw a Horizontal line (target line) /in the begining actual open line price + 5*Ticksize/.
      That's easy too.

      Afterwards I'd like to move target line manually on the chart, but ofcourse always gets begining price...
      How can i solve it? How can I move like open line?

      Here is my code...

      foreach (IDrawObject draw in DrawObjects)
      {

      if (draw.UserDrawn && draw.DrawType == DrawType.Line && DrawObjects["open"] != null)
      {
      ILine openLine = (ILine) draw;
      openLine.Locked = false;
      openLine.Pen.Width = 2;
      leftY = openLine.StartY;
      rightY = openLine.EndY;
      leftBarsAgo = openLine.EndBarsAgo;
      rightBarsAgo = openLine.StartBarsAgo;
      openLine.Pen.Color = Color.Blue;

      IHorizontalLine targetLine = DrawHorizontalLine("target_line", false, leftY+5*TickSize, Color.Green, DashStyle.Solid, 1); //Automatic target Hline draw
      celarLine.Locked = false;


      }
      if (DrawObjects["open"] == null)
      {
      leftY = 0;
      rightY = 0;
      leftBarsAgo = 0;
      rightBarsAgo = 0;
      RemoveDrawObject("target_line");
      }
      }

      Thx
      w.

      Comment


        #4
        Hello wokitun,

        Well I see inside of your code that you are drawing the "target_line" each time you are inside of the code. I would expect this to continuously redraw this line reverting any changes you may do to it.

        You may want to add a variable or conditions so that it only draws it once.

        Let me know if this helps.
        JCNinjaTrader Customer Service

        Comment


          #5
          Hi!

          I add a conditions in foreach... like

          if (DrawObjects["target_line"] == null) //if not exists, create line
          {
          IHorizontalLine hLine = DrawHorizontalLine("target_line", false, 1.3000, Color.Black, DashStyle.Solid, 2);
          hLine.Locked = false;
          targetY = hLine.Y;
          }

          Now I can move the line perfectly but I cannot get new targetY.
          ??

          Please help me what should i do..

          thx
          w.

          Comment


            #6
            Hello wokitun,

            This is because you are only setting "targetY" when you first draw "target_line".

            Just like you did for object Open, you will want to check the drawing object name of "target_line" and make sure it is not "null" and then get a the new value of "targetY". Note that you do not want to draw it again but just get the Y value.
            JCNinjaTrader Customer Service

            Comment


              #7
              OK, thx

              I found the right way...

              Another question please...
              How can i get....tf there is not any Drawobject.Dot on the chart?

              thx
              w.

              Comment


                #8
                Hello wokitun,

                Not a IDrawObject but there is a IDot that you may get.
                JCNinjaTrader Customer Service

                Comment


                  #9
                  I mean...

                  foreach (IDrawObject draw2 in DrawObjects)
                  {

                  if (draw2.DrawType == DrawType.Dot)// && DrawObjects["target"] != null)
                  {

                  IDot celarDot = (IDot) draw2;
                  celarY = celarDot.Y;
                  celarDot.Locked = false;
                  }
                  }

                  So how to add my code if no any dot object exist on the chart??? /thats what i want./
                  And i don't know dot object tag name aswell...

                  I try with this...
                  if (celarDot == null)
                  {
                  bla-bla-bla
                  }

                  but its not working

                  thx
                  w.

                  Comment


                    #10
                    Hello wokitun,

                    You would still use the DrawObjects["target"] to be able to get the name of the Tag for the Dot so that you can check to see if its null or if it has a specific tag name.

                    You may also use "celarDot.Tag" to get the string tag for it as well.
                    JCNinjaTrader Customer Service

                    Comment


                      #11
                      Thanks everything...

                      w.

                      Comment


                        #12
                        Line Tag Changed

                        Good Evening,

                        I spent some time drawing horizontal lines on my chart and named them by changing the tag in the Data field. I tested going back and forth to and from them and it seemed to be working. All of sudden when I changed timeframes, all of the Tags I named were gone. The lines still were in place but the Tag reverted back to default. I was switching between timeframes before and it didn't seem to affect it.

                        Also. Is there some sort "hover" feature where I can name a horizontal line and when I hover over the line the name will pop up? Thanks.

                        Comment


                          #13
                          Hello JRCibula,

                          Was it a particular time frame that you switched it to when this happened?

                          Are you drawing the objects inside of your script or are you drawing them manually and modifying them in your script?

                          You would have to open up the Drawing Object's properties or Print it out in the output window to see the Tag name.


                          Happy to be of further assistance.
                          JCNinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by r68cervera, Today, 05:29 AM
                          0 responses
                          2 views
                          0 likes
                          Last Post r68cervera  
                          Started by geddyisodin, Today, 05:20 AM
                          0 responses
                          3 views
                          0 likes
                          Last Post geddyisodin  
                          Started by JonesJoker, 04-22-2024, 12:23 PM
                          6 responses
                          33 views
                          0 likes
                          Last Post JonesJoker  
                          Started by GussJ, 03-04-2020, 03:11 PM
                          12 responses
                          3,239 views
                          0 likes
                          Last Post Leafcutter  
                          Started by AveryFlynn, Today, 04:57 AM
                          0 responses
                          6 views
                          0 likes
                          Last Post AveryFlynn  
                          Working...
                          X