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

Draw Vertical Line

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

    Draw Vertical Line

    Hey guys,

    I'm looking to have a vertical Line drawn between a high and a low in an indicator.
    In this example from the help file I get 10 which is bars back. But I'm looking to connect the high and the low for the current bar with a vertical line so it looks similar to the price bar.

    DrawVerticalLine("tag1", 10, Color.Black);

    Could I get some help with setting the start and stop of the line?

    In english I'd like the logic to be: Draw vertical line starting here and ending here for the current bar.

    Thanks a lot.

    #2
    DrawLine("Tag1", 0, highValue, 0, lowValue, Color.Blue)
    RayNinjaTrader Customer Service

    Comment


      #3
      Thanks Ray, Does that go in OnBarUpdate()?
      I put it in there with the proper value's but it didn't draw anything.
      thanks
      JJ

      Comment


        #4
        Yes, in OnBarUpdate()
        RayNinjaTrader Customer Service

        Comment


          #5
          Thanks for the help Ray,


          protectedoverridevoid OnBarUpdate()
          {
          // Use this method for calculating your indicator values. Assign a value to each
          // plot below by replacing 'Close[0]' with your own formula.


          Hi.Set(ValueHi());
          Lo.Set(ValueLo());
          DrawLine(
          "Tag1", 0, ValueHi(), 0, ValueLo(), Color.White);
          }

          Is this enough to plot the line that I asked about in the previous question or do I need to reference that tag somehow?
          thanks
          JJ

          Comment


            #6
            Likely, just try it out and test it.
            RayNinjaTrader Customer Service

            Comment


              #7
              Hey Ray, That peice of code doesn't give me a line. For hi and low value I also just put in a static number to make sure it wasn't my calculations but no go.
              Any suggestions? Do I need anything in Initalize()?
              thanks for the help.

              Comment


                #8
                I will look into it, it should work.
                RayNinjaTrader Customer Service

                Comment


                  #9
                  This works for me:

                  DrawLine("Tag1", 0, High[0] + 4 * TickSize, 0, Low[0] - 4 * TickSize, Color.Red);

                  There is likely something else wrong in your script that you would have to debug.
                  RayNinjaTrader Customer Service

                  Comment


                    #10
                    I appreciate your tiem with me Ray. Your code does work for me but it plots the line on the price panel. I would like the line drawn in the indicator panel. How can I modify that?
                    thanks

                    Comment


                      #11
                      In the Initialize() method, include the following line:

                      DrawOnPricePanel = false;

                      RayNinjaTrader Customer Service

                      Comment


                        #12
                        Awesome Ray! It worked!!!

                        One more dilema for you. How can I get that line to stay and not just paint on the current bar. I'd like it to paint on the current bar of course but I'd also like it to stay when the bar is finished forming if possible.
                        thanks.

                        Comment


                          #13
                          Then you have to provide a unique tag name for each line.

                          Instead of "Tag1"

                          Use something like

                          DrawLine("Tag1" + CurrentBar, 0, High[0] + 4 * TickSize, 0, Low[0] - 4 * TickSize, Color.Red);
                          RayNinjaTrader Customer Service

                          Comment


                            #14
                            Ray, you are the f'n MAN!

                            Got it! I'm very appreciative for your time and expertise.

                            JJ

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by algospoke, Today, 06:40 PM
                            0 responses
                            9 views
                            0 likes
                            Last Post algospoke  
                            Started by maybeimnotrader, Today, 05:46 PM
                            0 responses
                            7 views
                            0 likes
                            Last Post maybeimnotrader  
                            Started by quantismo, Today, 05:13 PM
                            0 responses
                            7 views
                            0 likes
                            Last Post quantismo  
                            Started by AttiM, 02-14-2024, 05:20 PM
                            8 responses
                            168 views
                            0 likes
                            Last Post jeronymite  
                            Started by cre8able, Today, 04:22 PM
                            0 responses
                            9 views
                            0 likes
                            Last Post cre8able  
                            Working...
                            X