How to calculate Exchange Opening Time? - futures io
futures io



How to calculate Exchange Opening Time?


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one baruchs with 5 posts (0 thanks)
    2. looks_two Fat Tails with 3 posts (0 thanks)
    3. looks_3 sam028 with 1 posts (0 thanks)
    4. looks_4 MXASJ with 1 posts (0 thanks)
    1. trending_up 5,357 views
    2. thumb_up 0 thanks given
    3. group 4 followers
    1. forum 13 posts
    2. attach_file 1 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

How to calculate Exchange Opening Time?

(login for full post details)
  #1 (permalink)
 baruchs 
Israel
 
Experience: Intermediate
Platform: NinjaTrader
Broker: pfg
Trading: eminis
 
Posts: 323 since Jun 2009
Thanks: 6 given, 208 received

Hi,
For my strategy I need to know the opening times of all exchanges (NY, Tokyo, Sidney, London).
So I have those parameters:
private int NYStart = 830;
private int TokyoStart = 1800;
private int SydneyStart = 1800;
private int LondonStart = 200;

Its for CST so I also have a parameter for CSTOffsetHours.
Now I need to change those opening hours depending on different DST (day light saving times).
So that is how I do it:
int MonthDay = ToDay(Time[0]) % 10000;
if (MonthDay > 313 && MonthDay < 1106) TokyoStart -= 100;
if (!(MonthDay > 403 && MonthDay < 1002)) SydneyStart += 100;
if (MonthDay > 313 && MonthDay < 2603) TokyoStart -= 100;
if (MonthDay > 313 && MonthDay < 1106) LondonStart -= 100;
if (MonthDay > 1030 && MonthDay < 1106) LondonStart += 100;

Is this correct?

Baruch

Started this thread Reply With Quote

Journal Challenge April 2021 results (now extended!):
Competing for $1800 in prizes from Jigsaw
looks_oneMaking a Living with the Microsby sstheo
(82 thanks from 10 posts)
looks_twoSalao's Journalby Salao
(25 thanks from 6 posts)
looks_3Deetee’s DAX Trading Journal (time based)by Deetee
(25 thanks from 9 posts)
looks_4Learning to Profit - A journey in algorithms and optionsby Syntax
(12 thanks from 7 posts)
looks_5Maybe a little bit different journalby Malykubo
(6 thanks from 3 posts)
 
Best Threads (Most Thanked)
in the last 7 days on futures io
The Crude Dude Oil Trading System
73 thanks
futures io site changelog and issues/problem reporting
73 thanks
Would You Sell Your System?
71 thanks
FIO Journal Challenge - April 2021 w/Jigsaw Trading
32 thanks
Big Mike in Ecuador
28 thanks
 
(login for full post details)
  #3 (permalink)
 sharmas 
Auckland
 
Experience: Advanced
Platform: Ninja Trader
Broker: Zen-Fire
Trading: CL and ES
 
Posts: 764 since Apr 2010
Thanks: 3,793 given, 735 received


Hi

This might assist but not sure if it will

Attached Thumbnails
How to calculate Exchange Opening Time?-timezones-lesson-3.pdf  
Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #4 (permalink)
 baruchs 
Israel
 
Experience: Intermediate
Platform: NinjaTrader
Broker: pfg
Trading: eminis
 
Posts: 323 since Jun 2009
Thanks: 6 given, 208 received

Hi sharmas,
No it does not help. I know the times. My question is about the calculaton of DST.

Baruch

Started this thread Reply With Quote
 
(login for full post details)
  #5 (permalink)
 redratsal 
Milan (I)
 
Experience: Advanced
Platform: Ninjatrader
Broker: Kinetick
Trading: FDAX,6E,CL,YM,NQ,ES
 
redratsal's Avatar
 
Posts: 1,653 since Oct 2010
Thanks: 1,215 given, 2,083 received


baruchs View Post
Hi,
For my strategy I need to know the opening times of all exchanges (NY, Tokyo, Sidney, London).
So I have those parameters:
private int NYStart = 830;
private int TokyoStart = 1800;
private int SydneyStart = 1800;
private int LondonStart = 200;

Its for CST so I also have a parameter for CSTOffsetHours.
Now I need to change those opening hours depending on different DST (day light saving times).
So that is how I do it:
int MonthDay = ToDay(Time[0]) % 10000;
if (MonthDay > 313 && MonthDay < 1106) TokyoStart -= 100;
if (!(MonthDay > 403 && MonthDay < 1002)) SydneyStart += 100;
if (MonthDay > 313 && MonthDay < 2603) TokyoStart -= 100;
if (MonthDay > 313 && MonthDay < 1106) LondonStart -= 100;
if (MonthDay > 1030 && MonthDay < 1106) LondonStart += 100;

Is this correct?

Baruch

Hi Baruch,

Gomi is your man goto post #5 BeginTime EndTime timezone ? - Page 2 - NinjaTrader Support Forum

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #6 (permalink)
 baruchs 
Israel
 
Experience: Intermediate
Platform: NinjaTrader
Broker: pfg
Trading: eminis
 
Posts: 323 since Jun 2009
Thanks: 6 given, 208 received

Thanks redratsal,
Unfortunately it does not help. Gomi speaks about figuring the difference for current time from local time to exchange time and I need the difference from other (not local) time.

Baruch

p.s.
Its the second time that I ask a question on this forum. Can anyone help?
p.s.s
The first question was more like a suction to help if get helped, and I got no response.

Started this thread Reply With Quote
 
(login for full post details)
  #7 (permalink)
 sam028 
Site Moderator
 
 
sam028's Avatar
 
