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

Vertical line indicator offset by 9, 26 and 52 bars (NinjaTrader 8 used)

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

    Vertical line indicator offset by 9, 26 and 52 bars (NinjaTrader 8 used)

    Hello,

    I would like to have an indicator on my graphs that draws 3 vertical lines offset by 9, 26 and 52 bars.

    These lines should be updated at each new candlestick and work on all time units. I have added an image as an example.

    Click image for larger version  Name:	3 vertical line.jpg Views:	0 Size:	83.0 KB ID:	1225154

    Can you help me please?

    Thanks in advance.​​

    #2
    I've created an indicator for you that will draw the 3 vertical lines as you have specified. On each new bar the 3 lines will advance one bar.

    The vertical lines will use the "default" drawing template for vertical lines. You can create a template for each of the vertical lines so that they can be colored as you wish. The 3 templates need to be named exactly Line1, Line2, and Line3. Line1 is 9 bars back, Line 2 is 26 bars, and Line3 is 52 back.

    If you don't know how to create a drawing tools template then you really need to study the help guide here: https://ninjatrader.com/support/help...bjectTemplates

    My3VerticalLines.zip

    Comment


      #3
      Hello C78070,

      Thanks for your post.

      Are you wanting to draw a vertical line 9 bars from the currently forming bar, 26 bars from the currently forming bar, and 52 bars from the currently forming bar?

      If so, you could use the Draw.VerticalLine() method and pass in the barsAgo value that you want to draw the vertical line on.

      For example, you would pass in a 9 for the barsAgo argument when calling Draw.VerticalLine().

      Code:
      // Draws a vertical line 9 bars back from the current bar
      Draw.VerticalLine(this, "tag1", 9, Brushes.Black);
      See this help guide page for more information: https://ninjatrader.com/support/help...rticalline.htm

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

      Comment


        #4
        Originally posted by Tasker-182 View Post
        I've created an indicator for you that will draw the 3 vertical lines as you have specified. On each new bar the 3 lines will advance one bar.

        The vertical lines will use the "default" drawing template for vertical lines. You can create a template for each of the vertical lines so that they can be colored as you wish. The 3 templates need to be named exactly Line1, Line2, and Line3. Line1 is 9 bars back, Line 2 is 26 bars, and Line3 is 52 back.

        If you don't know how to create a drawing tools template then you really need to study the help guide here: https://ninjatrader.com/support/help...bjectTemplates
        ​Hello Tasker-182,

        Thanks for the coding of the indicator, it meets exactly my need

        I just modified the numbers to take into account the candlestick being formed.

        Apart from that everything is perfect and I thank you.

        Good continuation

        Comment


          #5
          Tasker 182 - Would you be willing to modify the "My2VerticalLines" indicator draw the line on the current bar and have the line drawn though all panels on the chart.

          Comment


            #6
            Originally posted by edshaffer1 View Post
            Tasker 182 - Would you be willing to modify the "My2VerticalLines" indicator draw the line on the current bar and have the line drawn though all panels on the chart.
            No, as far as I know that would require unsupported code.

            Comment


              #7
              Hi edshaffer1,

              Welcome to the NinjaTrader forums!

              Unfortunately, a script cannot draw in multiple panels. It would be necessary to add the indicator multiple instances to the chart set to each panel individually.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Hi there,

                i was trying to work out how to do something similar

                i wanted to start an anchor point in say any time frame ( bars count - so i can use tick or time or range bars say )
                i start the vertical line at 0 count and i have a list of say 12 inputs of interval of time / bars -= as an example 10 bars , 12 bars 10 bars , 14 bars etc...

                but i want to forward them in time , so at current ( time of say 4 pm ) i can see a bar at 410pm say with tick bar ( because its counting with bars not time it would be 10 bars ) it shows where 10 bars will be

                i need a colour set for red down and green up , and start my anchor point with a up first or down first , so i can see which bar is a high or low

                im not very good at this and i was wondering if this is possible to do this in a chart back a few weeks and then project forward to current day , any time frame is ok, even daily , so long as it counts the bars

                Thanks in advance

                Comment


                  #9
                  Hello Orolo2001,

                  Welcome to the Forums!

                  To draw a vertical line at a specific time, you could use the Draw.VerticalLine() overload that allows you to specify a DateTime instead of a barsAgo value.

                  Draw.VerticalLine(NinjaScriptBase owner, string tag, DateTime time, Brush brush)
                  Draw.VerticalLine(NinjaScriptBase owner, string tag, DateTime time, Brush brush, DashStyleHelper dashStyle, int width, bool drawOnPricePanel)


                  For example, if the current time is 4:00PM and you pass in a time of 4:10PM for the Draw.VerticalLine() Datetime time argument, the vertical line will be drawn forward in time at 4:10PM.

                  Draw.VerticalLine(): https://ninjatrader.com/support/help...rticalline.htm

                  There would be no supported means to draw the vertical line forward in time using the overload that allows you to specify a barsAgo argument. BarsAgo would look back a set number of bars from the current bar.​
                  Brandon H.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by sidlercom80, 10-28-2023, 08:49 AM
                  170 responses
                  2,270 views
                  0 likes
                  Last Post sidlercom80  
                  Started by Irukandji, Yesterday, 02:53 AM
                  2 responses
                  17 views
                  0 likes
                  Last Post Irukandji  
                  Started by adeelshahzad, Today, 03:54 AM
                  0 responses
                  3 views
                  0 likes
                  Last Post adeelshahzad  
                  Started by CortexZenUSA, Today, 12:53 AM
                  0 responses
                  3 views
                  0 likes
                  Last Post CortexZenUSA  
                  Started by CortexZenUSA, Today, 12:46 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post CortexZenUSA  
                  Working...
                  X