Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Getting the Price at a specific moment in time

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

    Getting the Price at a specific moment in time

    I have 3 questions:

    I am applying a strategy to a one minute chart--but want to use the price at specific time (such as 9:27:30 AM) - to set a limit entry price from.

    1) What is the best way to get a price to use (O,H,L,C or Bid, Ask) for a specific time-since I can't be sure that there will be a incoming tick for that specific moment in time?Essentially what I want is the last traded price as close to that time as possible (withing 3-5 seconds)

    2) Am I right in assuming that even if I set
    CalculateOnBarClose = false, that there are not necessarily O,H,L,C values for the bar at time = 092730 unless there is a trade at that moment?



    3) Lastly--if I wanted the open price at say 8:30 AM-- would that be the Time stamp of 83000 or 83100 on a one minute chart?
    Jim-Boulder
    NinjaTrader Ecosystem Vendor - Elephant Tracks

    #2
    Hello Jim-Boulder,

    Thank you for your post.

    1. You could use DateTme.Now to pull the PC's time rather than the bar time, however, you would still need to rely on the OnBarUpdate() method which would occur on a bar update only, whether COBC true or false.

    2. Correct, even with COBC = false and using a tick based interval the Time[0] will not update until a trade occurs.

    3. This is also correct, with a 1 minute bar the time stamp is the close. So 83100 would be the timestamp of the bar that opens at 8:30 AM.

    Comment


      #3
      So what is the solution to the below question? How do I retrieve the closing price at a specific time, for price comparisons? Say I want to evaluate if the current price is higher/lower than the price was at a specific time earlier in the day.

      Comment


        #4
        Hello,

        NinjaTrader methods are locked to the period you select and the COBC setting and also the incoming data, all three play a roll in the timing of the OnBarUpdate and other events.

        To get a precise time such as your example, there is always the chance that there will not be a tick or data received or OnBarUpdate to continue your logic at that exact time. In general, OnMarketData will be called very quickly as data comes in, if you are trading a very active symbol there will likely be market data during the time you are looking to get. you could try to move this logic into OnMarketData, and check the Time of the data that is coming in to do logic. Note this would only work in realtime. http://www.ninjatrader.com/support/h...b=OnMarketData

        Otherwise It would be best to try a range of time to get your results, similar to the example for ToTime: http://www.ninjatrader.com/support/h...ightsub=totime

        I look forward to being of further assistance.

        Comment


          #5
          For my purposes, the Close price of a 1 minute data series would be sufficient.
          What is the code I need for that? A complication is that I may not necessarily be using a 1-min chart in my strategy. Do I need to make a multi-series script in that case?

          Comment


            #6
            Hello,

            Yes, any time the Chart series is different than what you want the logic to be, you would use a multi series script.

            If you think of it as "I want to do something a X interval" you would need to have X data series added by the script to ensure that happens. If you know you will only use this on a 1 minute chart, then a multi series script would not be needed but for flexibility adding a series will allow you to program knowing any chart you put this on, it will use the correct series for the logic.

            For this, I would recommend looking at the SampleMultiTImeFrame strategy if you have not already and also the following links:





            I look forward to being of further assistance.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            558 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
            545 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