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 rhyminkevin, Today, 04:58 PM
              4 responses
              52 views
              0 likes
              Last Post dp8282
              by dp8282
               
              Started by iceman2018, Today, 05:07 PM
              0 responses
              5 views
              0 likes
              Last Post iceman2018  
              Started by lightsun47, Today, 03:51 PM
              0 responses
              7 views
              0 likes
              Last Post lightsun47  
              Started by 00nevest, Today, 02:27 PM
              1 response
              14 views
              0 likes
              Last Post 00nevest  
              Started by futtrader, 04-21-2024, 01:50 AM
              4 responses
              50 views
              0 likes
              Last Post futtrader  
              Working...
              X