The conversion from different timezones does not work for .Net 2.0 / NinjaTrader 6.5. However, .Net 3.5 / NinjaTrader 7.0 are capable of doing the conversion. the session manager of Ninjatrader 7.0 uses this timezone conversion capability.
These are the steps to convert between different timezones:
(1) Define TimeZoneInfo variables which contain the timezoneinfo information. Here is an example to create a timezoneinfo variable for the Asian session (Tokyo time)
(2) Next use the TimeZoneInfo variables for conversion. Let us assume that you have defined four variables tstZone, cetZone, gmtZone, estZone and that they contain the correct information collected from the class library. Now you also need your local timezone and the timezone of your session template:
Local timezone can be found as: TimeZoneInfo.Local
Session template timezone can be found as: Bars.Session.TimeZoneInfo
(3) To convert, use TimeZoneInfo.ConvertTime
For example to convert from TST to local Time ->
Or to convert from session template to local time ->
You can now easily code an indicator that prints the market hours on your chart.
Here you can find an example, how to apply this. The chart shows today's FOREX sessions:
Session template (in Eastern Time): 3 sessions, Asian, European and US session. The Asian session includes Sydney and Tokio. The European session starts at 2:00 AM Est, which is correct for 49 weeks out of 52 weeks per year. The US session starts at 8:00 AM EST, the Asian session starts at 5:00 PM Est.
European open and London open is collected from the session template. The Tokyo open is generated via indicator, as the session template does only use EST, and is not aware of TST.
The opening range indicator uses TST for the Asian pre-session and CET for the European pre-session.
Created by applying the indicator twice to display both European and US opening range. The indicator is available here:
Interestingly I saw the source code for trading platform that did a similar thing, and it was billed as a performance enhancement (math on ints being less expensive than math on DateTimes, I guess), but I wonder if it merely code that originated back during .NET 2.0. Interesting factoid, Fat Tails. Thanks.