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 sjsj2732, Today, 04:31 AM
            0 responses
            20 views
            0 likes
            Last Post sjsj2732  
            Started by NullPointStrategies, 03-13-2026, 05:17 AM
            0 responses
            280 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            279 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            130 views
            1 like
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            90 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Working...
            X