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

Looking at bars in the future of an Added data series

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

    Looking at bars in the future of an Added data series

    Hi there,

    To draw a line from the current bar to two bars in front I would use the barToStartAt = 0 and barToEndAt = -2. Which works fine.

    However what if, I am on a non time based chart running an indicator which has an added data series of 15minutes.

    How would I draw a line from the current 15 minute until 2 15 minutes later.

    If that makes any sense. I guess I can use time tbh and just start the drawing from every 00, 15, 30, 45 and draw the line by adding whatever time it would be 30 mins later. But i'm hoping there's an equivalent to the -2 ^^ such as CurrentBars[1] -2 or something (i know that doesn't work).

    Thanks,

    Tarik

    #2
    Hello Tarik,

    Thanks for your question.

    Drawings would be made on primary bars and when the we are working with a tick based bar as the primary bar, "time in the future" cannot be determined by number of bars.

    So, the best you could do would be to give times for where you would want the line to be drawn.

    Let us know if you have any additional questions.
    JimNinjaTrader Customer Service

    Comment


      #3
      Ahhh okay I figured as much.

      Thanks for your reply Jim.

      Tarik

      Comment


        #4
        Hey Jim, me again.

        Would it be possible to do it on time based bars then?

        Say my added data series is 15 minutes and my primary chart is 3 min candles.

        And I want to draw 30mins (but using my added data series so CurrentBars[1] -2 or whatever) into the future, is that possible?

        Thanks,

        Tarik

        Comment


          #5
          Hello Tarik,

          Since the drawing are made on primary bars, we can only provide BarsAgo indexes relative to the primary bar, or we would have to use GetBar with the secondary series to get a time that we can use instead.

          Code:
          if (BarsInProgress == 0)
          {
              Draw.Line(this, "tag", true, Time[0], Close[0], BarsArray[1].GetTime(CurrentBars[1] + 10), Close[0], "");
          }
          For example, the above will get the next bar time for the index provided, but since we provide an index that does not yet exist, we get the last bar time for the secondary bar. (+ 10 would not make a difference here)

          So, if you wanted to do something like the above using a secondary series, you can, but you cannot go further into the future than the next secondary bar's time.

          A better way to do this would be to use BarsAgo values relative to the primary series.

          You could convert the time in the future into number of bars with the primary bar, and since the bar is time based, using a - value for BarsAgo and the line will project forward accurately since we are dealing with time based bars.

          Code:
          if (BarsInProgress == 0)
          {
              if (Time[0].Minute == 30)
                  Draw.Line(this, "tag", true, 0, Close[0], -60, Close[0], "");
          }
          JimNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by elliot5, Today, 03:28 AM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_Jason  
          Started by pjsmith, 09-25-2022, 07:13 AM
          7 responses
          57 views
          0 likes
          Last Post pjsmith
          by pjsmith
           
          Started by knarfoe, 09-23-2021, 05:19 AM
          7 responses
          66 views
          0 likes
          Last Post NinjaTrader_Jason  
          Started by EstheYund, Today, 01:56 AM
          0 responses
          14 views
          0 likes
          Last Post EstheYund  
          Started by Daveman0, 09-25-2022, 11:14 PM
          4 responses
          46 views
          0 likes
          Last Post jeronymite  
          Working...
          X