Trading multiple time zones - NinjaTrader Programming | futures io social day trading
futures io futures trading


Trading multiple time zones
Updated: Views / Replies:1,877 / 8
Created: by DarkPoolTrading Attachments:0

Welcome to futures io.

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

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

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

Reply
 
Thread Tools Search this Thread
 

Trading multiple time zones

  #1 (permalink)
 Vendor: diversifyportfolio.com 
PTA, Gauteng
 
Futures Experience: Advanced
Platform: Self built + Sierra + TWS
Favorite Futures: Stocks and Options
 
DarkPoolTrading's Avatar
 
Posts: 1,036 since May 2012
Thanks: 1,244 given, 1,304 received

Trading multiple time zones

Hi All,

I trade different time zones to where I live. This is not a problem when doing discretionary trading because I can just look at a world clock and know what the relevant time zone of the instrument im trading is. However what I would like to do is implement parameters into my strategies so that I can enter the relevant trading hours depending on what instrument im trading.

For example my local time is 6 hours ahead of New York. If I want a strategy to only trade New York time 09:00 to 16:00 that will be 15:00 to 22:00 my local time. So because NinjaTrader displays the local time from my PC, I will need to code NinjaScript to only trade between 15:00 to 22:00. Is that correct so far?

Now my problem comes in with day light savings and time changes. This is because my local time does not change (no day light savings here). Therefore instead of the system using 15:00 to 22:00 it must use 16:00 to 23:00 for example.

I would like to specify in code that between month X and month Y each year, the strategy should use a certain time frame (eg: 15:00 to 22:00). But from month A to month B, use a different time frame.

Is there a way to code that?

Any advice is much appreciated.

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Israel
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: pfg
Favorite Futures: eminis
 
Posts: 323 since Jun 2009
Thanks: 6 given, 206 received



Quoting 
Is there a way to code that?

May be. My solution was to change my computer TZ to CT. This is because here in Israel we have a bigger problem, our day light savings are irregular.

Baruch

Reply With Quote
 
  #4 (permalink)
 Vendor: diversifyportfolio.com 
PTA, Gauteng
 
Futures Experience: Advanced
Platform: Self built + Sierra + TWS
Favorite Futures: Stocks and Options
 
DarkPoolTrading's Avatar
 
Posts: 1,036 since May 2012
Thanks: 1,244 given, 1,304 received

Ok, thanks for the reply. It's not a huge issue if this is not possible.

Reply With Quote
 
  #5 (permalink)
 Vendor: diversifyportfolio.com 
PTA, Gauteng
 
Futures Experience: Advanced
Platform: Self built + Sierra + TWS
Favorite Futures: Stocks and Options
 
DarkPoolTrading's Avatar
 
Posts: 1,036 since May 2012
Thanks: 1,244 given, 1,304 received

I've just been thinking about this problem a bit more, and this is going to affect all back testing results on instruments in different time zones which have daylight savings if your local time does not have daylight savings.

This is because from the end of March to the end of October, the local trading time should be 09:00 to 17:30 to correspond to the foreign market. But for the other 6 months of the year, trading will from 10:00 to 18:30 local time to correspond to the foreign market.

Without being able to specify in code what time's should be used for certain times of the year, the results will not be accurate. Surely someone else has realised this and found a way around it with their back tests? Is there some sort of Month parameter that can be created?

thanks.

Reply With Quote
 
  #6 (permalink)
 Vendor: www.traderwerks.com 
Taipei Taiwan
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Optimus
Favorite Futures: TW
 
Posts: 693 since Jun 2009
Thanks: 440 given, 440 received


DarkPoolTrading View Post
I've just been thinking about this problem a bit more, and this is going to affect all back testing results on instruments in different time zones which have daylight savings if your local time does not have daylight savings.

This is because from the end of March to the end of October, the local trading time should be 09:00 to 17:30 to correspond to the foreign market. But for the other 6 months of the year, trading will from 10:00 to 18:30 local time to correspond to the foreign market.

Without being able to specify in code what time's should be used for certain times of the year, the results will not be accurate. Surely someone else has realised this and found a way around it with their back tests? Is there some sort of Month parameter that can be created?

thanks.

Does this help


Quoting 
NinjaTrader 7 has conversion between time zonens. I hear the code below won't run on on NT6.5. I am not sure, I haven't been doing any thing serious on 6.5 since the NT7 beta came out in 2009. If you are still using NT6.5, please stop. Really.

You can access the local timezone ( of the machine you are using )

 
Code
TimeZoneInfo.Local
You can acces the TimeZone infor the the time zone in question by looking it up via the string.

 
Code
private string exchange_timezone = "Central European Standard Time" ;
private TimeZoneInfo time = TimeZoneInfo.ConvertTime(time, tstZone, TimeZoneInfo.Local);
cet_timezone = TimeZoneInfo.FindSystemTimeZoneById(exchange_timezone );
Now that yo have the timezone of where you are and the timezone of where you are trading and your local time, you can convert, using TimeZoneInfo.ConvertTime

 
Code
time = TimeZoneInfo.ConvertTime(time, cet_timezone , TimeZoneInfo.Local)


Math. A gateway drug to reality.
Reply With Quote
The following user says Thank You to traderwerks for this post:
 
  #7 (permalink)
 Vendor: diversifyportfolio.com 
