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

determine first and last available bars in BarsArray

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

    determine first and last available bars in BarsArray

    Dear NT fans & team,

    I am working on a multi-instrument strategy, which I'd like to back-test over several years of daily bars. Not all instruments will be available throughout the full back-testing period, and I need to be able to figure out which instruments are available at any given point in time.

    The information is available; when I run my strategy in the debugger I see exactly what I am looking for under 'BarsArray[...]' labelled as 'firstTime' and 'lastTime'. Unfortunately, I can't figure out where MSVC got this information from, as fields with these names don't seem to exist. I have attached a screenshot.

    The time of the last bar is available as 'BarsArray[...].BarsSeries.LastBarTime', but there does not seem to be an equivalent for the first bar time.

    Please note that the information I am looking for is not equivalent to 'BarsArray[…].FromDate' and 'BarsArray[…].ToDate'; those only hold the date range of the strategy analyzer but not the subset thereof I am looking for.

    Any pointers on this are highly appreciated!

    Thank you,
    best regards

    Felix
    Attached Files

    #2
    Hello fbertram,

    Thanks for your post.

    You could use BarsArray.GetTime() for the starting index (0) and the index for Bars.Count, to get the time of the starting and ending bar. Keep in mind, this will not tell you if there is a gap in the data that you have on your platform. I may recommend viewing a chart for that particular data series to be certain the data exists on your platform.

    Code:
    Print(BarsArray[0].GetTime(BarsArray[0].Count));
    Print(BarsArray[0].GetTime(0));
    Please let us know if you have any additional questions.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by bmartz, 03-12-2024, 06:12 AM
    5 responses
    32 views
    0 likes
    Last Post NinjaTrader_Zachary  
    Started by Aviram Y, Today, 05:29 AM
    4 responses
    13 views
    0 likes
    Last Post Aviram Y  
    Started by algospoke, 04-17-2024, 06:40 PM
    3 responses
    28 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by gentlebenthebear, Today, 01:30 AM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by cls71, Today, 04:45 AM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X