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 funk10101, Today, 09:43 PM
    0 responses
    3 views
    0 likes
    Last Post funk10101  
    Started by pkefal, 04-11-2024, 07:39 AM
    11 responses
    36 views
    0 likes
    Last Post jeronymite  
    Started by bill2023, Yesterday, 08:51 AM
    8 responses
    44 views
    0 likes
    Last Post bill2023  
    Started by yertle, Today, 08:38 AM
    6 responses
    26 views
    0 likes
    Last Post ryjoga
    by ryjoga
     
    Started by algospoke, Yesterday, 06:40 PM
    2 responses
    24 views
    0 likes
    Last Post algospoke  
    Working...
    X