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 current time (Seconds or MS precision) of current feed (nstead of DateTime.Now)

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

    Get current time (Seconds or MS precision) of current feed (nstead of DateTime.Now)

    I used something like this:

    DateTime now = Connection.PlaybackConnection != null ? Connection.PlaybackConnection.Now : DateTime.Now;

    to get current time, but i see that it's faulty.
    If i am not in MarketReplay, then it gets DateTime.Now, which is 1 minute (or i.e. 36 seconds or whatever) different that feed's time.
    How to get current real-time from feed-data?

    I've been thinking about: "Cbi.Connection.Connections[0].Now", but i dont know which connection index is used by current chart symbol.
    Last edited by ttodua; 03-03-2019, 05:21 AM.

    #2
    Hello TazoTodua,

    Are you asking how the get the time of the bar?

    Thats the Time[0] object which is a DateTime object which for NinjaTrader 8 has millesecond granularity if thats what you are printing in your print.

    If you want each tick then add a 1 tick series.

    Below is a link to the help guide on the Time[0] object.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Oh ChelseaB, no, TIme[0] is irrelevant. Let's say i have a hourly chart open and attached indicator(set OnEachTick):

      then time[0] just prints, i.e.:

      14:00:00
      15:00:00
      (if live bar, then it prints multiple times, on each time
      16:00:00
      16:00:00
      ...
      etc...

      I Dont want to get bar's closing time, i want the live time, how can i explain it better i donno.
      like:

      15:33:54
      15:33:55
      etc...

      in the second granularity, without need of using `AddDataSeries`. Just using with OnEaechTick should be enough. I've described in question how i could.

      Comment


        #4
        Hello TazoTodua,

        If you want each tick's time then add a 1 tick series.

        Or get the time of the update in OnMarketData().
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          How to get time of current update (when not using AddDataSeries) in OnMarketData?

          Comment


            #6
            Hello TazoTodua,
            Code:
            protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
            {
                Print(marketDataUpdate.Time);
            }
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Excellent! probably somehow there could be accessible last update time from OnBarUpdate too, i will try to find something.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by bortz, 11-06-2023, 08:04 AM
              47 responses
              1,604 views
              0 likes
              Last Post aligator  
              Started by jaybedreamin, Today, 05:56 PM
              0 responses
              8 views
              0 likes
              Last Post jaybedreamin  
              Started by DJ888, 04-16-2024, 06:09 PM
              6 responses
              18 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by Jon17, Today, 04:33 PM
              0 responses
              4 views
              0 likes
              Last Post Jon17
              by Jon17
               
              Started by Javierw.ok, Today, 04:12 PM
              0 responses
              13 views
              0 likes
              Last Post Javierw.ok  
              Working...
              X