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

Ho to get 'TimeZoneInfo' for Control Center's 'Tools/Options/General/Time zone' ?

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

    Ho to get 'TimeZoneInfo' for Control Center's 'Tools/Options/General/Time zone' ?

    It's not the same as 'Bars.TradingHours.TimeZoneInfo' time zone, that is configured by a 'Trading Hours' template.

    As it is said here:

    Time zone

    Sets the time zone that NinjaTrader will use. All charts and market data will be displayed in this time zone. Time zones are set to your local PC time by default.
    And so, by default 'MarketDataEventArgs' instance's 'Time' property returns DateTime value in the local PC time, though 'Kind' property of the latter is set to 'DateTimeKind.Unspecified'. We can check that with the following code:

    Code:
    protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
    {
        if (marketDataUpdate.MarketDataType == MarketDataType.Last)
            Print(string.Format("{0:yyyy-MM-dd HH:mm:ss.fffffff} ({1})", marketDataUpdate.Time, marketDataUpdate.Time.Kind));
    }
    If then I go to Control Center's 'Tools/Options/General' and set its 'Time zone' to 'Utc', then the above code will give me 'DateTimeKind.Utc'.

    Everything is correct. But how can I programmatically find out the Control Center's 'Tools/Options/General/Time zone' in the previous case, if it's not set to 'Utc' ? Where can I get its TimeZoneInfo ?
    Last edited by quicktrick; 03-08-2017, 02:56 AM.

    #2
    Hello quicktrick,

    Thanks for writing in to our Support Forums!

    The Kind property of a DateTime object will only specify Local, UTC, or Unspecified if the time is not set to UTC.

    You may work around this by comparing the current time to the time in UTC to determine which timezone the user has specified. For example:

    Code:
    		protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
    		{
        		if (marketDataUpdate.MarketDataType == MarketDataType.Last)
    			{
    				if (marketDataUpdate.Time.ToUniversalTime() > marketDataUpdate.Time)
    					Print("UTC -"+(marketDataUpdate.Time.ToUniversalTime() - marketDataUpdate.Time));
    				else if (marketDataUpdate.Time.ToUniversalTime() < marketDataUpdate.Time)
    					Print("UTC +"+(marketDataUpdate.Time - marketDataUpdate.Time.ToUniversalTime()));
    			}
    		}
    The code above will tell you the timezone in terms of the offset from UTC.

    Please reference the MSDN documentation for information on using the ToUniversalTime() method. I will link it below:


    If you have any other questions, please don't hesitate to ask.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thank you Jim, but such a... "solution" is... somewhat like... contrary to what is logical. Perhaps, your developers consider the possibility to add TimeZoneInfo for that profound feature, needed literally in every time-concerning functionality?

      Comment


        #4
        Hello quicktrick,

        Thanks for the reply.

        I understand the convenience of having the timezone value available without calculation. I have submitted a feature request on your behalf to have this timezone value exposed via NinjaScript. It is being tracked with the ticket ID SFT-2010. You may reference this feature request's implementation in the release notes of the version of NinjaTrader 8 that includes that feature. You can view the release notes here: https://ninjatrader.com/support/help...ease_notes.htm

        You may also write in to platformsupport[at]ninjatrader[dot]com with the ticket ID to request a status update on the feature request.

        Please let me know if I may be of further help.
        JimNinjaTrader Customer Service

        Comment


          #5
          By the way, Jim, when I receive historical market data (State == State.Historical), its 'Time.Kind' property is always set to 'DateTimeKind.Unspecified', regardless of the Control Center's 'Tools/Options/General/Time zone' setting ('UTC' or whatever). Only Realtime market data has its 'Time.Kind' property set in accordance with the 'Time zone' setting. I don't think this is a correct behavior.

          Comment


            #6
            Hello quicktrick,

            Thanks for providing me that information. I witness the same behavior you are describing and I will forward your note to the development team for their analysis.
            JimNinjaTrader Customer Service

            Comment


              #7
              As stated in the posts below, NinjaTrader 8 allows for selecting the time zone under Options -> General -> Preferences -> Time Zone.

              This time zone is used for storing all historical data.
              Also it is used for time stamping all chart bars.

              How can I programmatically access this timezone?

              It would be a very basic feature to be able to access the timezone that NinjaTrader uses for storing historical data and for displaying all charts.

              Is this the request tracked under SFT-2010?

              Comment


                #8
                Hello Harry,

                Yes, this is being tracked with SFT-2010. There currently is not a way to look up the user's timezone via NinjaScript.

                I have added a vote for this feature request on your behalf.

                Feature Requests that are filled will be noted in the Release Notes page of the help guide.

                Release Notes: https://ninjatrader.com/support/help...ease_notes.htm

                Please let me know if I may be of further assistance.
                JimNinjaTrader Customer Service

                Comment


                  #9
                  I think this is rather urgent!

                  Jim,

                  Thank you for your answer.

                  There are numerous trading applications for which it is essential that time stamps are converted from exchange time to chart time and vice-versa.


                  Needed for a large number of trading applications

                  List of indicators that will not work properly with NinjaTrader 8, when the user selects a preferred timezone other than the timezone of the PC

                  -> daily VWAP (regular session)
                  -> weekly VWAP (regular session)
                  -> monthly VWAP (regular session)
                  -> opening range indicator (regular session)
                  -> inital balance range bands (regular session)
                  -> daily pivot (regular session)
                  -> weekly pivots (regular session)
                  -> monthly pivots (regular session)
                  -> relative volume (comparing volume to prior trading days requires conversion to exchange time)
                  -> relative ranges (comparing volatiltiy to prior trading days requires conversion to exchange time)

                  I have currently over 30 indicators for NinjaTrader 8 on hold which do not work correctly, because the timezone of the chart bars is unknown! All our trading strategies are based on these indicators.

                  Also we are talking about 60,000 downloads in the indicator section of www.futures.io and about 10,000 downloads in the NinjaTrader forum (downloads were for NT7, indicators are being converted to NT8)


                  No workaround

                  Also it is not possible to second guess the correct TimeZoneInfo by comparing real-time data with the current time of the PC. First of all such a guess is not possible for historical charts. Second the offset calculated does not tell me the entire truth, as offsets are variable due to different daylight savings schedules.


                  Problem occurs when customer changes preset time preference

                  Shall I tell all my NinjaTrader customers that they are allowed to change the preferred time settings under options, but that all indicators will stop working then? Just because it is impossible to access the preferred timezone programmatically?

                  Or do I need to add a TimeZoneInfo Property to each of the 30 indicators, where the customer sets the same timezone that he has already selected under Tools -.> Options -> General -> Preferences -> TimeZone?


                  Please fix it - it is a very, very basic feature which should be available!

                  For me it is unbelievable that the very, very basic information of the time zone which is used

                  -> for all historical data
                  -> for all real-time data
                  -> for all trading charts

                  cannot be accessed.

                  Please fix it.This is an omission by developers who have added a new feature but not thought about the implications. Moreover I know that it is a very easy fix.
                  Last edited by Harry; 06-15-2017, 09:04 AM.

                  Comment


                    #10
                    Vote +1 for SFT-2010

                    Comment


                      #11
                      Hello,

                      @ntuser2017, Vote added!

                      @Harry, I've submitted your feedback to the feature request ticket.

                      If there is anything else I can do to help, please let me know.
                      JimNinjaTrader Customer Service

                      Comment


                        #12
                        Requesting fix for SFT-2010

                        Comment


                          #13
                          Vote +1 for SFT-2010

                          Comment


                            #14
                            Vote +1 for SFT-2010

                            Comment


                              #15
                              Vote +1 for SFT-2010

                              Vote +1 for SFT-2010

                              And lets do it quickly, before I completely move off to that other platform which already does so much faster, better, and cheaper.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by junkone, Today, 11:37 AM
                              2 responses
                              12 views
                              0 likes
                              Last Post junkone
                              by junkone
                               
                              Started by frankthearm, Yesterday, 09:08 AM
                              12 responses
                              43 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by quantismo, 04-17-2024, 05:13 PM
                              5 responses
                              35 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by proptrade13, Today, 11:06 AM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by love2code2trade, 04-17-2024, 01:45 PM
                              4 responses
                              35 views
                              0 likes
                              Last Post love2code2trade  
                              Working...
                              X