Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CalculateOnBarClose = false question

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

    CalculateOnBarClose = false question

    I have a strategy attached to a chart. The strategy has CalculateOnBarClose = false;

    When I reference Closes[0][0], sometimes it refers to the open bar and sometimes the bar before the open bar. The reference can be triggered by a button on the chart. i.e. update or from the code on a firstTick/OnBarUpdate event. -- i.e. i have a manual override to calculate the strategy instead of waiting for the next firsttick.

    So the question is, can the Closes[0][0] sometimes refer to an open bar and sometimes the 1st closed bar, given the different sources of the call. Are there any reasons I wouldn't betting getting the open bar at all times with Closes[0][0]?

    Thanks
    Rich

    #2
    Hi Rich,

    It can vary here, depending on whether the bar update is marked as historical. The bar referencing model for multiseries script changes whether you're accessing historically or real time.


    If you get a real time update on Closes[0][0] and are running with COBC = false, then you should generally expect that this refers to the most recent bar - the one currently forming.

    If you access this value in a multiseries script, you should filter within a specific BarsInProgress, so that you're not looking at the value within the context of another series' updates.

    if (BarsInProgress == 0)
    Print(Closes[0][0]);
    Ryan M.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    72 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    44 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    25 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    30 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    61 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X