Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Knowing it is the last bar interation in OnBarUpdate()

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

    Knowing it is the last bar interation in OnBarUpdate()

    Hi,

    I'm doing a calculation inside OnBarUpdate() and want the result of the last bar to export to a file.
    How can I know I'm in the last bar?
    For example the first bar I can check with CurrentBar == 1 but how can I know I'm in the last iteration(bar)?

    Thanks in advance,
    Roy

    #2
    Hello,

    Thanks for your note.

    So that I understand this correctly you want the last bar of the session.

    You will want to use the following method:



    This will get you the time of the end of the session.

    Then you would in OnBarUpdate() check if it is equal to the time and then output your data that you need to export.

    I look forward to assisting you further.
    BrettNinjaTrader Product Management

    Comment


      #3
      Hi Brett,

      No I'm not looking for the last bar of the session but the last bar of the whole time frame.
      For example if I'm using 365 days chart with my indicator I'll want to know the last bar on this year.
      Is there a way to know it?

      Thanks!

      Comment


        #4
        Hello,

        Ok, but whats your definition of a full chart in this case? Just historical data?, as a chart doesnt just end when you have live data flowing into it will continue to form live. The below will output the historical data for the chart only and no live data.

        Mabye this is more what your looking for, if (CurrentBar== Bars.Count -2)

        Let me know if I can be of further assistance.
        BrettNinjaTrader Product Management

        Comment


          #5
          Thanks Brett it works!
          What a great support team NT has!

          Comment


            #6
            Hello,

            Thanks! Excellent.

            Let me know if I can be of further assistance.
            BrettNinjaTrader Product Management

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by sjsj2732, 03-23-2026, 04:31 AM
            0 responses
            42 views
            0 likes
            Last Post sjsj2732  
            Started by NullPointStrategies, 03-13-2026, 05:17 AM
            0 responses
            294 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            290 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            135 views
            1 like
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            98 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Working...
            X