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

Time associated with a bar

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

    Time associated with a bar

    Hi

    This might be drop-dead easy, but I've searched around in the manuals and cannot find the solution to it.

    I would like to back-test trading certain futures contracts, but want to limit trading to only a certain time of day.

    When back-testing the strategy on historical data, how can I tell what time of day it is when onbarupdate is called? I.e. is there a bar property that refers to its timestamp?

    Thank you
    Jan

    #2
    Originally posted by janseun View Post
    When back-testing the strategy on historical data, how can I tell what time of day it is when onbarupdate is called? I.e. is there a bar property that refers to its timestamp?
    Yes, there is a Time series.

    When OnBarUpdate() is called, Time[0] will contain the date & time of when the bar closed.

    Also check out this reference sample:
    Last edited by bltdavid; 04-20-2017, 11:06 PM.

    Comment


      #3
      Hello Jan,

      Thanks for your post and welcome to the NinjaTrader forums!

      Member bltdavid has provided a good answer to your question. To supplement, here are specific references in the helpguide that are related:
      Time[n]: http://ninjatrader.com/support/helpG...eries_time.htm
      ToTime(): http://ninjatrader.com/support/helpG...us/?totime.htm

      Also, another example of working with datetime objects: http://ninjatrader.com/support/forum...ad.php?t=19292
      Paul H.NinjaTrader Customer Service

      Comment


        #4
        Awesome, that does it! Thank you for the help. Don't know how I missed those.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cmtjoancolmenero, Yesterday, 03:58 PM
        4 responses
        24 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Brevo, Today, 01:45 AM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by rjbtrade1, 11-30-2023, 04:38 PM
        2 responses
        74 views
        0 likes
        Last Post DavidHP
        by DavidHP
         
        Started by suroot, 04-10-2017, 02:18 AM
        5 responses
        3,022 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by Stanfillirenfro, Today, 07:23 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X