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 burtoninlondon, Today, 12:38 AM
    0 responses
    5 views
    0 likes
    Last Post burtoninlondon  
    Started by AaronKoRn, Yesterday, 09:49 PM
    0 responses
    14 views
    0 likes
    Last Post AaronKoRn  
    Started by carnitron, Yesterday, 08:42 PM
    0 responses
    11 views
    0 likes
    Last Post carnitron  
    Started by strategist007, Yesterday, 07:51 PM
    0 responses
    13 views
    0 likes
    Last Post strategist007  
    Started by StockTrader88, 03-06-2021, 08:58 AM
    44 responses
    3,982 views
    3 likes
    Last Post jhudas88  
    Working...
    X