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

Shorter vertical line with DrawLine

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

    Shorter vertical line with DrawLine

    Go ahead & smile then, show me the error of my ways...

    I'm trying to draw a short vertical line from a strategy using:

    DrawLine("Line" + CurrentBar, false, 0, High[0] + 5*TickSize, 0, Low[0] - 5*TickSize, Color.Cyan, DashStyle.Dot, 2)

    If I set the bool to "true" it shows the vertical lines but, they are way too long.
    If I then hold the Ctrl key and move the chart up and down, the lines stay put (As expected since I set autoscale to "true"
    However, setting autoscale to false causes the lines to disappear.... ?

    Thx in advance

    #2
    Randwulf,

    I would suggest changing the size of

    High[0] + 5*TickSize

    and

    Low[0] - 5*TickSize

    You have your "bars ago" settings both to 0 so it should be a vertical line. In this case, the Low and High code above sets the lengths of the line. Right now you would have High - Low + 10 ticks, so if you reduce the number of ticks it should make a smaller line.

    As far as your other issue, I am unable to replicate currently. Do you possibly have a simple toy strategy that does this I may test?
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Thx 4 the reply AdamP,

      I don't understand how I would have High - Low + 10 Ticks... ?
      I read that as drawing a line from "0" on the X axis & High + 5 Ticks on the Y axis
      to "0" on the X axis & Low - 5 Ticks on the Y axis.
      Is this incorrect ?

      protected override void OnBarUpdate()
      {
      // Condition set 1
      if (High[0] > KeltnerChannel(3.5, 50).Midline[0]
      && Low[0] < KeltnerChannel(3.5, 50).Midline[0])
      {
      DrawLine("My line" + CurrentBar, 0, High[0] + 5 * TickSize, 0, Low[0] + -5 * TickSize, Color.White);
      }
      }

      Comment


        #4
        Randwulf,

        The length of the line would be the top point : High[0] + 5*TickSize

        Minus the low point, which is : Low[0] - 5*TickSize

        So the length would be : ( High[0] + 5*TickSize ) - ( Low[0] - 5*TickSize )
        which is equal to : High[0] + 5*TickSize - Low[0] + 5*TickSize
        which finally is : High[0] - Low[0] + 10*TickSize

        This only works because you have a vertical line. It may be you have this number set too high, which is why the line looks bigger than you expect.

        Are you trying to draw this indicator between the two parts of the keltner channel? What is the purpose of this line?
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          Thx again AdamP,

          I was just wanting a line to accentuate the straddle bar but, running from
          KeltnerChannel(3.5, 50).Upper[0] to KeltnerChannel(3.5, 50).Lower[0]
          would certainly work....

          Just tried substituting those points instead but, lines still not appearing..

          Comment


            #6
            Randwulf,

            Could you possibly post your code for review?
            Adam P.NinjaTrader Customer Service

            Comment


              #7
              AdamP,

              I created a test strategy with the wizard using only the 1 condition and 1 output..
              The code below is the only code it created when I "View Code".

              protected override void OnBarUpdate()
              {
              // Condition set 1
              if (High[0] > KeltnerChannel(3.5, 50).Midline[0]
              && Low[0] < KeltnerChannel(3.5, 50).Midline[0])
              {
              DrawLine("My line" + CurrentBar, false, 0, KeltnerChannel(3.5, 50).Lower[0],
              0, KeltnerChannel(3.5, 50).Upper[0], Color.White, DashStyle.Solid, 2);
              }
              }

              Comment


                #8
                Randwulf,

                I am currently unable to replicate the disappearing lines. I would suggest upgrading your ninjatrader to the latest version perhaps and trying again. If you run this on a brand new chart without any extra indicators / strategies, does it still have the same behavior?

                Adam P.NinjaTrader Customer Service

                Comment


                  #9
                  AdamP,

                  If you were able to create a vertical line from top to bottom of a channel then,
                  it's obviously something on my end.
                  I will try fresh and report back.
                  Thank you again for the support & great product.

                  Comment


                    #10
                    Randwulf,

                    Thanks for your kind words.

                    If you happen to come across some replication steps, please let me know.
                    Adam P.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by jclose, Today, 09:37 PM
                    0 responses
                    5 views
                    0 likes
                    Last Post jclose
                    by jclose
                     
                    Started by WeyldFalcon, 08-07-2020, 06:13 AM
                    10 responses
                    1,413 views
                    0 likes
                    Last Post Traderontheroad  
                    Started by firefoxforum12, Today, 08:53 PM
                    0 responses
                    11 views
                    0 likes
                    Last Post firefoxforum12  
                    Started by stafe, Today, 08:34 PM
                    0 responses
                    11 views
                    0 likes
                    Last Post stafe
                    by stafe
                     
                    Started by sastrades, 01-31-2024, 10:19 PM
                    11 responses
                    169 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Working...
                    X