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 Mindset, 04-21-2026, 06:46 AM
            0 responses
            87 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            132 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            68 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by cmoran13, 04-16-2026, 01:02 PM
            0 responses
            118 views
            0 likes
            Last Post cmoran13  
            Started by PaulMohn, 04-10-2026, 11:11 AM
            0 responses
            67 views
            0 likes
            Last Post PaulMohn  
            Working...
            X