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

get price at specific time

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

    get price at specific time

    Hi,

    I would like to get the price at a specific time, including millisecond. What method can I use?

    For example, I want the price at 9:43:20:20, that is 9:43am at the 20 second mark and at the 20 millisecond mark, for example. How can I do that?

    Thanks

    #2
    Hi matt3m, NinjaTrader does not currently utilize millisecond resolution anywhere, but you can use the GetBar() function to find the bar number closest to the time you've specified and then just grab the close from that bar.

    AustinNinjaTrader Customer Service

    Comment


      #3
      Thank you for your reply.

      What is the smallest time frame I could get to ?

      Comment


        #4
        Hi matt3m,

        Bar time stamps are available up to 1 second resolution.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Austin, Is there a way to use a generic "yesterday" instead of a dateTime? for example, i wish to always plot a line at the price at 4:15 yesterday?

          Comment


            #6
            Hello trader3000a,

            Thanks for your note.

            You could create a variable named yesterday and assign yesterday's date based on what the current day is. Then you could check if ToDay(Time[0]) == yesterday and add a condition to check for the exact time you would like to plot your line. The code would look something like this.

            Code:
            int yesterday = ToDay(DateTime.Now.AddDays(-1)); // Gets yesterdays date based on what day it is currently.
            
            if (ToDay(Time[0]) == yesterday) // checks if current bars date is equal to yesterdays date
            {
                if (ToTime(Time[0]) == 161500) // checks if the current time is 4:15PM
                {
                    // Logic goes here
                }
            }
            Let us know if we may assist further.
            Brandon H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by ChastiJose, Today, 03:37 AM
            0 responses
            3 views
            0 likes
            Last Post ChastiJose  
            Started by Klaus Hengher, Today, 03:13 AM
            0 responses
            4 views
            0 likes
            Last Post Klaus Hengher  
            Started by ewileznwpods, Today, 02:57 AM
            0 responses
            1 view
            0 likes
            Last Post ewileznwpods  
            Started by 1001111, Today, 01:35 AM
            0 responses
            6 views
            0 likes
            Last Post 1001111
            by 1001111
             
            Started by ETFVoyageur, Yesterday, 07:05 PM
            1 response
            16 views
            0 likes
            Last Post ETFVoyageur  
            Working...
            X