• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.


No announcement yet.

Partner 728x90


Incorrect Bar data with two panels with two intervals

  • Filter
  • Time
  • Show
Clear All
new posts

    Incorrect Bar data with two panels with two intervals

    This is in the context of creating a custom drawing tool, but it could exist in other places.

    If I create a new chart that's not time-based ("4 range" for example), then add a new panel (on the same chart) that is time-based ("1 minute" for example), I am getting incorrect results from "GetAttachedToChartBars().Bars.Count" (as well as .GetHigh(), etc)

    In other words, if there are two instruments on the same chart (separate panels), but their intervals create a different number of SlotIndexes (1 min chart vs 4 range chart), I'm having difficultly getting correct Bar information for my custom drawing tool.

    If both intervals are the same, then there is no problem.

    Perhaps I need to do something differently to specify the panel when calling "GetAttachedToChartBars()"?

    Any help or confirmation that this is a bug is greatly appreciated!

    Hello neoikon,

    Thank you for your post.

    How are you setting your Points? Can you attach your Drawing Tool's code?
    Patrick H.NinjaTrader Customer Service


      My tool is based on the built-in "Rectangle" code. However, I was able to reproduce it using the builtin code as well.

      If I add the following to the first line of OnRender() in @Shapes.cs

      PHP Code:
      Print("Bars.Count: " GetAttachedToChartBars().Bars.Count "    EndAnchor: " EndAnchor.SlotIndex); 
      (I understand never modifying the builtin functions, but this is just to temporarily output the data)

      Then create a chart, as described in my first post (two instruments, in separate panels on the same chart, one 4R and one 5M).

      When I draw a rectangle on the top panel, then look at the output window, you'll see that the EndAnchor.SlotIndex (second value) is greater than the GetAttachedToChartBars().Bars.Count value, which shouldn't be (unless the rectangle is drawn in the future area).

      If you change both intervals to be the same interval (both 4R or both 5M), then you will see that the EndAnchor is less than the Bars.Count, as expected, since it's inside the count of the bars.

      Perhaps I am misunderstanding the relationship between Bar Count and SlotIndexes?

      If I look at EndAnchor.BarsAgo and EndAnchor.DrawnOnBar, they are equal to int.MinValue, so are of no use.

      I forgot to add that the reason this becomes problematic is when calling GetAttachedToChartBars().Bars.GetHigh(X), then it won't be the correct Bar as expected, if I am basing X on the StartAnchor/EndAnchor positions (looping through the bars in between them, for example).
      Last edited by neoikon; 02-29-2016, 03:44 PM.


        Hello neoikon,

        Thank you for your response.

        This is described in the Help Guide as follows: "In a single series chart there will always be equal number of slots and bars, however for multi-series charts there may be additonal slots compared to the bar series your drawing tool resides."
        Last edited by NinjaTrader_PatrickH; 03-01-2016, 03:57 PM.
        Patrick H.NinjaTrader Customer Service


          Thanks for the reply, but, unfortunately, that doesn't solve my problem or tell me how to achieve what I'm looking for.

          In this scenario, how do I find the bar index of one of the drawing tool's anchors in order to determine the High/Low of the bar that's at that same index?

          Or, loop through the bars between the two anchors and determine the highest high or lowest low bar.

          I can do these things no problem if the SlotIndex matches the Bar Counts. If the bar type is time based, then I could use the Anchor's time, then just add the "interval" to get the next bar time. However, the bar type is, obviously, not guaranteed to be time based.

          Thank you!
          Last edited by neoikon; 03-01-2016, 12:46 PM.


            Hello neoikon,

            Thank you for your patience.

            I have not found a way around this. I will report to development.
            Patrick H.NinjaTrader Customer Service


              Thanks for looking into this for me. I guess the good news is that I'm not crazy and there is an issue here.

              Perhaps there needs to be a way to translate SlotIndex to BarIndex, where most of the time they will be 1-to-1, but in this rare (?) situation there would need to be some kind of translation...


              Latest Posts


              Topics Statistics Last Post
              Started by lupearadu, Today, 01:58 PM
              1 response
              Last Post Emma1
              by Emma1
              Started by nctpar, Today, 02:13 PM
              0 responses
              1 view
              Last Post nctpar
              by nctpar
              Started by rexmie888, Today, 01:47 PM
              0 responses
              Last Post rexmie888  
              Started by aslane, Today, 12:41 PM
              0 responses
              Last Post aslane
              by aslane
              Started by NinjaCustomer, 06-06-2018, 08:47 AM
              15 responses
              Last Post cls71
              by cls71