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 DannyP96, 05-18-2026, 02:38 PM
    1 response
    27 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    117 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    69 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    226 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    414 views
    0 likes
    Last Post CaptainJack  
    Working...
    X