Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

setting Exchange time or Local Time

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

    setting Exchange time or Local Time

    hi, i want setting Exchange time or Local Time for CME


    how i set it? thanks

    #2
    Hello esignal,

    Thank you for your note.

    Please go to the NinjaTrader Control Center > Tools > Options > General > Time Zone. Here you can set whatever time zone you wish to use.

    For more information on the Options in NinjaTrader 8 please visit the following link: http://ninjatrader.com/support/helpG...us/options.htm

    Please let me know if you have any questions.

    Comment


      #3
      i want setting time for each market
      Example : Cme i want set time of New York
      Idem i want set time of Rome

      Comment


        #4
        Hello esignal,

        Thank you for your response.

        There is no option to set NinjaTrader to more than one time zone. By default NinjaTrader will use the PC's time zone, but in NinjaTrader 8 you can set the time zone specifically by going to the NinjaTrader Control Center > Tools > Options > General > Time Zone option.

        Please let me know if you have any questions.

        Comment


          #5
          how can you convert the NT time zone to local computer time?

          Comment


            #6
            would this be the way to do it?

            TimeZoneInfo.ConvertTime(time, Bars.TradingHours.TimeZoneInfo, TimeZoneInfo.Local);

            Comment


              #7
              Hello NinjaCustomer,

              Thanks for your post.

              The code you posted will convert time to whatever your PC time zone is set to. The DateTime object also has the ToLocalTime method.

              Please let me know if you have additional questions.
              Chris L.NinjaTrader Customer Service

              Comment


                #8
                can I reduce this code to: TimeZoneInfo.ConvertTime(time, TradingHours.TimeZoneInfo, TimeZoneInfo.Local); ?

                I mean in a Strategy would TradingHours and Bars.TradingHours be equivalent? I ask because I'm getting an object not set reference error in OnExecutionUpdate for some strange reason when I disable the strategy (when I enable it and have it running there is no such error).. and that code uses Bar.TradingHours , so I'm hoping by changing to to TradingHours that it will avoid this NullReferenceException

                Comment


                  #9
                  Hello NinjaCustomer, thanks for your reply.

                  I would recommend stepping through the code with the Visual Studio debugger to find that issue. See here for info on how to set this up:



                  I'm not seeing a Bars.TradingHours property in the help guide here, even though it is indeed a property of the bars object. So it looks like the supported way would be to use the plain TradingHours object.

                  Kind regards.
                  Chris L.NinjaTrader Customer Service

                  Comment


                    #10
                    I do know it is from this line of code because I luckily got a dialog with a stack trace but I can't reproduce it consistently, which means it would takes hours if I'm lucky to have the exception be triggered. so hopefully this TradingHours is always available at this point in my code, when (in rare cirumstances) Bars might be null for some strange reason.. I'm reasonably sure it must be Bars being null sometimes when referenced in OnExceutionUpdate upon disabling the strategy that is causing the exception since the rest of the code that the stacktrace leads to looks ok

                    Comment


                      #11
                      Hi,
                      I came accross this thread as I am having issues with the convertion from the exchange time to local time. I am using this code:

                      if (UseTimeFilter && (ToTime(Time[barIndex].ToLocalTime())<FilterTimeFrom || ToTime(Time[barIndex].ToLocalTime())>FilterTimeUntil))
                      {
                      if (!isTimeFilterActive && EnableLogging)
                      Log("PC Time <"+ DateTime.Now +"> Bar Time <"+ Time[0].ToLocalTime() +"> <"+VERSION+"> <"+Instrument.FullName+"> ENTRY TIME FILTER TRUE! FilterTimeFrom:<"+FilterTimeFrom+"> FilterTimeUntil<"+FilterTimeUntil+">", LogLevel.Information);
                      isTimeFilterActive = true;
                      return true;
                      }

                      My local Server (Windows 2019 Server) is set to UTC +1 (Amsterdam, Berlin, Bern ......) and I am having a second, additional timezone which is UTC
                      The return for Time[0].ToLocalTime() though is my timezone -1. E.g. if my timezone is 85000 am it returns 75000.

                      There could be two issue now:

                      1) the method is wrong because of different activation of daylight saving time (US did switch last weekend, europe is going to switch end of march). Unfortunately I am using the method as of this week. So I do not know if the return value was correct last week (before daylight saving time in the US)
                      2) the method is returning my second timezone of the server

                      I know .ToLocalTime() is not officially supported but you might want to have a look at it.
                      Thanks,

                      Comment


                        #12
                        Hi klaus, thanks for your note.

                        NinjaTrader already has a time zone setting which should be set to your UTC +1 time zone under Tools>Options>General. There would be no need to use ToLocalTime, this is offsetting the time incorrectly for me. ToTime(Time[barIndex]) would return the correct time for you.



                        Chris L.NinjaTrader Customer Service

                        Comment


                          #13
                          Hi Chris,
                          thanks for your answer. The Time Settings in the Option Setting is alreaday set to CET.
                          Please have a look at the attached screenshot. I am running my strategy on a minute bar. You see, the server time is around 140000. The Bar Time which is printed by the code which I posted here is printing around 150000.
                          Something is wront here.
                          Please have a look at it.
                          Thanks,
                          Klaus

                          Comment


                            #14
                            Hi Hlaus, thanks for your reply.

                            I tested by setting my Windows time zone to your time zone, then I tested with ToTime(Time[barIndex].ToLocalTime() and without ToLocalTime(). The time I received was in the correct time zone. Can you confirm you tried taking out ToLocalTime()?


                            Chris L.NinjaTrader Customer Service

                            Comment


                              #15
                              Hi Chris,
                              I attached the original code which I am using. The Server (Windows Server 2019) are also attached.
                              I am using the ToLocalTime() for logging. The hour difference is not problem here. The problem is the when I use the time as a filter. I have to calculated the correct time to enter in my strategy and that is quite confusing. I am sure that the problem disappears when we go to summertime in europe. Please find also the code for the filter attached...
                              Klaus

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Perr0Grande, Yesterday, 08:16 PM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by f.saeidi, Yesterday, 08:12 AM
                              3 responses
                              24 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by algospoke, Yesterday, 06:40 PM
                              1 response
                              14 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by quantismo, Yesterday, 05:13 PM
                              1 response
                              13 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by The_Sec, 04-16-2024, 02:29 PM
                              3 responses
                              16 views
                              0 likes
                              Last Post NinjaTrader_ChristopherS  
                              Working...
                              X