Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Processing Historical Bars while CalculateOnBarClose=False

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

    Processing Historical Bars while CalculateOnBarClose=False

    With regards to OnBarUpdate,

    When COBC=True, the BarsAgo index of the most recently closed bar is 0.
    When COBC=False, the BarsAgo index of the most recently closed bar is 1.

    Ok, during the time period in which Historical bars are processed by OnBarUpdate,
    what is the correct BarsAgo index for the most recently closed bar?

    The essential questions are,

    1. When Historical is true, should the code ignore COBC setting and always use 0?
    2. When Historical is False, should the code always use '0' for COBC=True and '1' for COBC=False?

    For example, the above two statements can be expressed in code with,

    Code:
    public int FirstBarsAgo {
        get {
            return Historical ? 0 : CalculateOnBarClose ? 0 : 1;
        }
    }
    When processing OnBarUpdate, does the code above give the correct BarsAgo index for the
    most recently closed bar for all combinations of Historical and CalculateOnBarClose?


    #2
    Hello bltdavid,

    Thank you for your post.

    If historical is true, it will always calculate OnBarClose.

    You would want to test this custom logic, but at first glance your code would give the correct BarsAgo index. You could do something similar by using FirstTickOfBar, which is only true when you're not using OnBarClose. So you could change the index you're using depending on whether FirstTickOfBar is true and not have to use the above code.

    Here's a link to our help guide that goes over FirstTickOfBar:



    Please let us know if we may be of further assistance to you.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    558 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