Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Drawing Bar number is off by -1

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

    Drawing Bar number is off by -1

    In a simple strategy that checks if High[0] is greater than High[1]. The bars numbers in the square brackets for the condition here does not match the bar number used to insert drawings on the chart.

    See screenshot. The arrow is drawn on Bar 2, despite me writing [1]. What am I missing here? why would the bar count by different here than in the condition?

    #2
    Hello several,

    Is the script running with Calculate.OnBarClose?

    If so, the condition and action will be executed after the bar closes as a new bar opens.

    You can print the bar time in the condition to see which bar this is updating for.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      It's on bar close yes. But even so I don't understand how the condition bar numbers is different from the drawing bar numbers.

      Why is High[1] in the condition the 2nd bar from the right in the screenshot, but [1] on the drawing part of the strategy is the 3rd bar from the right. Surely both number should execute the same??

      Comment


        #4
        Hello several,

        What is the date time showing for the object in the Draw Objects window?

        Add debugging prints of the bar time within the action logic block where the drawing object is drawn so that we may compare.


        If the object is being drawn with barsAgo 0, this would appear on the bar where the condition that draws the object was true.

        If you are seeing the object appearing on the previous bar as a new bar opens, this would be due the object being drawn after the bar closed.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello, did you see the screenshot I posted in the OP? everything in the strategy is right there.

          Comment


            #6
            Hello several,

            The screenshot is only showing the drawing object is being drawn with Bars ago 1, so would be drawn on the previous bar.

            The print output would show us what time the condition drew the object and what bar to look on the previous bar.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Today, 05:17 AM
            0 responses
            50 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            126 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            69 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            42 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            46 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X