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 fx.practic, 10-15-2013, 12:53 AM
            5 responses
            5,403 views
            0 likes
            Last Post Bidder
            by Bidder
             
            Started by Shai Samuel, 07-02-2022, 02:46 PM
            4 responses
            94 views
            0 likes
            Last Post Bidder
            by Bidder
             
            Started by DJ888, Yesterday, 10:57 PM
            0 responses
            6 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by MacDad, 02-25-2024, 11:48 PM
            7 responses
            158 views
            0 likes
            Last Post loganjarosz123  
            Started by Belfortbucks, Yesterday, 09:29 PM
            0 responses
            8 views
            0 likes
            Last Post Belfortbucks  
            Working...
            X