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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    68 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    39 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    63 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    62 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X