Announcement

Collapse
No announcement yet.

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.
            <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            559 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            324 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            546 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            547 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X