Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Kate W.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by quantismo, 04-17-2024, 05:13 PM
    4 responses
    30 views
    0 likes
    Last Post quantismo  
    Started by love2code2trade, 04-17-2024, 01:45 PM
    4 responses
    31 views
    0 likes
    Last Post love2code2trade  
    Started by cls71, Today, 04:45 AM
    2 responses
    10 views
    0 likes
    Last Post eDanny
    by eDanny
     
    Started by proptrade13, Today, 11:06 AM
    0 responses
    5 views
    0 likes
    Last Post proptrade13  
    Started by kulwinder73, Today, 10:31 AM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Erick  
    Working...
    X