Posts: 3,670 since Jun 2009
Thanks: 3,789 given, 4,505 received

Why are you using in variables instead of DateTime variables ?
You want to manipulate "the opening times of all exchanges", so it will be much easier to manipulate DateTime than int, as you have all the needed classes and methods to play with timezones.
See TimeZoneInfo class, ConvertTime, DateTimeOffset, ...
You know in which timezone are NY, Tokyo, ..., so you're also able to convert any date from a timezone to another one. And as these classes are "DST aware", I don't see where could be the problem to do what you want to do.

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
 
(login for full post details)
  #8 (permalink)
 baruchs 
Israel
 
Experience: Intermediate
Platform: NinjaTrader
Broker: pfg
Trading: eminis
 
Posts: 323 since Jun 2009
Thanks: 6 given, 208 received

Thanks sam028,
That is exactly what I was looking for.

Baruch

Started this thread Reply With Quote
 
(login for full post details)
  #9 (permalink)
 redegenerated 
España
 
Experience: None
Platform: NT
Trading: 6E
 
redegenerated's Avatar
 
Posts: 131 since Jun 2010
Thanks: 301 given, 81 received


sharmas View Post
Hi

This might assist but not sure if it will

this comes handy to me that i always get lost in timezone nice summary, tnx

Reply With Quote
 
(login for full post details)
  #10 (permalink)
 Fat Tails 
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,855 since Mar 2010
Thanks: 4,238 given, 26,743 received



sharmas View Post
Hi

This might assist but not sure if it will

Some questions:

(1) This table does not take into account the different daylight saving schedules, so for Europe it will not work from March 13 to March 27, 2011 and from October 30 to November 6, 2011. Tokyo does not have any DST, so the schedule will run into problems during the summer. To display the times correctly, you would need 4 different schedules.

(2) To display the Tokyo open, you would need to introduce a column with Tokyo time, as it does not match any of the other timezones and does not use DST.

Opening hours of FOREX markets

I have visited about 20 websites for FOREX opening hours and this is the result:

Tokyo Open 6:00 PM EST in winter, 7:00 PM EST in summer
Tokyo Close 4:00 AM EST in summer 5:00 AM EST in summer
Frankfurt Open 2:00 AM EST
Frankfurt Close 11:00 AM EST
London Open 3:00 AM EST (except for the 3 weeks listed above)
London Close 12:00 PM EST (except for the 3 weeks listed above)
New York Open 8:00 AM EST
New York Close 5:00 PM EST

If I translate from your PDF: Euro Open => Frankfurt Open, London Activity => London Open, European Close => London Close, we get the same values for Europe.

I get a different value for New York (1 hour later), I only have found 4:00 PM as the New York close occasionally.

For Tokyo there are different hours for winter and summer, your opening hours at 8:00 PM are later than both the winter and summer times that I have found.

Glad if somebody knows better than this.

Reply With Quote
 
(login for full post details)
  #11 (permalink)
 Fat Tails 
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,855 since Mar 2010
Thanks: 4,238 given, 26,743 received


sam028 View Post
Why are you using in variables instead of DateTime variables ?
You want to manipulate "the opening times of all exchanges", so it will be much easier to manipulate DateTime than int, as you have all the needed classes and methods to play with timezones.
See TimeZoneInfo class, ConvertTime, DateTimeOffset, ...
You know in which timezone are NY, Tokyo, ..., so you're also able to convert any date from a timezone to another one. And as these classes are "DST aware", I don't see where could be the problem to do what you want to do.

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)

 
Code
private TimeZoneInfo tstZone // TST stands for Tokyo Standard Time
try
{
tstZone = TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time"); 
}
catch (TimeZoneNotFoundException ex2)
{
throw new TimeZoneNotFoundException( String.Format("The time zone '{0}'cannot be found.", "Tokyo Standard Time"), ex);
}
(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 ->

 
Code
time = TimeZoneInfo.ConvertTime(time, tstZone, TimeZoneInfo.Local)
Or to convert from session template to local time ->

 
Code
time = TimeZoneInfo.ConvertTime(time, Bars.Session.TimeZoneInfo, TimeZoneInfo.Local)
You can now easily code an indicator that prints the market hours on your chart.

Reply With Quote
 
(login for full post details)
  #12 (permalink)
 Fat Tails 
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,855 since Mar 2010
Thanks: 4,238 given, 26,743 received

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:




Reply With Quote
 
(login for full post details)
  #13 (permalink)
 baruchs 
Israel
 
Experience: Intermediate
Platform: NinjaTrader
Broker: pfg
Trading: eminis
 
Posts: 323 since Jun 2009
Thanks: 6 given, 208 received

Hi fat tails,
Thank you very much. I'll work with ETC conversion.
You are very helpful.

Baruch

Started this thread Reply With Quote
 
(login for full post details)
  #14 (permalink)
 MXASJ 
Asia
 
Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 799 received


sam028 View Post
Why are you using in variables instead of DateTime variables ?
You want to manipulate "the opening times of all exchanges", so it will be much easier to manipulate DateTime than int, as you have all the needed classes and methods to play with timezones.
See TimeZoneInfo class, ConvertTime, DateTimeOffset, ...
You know in which timezone are NY, Tokyo, ..., so you're also able to convert any date from a timezone to another one. And as these classes are "DST aware", I don't see where could be the problem to do what you want to do.

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.

Reply With Quote


futures io Trading Community Platforms and Indicators NinjaTrader > How to calculate Exchange Opening Time?


Last Updated on January 12, 2011


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1,800 in prizes!

April
 

Seven Trading Mistakes Solved With Smart Trading Tools w/Brannigan Barrett

Elite only
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts