Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Last bar

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

    Last bar

    Is there a quick way in NT8 to determine if the current bar being evaluated is the last painted bar on the chart?

    #2
    Hello,

    To locate the Last bar, you could use ChartBars.ToIndex.

    This would be one example of a way to calculate this:

    Code:
    int mode = Calculate == Calculate.OnBarClose ? 1 : 0;
    Print(CurrentBar + " " +(ChartBars.ToIndex - mode));
    The mode variable in this example accounts for changing the Calculate mode, this is not necessary if you will be using OnEachTick, for OnBarClose you would need to adjust the count minus 1.

    For a real world use of ChartBars.ToIndex, please see the Misc region in the Pivots indicator.


    I look forward to being of further assistance.

    Comment


      #3
      Jesse, how would on price change be treated; i.e. what would the mode calculation be for Calculate.OnPriceChange?

      Comment


        #4
        Hello,

        This should handle both tick or price change, the Count would change depending on if you have Intra bar granularity or not.

        Using a Print without subtracting the value like shown in the previous example would better highlight the index differences when you toggle the setting.

        Code:
        Print(CurrentBar + " " +ChartBars.ToIndex);
        I look forward to being of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        557 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        324 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        545 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        547 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X