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 real time

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

    Get real time

    Hello.

    When I use DateTime.Now, I get PC time.

    Can I get "real" world time (for example current qoutes server time)?
    Last edited by fx.practic; 09-18-2012, 03:44 PM.
    fx.practic
    NinjaTrader Ecosystem Vendor - fx.practic

    #2
    Depending on your data provider, the DateTime from Time[0] might be the server timestamp.

    Comment


      #3
      Thank You, Radical! It was real news for me!

      But, in purpose to protect my scripts, I'd like to have possibility to determine current date using any provider.
      fx.practic
      NinjaTrader Ecosystem Vendor - fx.practic

      Comment


        #4
        I don't think that's possible, at least not directly through the Ninja API. You might contact your data provider to see if they have their own API that has this functionality, and then you could just get the time through that API right from your NinjaScript.

        Comment


          #5
          Well, and is there a way to determine the name of current connectivity provider from indicator code?
          fx.practic
          NinjaTrader Ecosystem Vendor - fx.practic

          Comment


            #6
            Originally posted by fx.practic View Post
            Thank You, Radical! It was real news for me!

            But, in purpose to protect my scripts, I'd like to have possibility to determine current date using any provider.
            Your original question that was answered asked about Current Time. This response talks about Current Date. The date is the date. It is the same for every provider and the PC, unless your PC has the wrong date. Do I miss the import of the question?

            Comment


              #7
              Originally posted by koganam View Post
              Your original question that was answered asked about Current Time. This response talks about Current Date...
              Oh, I'm sorry. It was realy ambiguous.

              I want to protect my indicators from unlimited usage.
              Date (and time) on local PC can be changed manualy. So, I want to find way to check real date.

              After Radical said, that "Depending on your data provider, the DateTime from Time[0] might be the server timestamp" I decide to check (if possible) broker's name to ban usage when connected to brokers which not give own time-stamp.

              So, can any body tell how to check broker's name (when connected) or how to get real date?

              Does anybody can help, please?
              Last edited by fx.practic; 09-19-2012, 01:17 PM.
              fx.practic
              NinjaTrader Ecosystem Vendor - fx.practic

              Comment


                #8
                Originally posted by fx.practic View Post
                Oh, I'm sorry. It was realy ambiguous.

                I want to protect my indicators from unlimited usage.
                Date (and time) on local PC can be changed manualy. So, I want to find way to check real date.

                After Radical said, that "Depending on your data provider, the DateTime from Time[0] might be the server timestamp" I decide to check (if possible) broker's name to ban usage when connected to brokers which not give own time-stamp.

                So, can any body tell how to check broker's name (when connected) or how to get real date?

                Does anybody can help, please?
                In that case, you need to be able to check the date and time from a NTP server. Here are some links that have code to do that. You are going to have to massage the code to use it in NT, but, hey, it is just C#.

                Check if the expiration date of your application has been passed regardless of system date.


                Comment


                  #9
                  Thank you!
                  I see, I get what to do nearest couple of weeks.
                  This looks like universal solution.
                  fx.practic
                  NinjaTrader Ecosystem Vendor - fx.practic

                  Comment


                    #10
                    Originally posted by fx.practic View Post
                    Thank you!
                    I see, I get what to do nearest couple of weeks.
                    This looks like universal solution.
                    This seems to be a simpler, NT specific solution to the same problem. In fact, I think I am going to implement it myself. Just check the exchange time, and I will get the real time, even if the computer time has been turned back.



                    Somehow though, I wonder if this is even necessary. I seem to remember that the exchange does not send data if the local clock date is different from the exchange date. I will have to cross-check to be sure, though.
                    Last edited by koganam; 09-25-2012, 02:20 PM. Reason: Corrected punctuation.

                    Comment


                      #11
                      koganam, thanks a lot!

                      I made a little investigation. Results - on screenshot, indicator in attach.
                      I changed PC date and time and print it in all known ways. (My provider - AMP, they assign to ticks native time.)

                      Сonclusion: DateTime.Now == Bars.MarketData.Connection.Now == PC Time


                      There is once more way: to bound indicator to futures name:
                      Code:
                      if( Instrument.FullName != "CL 11-12" && Instrument.FullName != "ES 12-12" ) //get out
                      But this way is not very universal.
                      Attached Files
                      Last edited by fx.practic; 09-25-2012, 03:58 PM.
                      fx.practic
                      NinjaTrader Ecosystem Vendor - fx.practic

                      Comment


                        #12
                        Originally posted by fx.practic View Post
                        koganam, thanks a lot!

                        I made a little investigation. Results - on screenshot. I changed PC date and time and print it in all known ways. (My provider - AMP, they assign to ticks native time.)

                        Сonclusion: DateTime.Now == Bars.MarketData.Connection.Now == PC Time

                        There is once more way: to bound indicator to futures name:
                        if( Instrument.FullName != "CL 11-12" && Instrument.FullName != "ES 12-12" ) //get out

                        But this way is not very universal.
                        So it appears then that AMP/CQG provides the actual time stamp to its data, so that Time[0] is actually the correct time? Hm. Not sure that all providers do that. You may still need to check that NTP Server, for a universal solution.

                        Comment


                          #13
                          Originally posted by Radical View Post
                          Depending on your data provider, the DateTime from Time[0] might be the server timestamp.

                          http://www.ninjatrader.com/support/h...rical_data.htm
                          8 providers support and 7 not support native Real-Time Timestamp.

                          So, I agree with You - It's better to check some SNTP servers.
                          fx.practic
                          NinjaTrader Ecosystem Vendor - fx.practic

                          Comment


                            #14
                            Originally posted by fx.practic View Post
                            8 providers support and 7 not support native Real-Time Timestamp.

                            So, I agree with You - It's better to check some SNTP servers.
                            Aaaaghh. Back to the drawing board it is then.

                            Comment


                              #15
                              Your original question that was answered asked about Current Time
                              Last edited by peterr89; 11-28-2012, 07:57 PM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Tburg1073, Today, 08:36 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post Tburg1073  
                              Started by alexstox, 10-16-2018, 03:29 PM
                              10 responses
                              333 views
                              0 likes
                              Last Post Tburg1073  
                              Started by smartromain, 03-13-2024, 01:42 AM
                              6 responses
                              98 views
                              0 likes
                              Last Post smartromain  
                              Started by Jonker, 04-27-2024, 01:19 PM
                              4 responses
                              29 views
                              0 likes
                              Last Post Jonker
                              by Jonker
                               
                              Started by Yasharandom, Today, 07:45 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post Yasharandom  
                              Working...
                              X