• 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.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Incorrect Bar data with two panels with two intervals

Collapse
X
 
  • 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!

    #2
    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

    Comment


      #3
      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, 02:44 PM.

      Comment


        #4
        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."
        SlotIndex
        Last edited by NinjaTrader_PatrickH; 03-01-2016, 02:57 PM.
        Patrick H.NinjaTrader Customer Service

        Comment


          #5
          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, 11:46 AM.

          Comment


            #6
            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

            Comment


              #7
              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...

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by U0000999, Today, 09:45 AM
              0 responses
              3 views
              0 likes
              Last Post U0000999  
              Started by Newtrader101, Today, 08:01 AM
              0 responses
              6 views
              0 likes
              Last Post Newtrader101  
              Started by Johnny Santiago, 10-11-2019, 08:21 AM
              6 responses
              102 views
              0 likes
              Last Post 4x777
              by 4x777
               
              Started by pjsmith, Today, 02:42 AM
              2 responses
              16 views
              0 likes
              Last Post pjsmith
              by pjsmith
               
              Started by moyerchopra, Yesterday, 11:43 PM
              0 responses
              5 views
              0 likes
              Last Post moyerchopra  
              Working...
              X