PTA, Gauteng
 
Futures Experience: Advanced
Platform: Self built + Sierra + TWS
Favorite Futures: Stocks and Options
 
DarkPoolTrading's Avatar
 
Posts: 1,036 since May 2012
Thanks: 1,244 given, 1,304 received

Great, thanks for the reply. Ill give that a try tonight, but at first look I think it's gong to work.

Reply With Quote
 
  #8 (permalink)
Elite Member
Australia
 
Futures Experience: Advanced
Platform: NinjaTrader, Multicharts
Favorite Futures: Spot Forex, Gold, Silver
 
Posts: 176 since Oct 2010
Thanks: 114 given, 114 received

Have a look at the code from in my indicator. It's fairly straightforward to get/convert timezone in C#

https://futures.io/download/ninjatrader-7/indicators/1151-download.html?view

Reply With Quote
 
  #9 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,651 since Mar 2010
Thanks: 4,226 given, 25,601 received
Forum Reputation: Legendary


DarkPoolTrading View Post
Hi All,

I trade different time zones to where I live. This is not a problem when doing discretionary trading because I can just look at a world clock and know what the relevant time zone of the instrument im trading is. However what I would like to do is implement parameters into my strategies so that I can enter the relevant trading hours depending on what instrument im trading.

For example my local time is 6 hours ahead of New York. If I want a strategy to only trade New York time 09:00 to 16:00 that will be 15:00 to 22:00 my local time. So because NinjaTrader displays the local time from my PC, I will need to code NinjaScript to only trade between 15:00 to 22:00. Is that correct so far?

Now my problem comes in with day light savings and time changes. This is because my local time does not change (no day light savings here). Therefore instead of the system using 15:00 to 22:00 it must use 16:00 to 23:00 for example.

I would like to specify in code that between month X and month Y each year, the strategy should use a certain time frame (eg: 15:00 to 22:00). But from month A to month B, use a different time frame.

Is there a way to code that?

Any advice is much appreciated.


Trading multiple time zones is easy with the .Net Framework 3.5, as all methods are implemented to convert from one time zone to another. NinjaTrader has the local timezones of the exchange implemented via the session template. All you need to do is to apply the proper session template, for eexample if you want to trade CL with Eastern Time, then you should take the session template "NYMEX Energy". The session always starts at 6:00 PM EST, irrespectively of your local daylight savings schedule.

You can then use a TimeSpan variable as an offset to define your trading start time. First check for the start of the new trading day with "GetTradingDayFromLocal()", then add the TimeSpan accounting for the difference between your trading start time (9:00 AM) and the session start time (6:00 PM). In this case the offset to be stored in the TimeSpan would be 15 hours.

A note on segmented session templates: There is a known NinjaTrader bug, which will hit you, if you use a session template, which divides the day into several subsessions. NinjaTrader tends to confuses the session break (between night and day session) and the break of the trading day. This also applies to stop and limit orders with the setting DAY. As some brokers do not accept the setting GTC, I have coded strategies with the setting DAY, and NinjaTrader will cancel all stop orders at the session break between night and RTH session, taking this for the day break. Therefore I do not recommend to use segmented session templates for use with a strategy, but rather suggest to stay with a single session template and define the start time of your session via a TimeSpan offset relative to the start of the trading day.

Below is a sample code to determine the trading start time. It takes into account how to find the correct session date, as this is not necessarily identical with your local date.

 
Code
// catch the current session end of the instrument you trade
DateTime sessionStartTimeLocal;
DateTime sessionEndTimeLocal;
Bars.Session.GetNextBeginEnd(Bars,0, out sessionStartTimeLocal, out sessionEndTimeLocal);
// to catch the correct trading date, convert the session end time to exchange time and extract the date
DateTime instrumentSessionDate = 
    TimeZoneInfo.ConvertTime(sessionEndTimeLocal, TimeZoneInfo.Local, Bars.Session.TimeZoneInfo).Date;
// enter your trading start time in exchange time, for example 9:00 AM
TimeSpan tradeStartTime = new TimeSpan (9,0,0);
// add that start time to the instrument session date
DateTime tradeStartTime = instrumentSessionDate.Add(tradeStartTime);
// convert the tradeStartTime to local time
DateTime tradeStartTimeLocal = 
    TimeZoneInfo.Convert(tradeStartTime, Bars.Session.TimeZoneInfo, TimeZoneInfo.Local);
// you have now obtained your tradeStartTime in local time

I have used a similar approach for the Opening Range indicator.

Reply With Quote
The following user says Thank You to Fat Tails for this post:

Reply



futures io > > > > > Trading multiple time zones

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Colour time zones indicator nickohorny NinjaTrader 17 June 2nd, 2016 10:21 AM
Multiple Time Frames jkinneberg NinjaTrader Programming 17 March 21st, 2015 08:42 PM
Multiple Time Frame Bollinger Bands Saroj The Elite Circle 3 April 28th, 2013 03:34 PM
Webinar: Multiple Time Frames - Trading with Trend Big Mike The Elite Circle 40 August 9th, 2011 08:21 PM


All times are GMT -4. The time now is 11:36 PM.

Copyright © 2017 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
Page generated 2017-12-12 in 0.14 seconds with 19 queries on phoenix via your IP 54.234.255.29