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 sjsj2732, Yesterday, 04:31 AM
        0 responses
        22 views
        0 likes
        Last Post sjsj2732  
        Started by NullPointStrategies, 03-13-2026, 05:17 AM
        0 responses
        280 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        279 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        130 views
        1 like
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        90 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Working...
        X