Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time Zones - remote server question

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

    Time Zones - remote server question

    I'm developing a strategy that is only intended to be used during CME open market hours. In Denver (Mountain Time Zone), that falls between 7:30 am and 2:15 pm. However, I'd like to deploy this strategy on a virtual remote server which is located in Chicago. Chicago, of course, is in the Central Time Zone, where the market's open from 8:30 am to 3:15 pm.

    So my problem is: the time zones for my development machine and my deployment machine are different. Is there a programmatic way to handle time and time zones? Can you specify a time zone - say, tell your strategy "I want you to be active between 8am and 2pm, Central Standard Time" - and have NinjaTrader be aware of the time zone of the machine it's currently running on?

    Right now, I'm actually making code changes before uploading my strategy to my remote server, but that's not terribly good coding practice.

    #2
    Hello pbailey19,

    Thank you for the question I will be happy to assist.

    If you are looking to create a condition based on the time zone you could use

    Code:
    Bars.Session.TimeZoneInfo.Id
    This returns the time zone name as a string for the selected session template. You could use that in an if statement to determine what time zone and adjust the times accordingly.

    Alternatively you could get the session template information as DateTime objects. There is a great example of this located in the help guide located here: http://www.ninjatrader.com/support/h...xtbeginend.htm

    The first portion of the example will give you the start time and end time of the selected session template and you could base the times off of that.

    Code:
    private DateTime sessionBegin;
    private DateTime sessionEnd;
     
    protected override void OnBarUpdate()
    {
        if (Bars.FirstBarOfSession)
             Bars.Session.GetNextBeginEnd(BarsArray[0], 0, out sessionBegin, out sessionEnd);
     
        Print("Session Start: " + sessionBegin + " Session End: " + sessionEnd);
    }

    Here is some more documentation on both of the above examples


    Please let me know if I may be of additional assistance.

    Comment


      #3
      So I quick edited one of my strategies to use "Bars.Session.TimeZoneInfo.Id". It prints out "Central Standard Time", even though I'm currently located in the Mountain Time Zone.

      Now, I am running the test against the ES instrument, which is traded by the CME in Chicago, so that's why (I assume) I'm seeing a value of "Central Standard Time". But what I *need* to know is the current time zone of the computer that's running NinjaTrader. In other words, I need a method that returns "Mountain Standard Time" when it's being run on a machine in Denver, and "Central Standard Time" when it's run on a machine in Chicago.

      Comment


        #4
        Hello pbailey19,

        The Bars.Session.TimeZoneInfo.Id will return the timezone of the selected session template rather than the computers current timezone.

        In NinjaScript you have access to the DateTime component of C# so you are able to access the local machines DateTime.

        You could use something like to to display the computers timezone name

        Code:
        TimeZone localZone = TimeZone.CurrentTimeZone;
        Print(localZone.StandardName);
        Please let me know if I may be of additional assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        558 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        324 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        545 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        547 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X