Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

How to use instrument time instead of local time in strategy logic

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

    How to use instrument time instead of local time in strategy logic

    Hi all

    I have faced the same problem. I am creating a strategy backtest to use in diferent instrements from diferent time zones. to simplify this I am going to speak about ES and FDAX with UTC-6 and UTC+1. This strategy uses open session time and close session time as reference.

    The problem is how to manage time(hour),as example I show a code to cancel orders no filled 1 hour before close market but the time manage by strategy is local time, as my local time is UTC+1 I have no problem with FDAX but I found problems with ES due to saving time change is not done at same time in Europe and EEUU and during thse days my orders are canceled 1 hour before I want to do it. In the rest of time I only have to define the time base on my local time.

    My questions is

    Is there any way to use trading hours defined in the strategy as strategy/bars time for each strategy to avoid problems with saving change time? I cannot change by tools my time becuase I will use both strategies at same time and in this case one of them no wok properly. I mean i want to get the instrument time when I print Time[0].


    In FADX strategy I would like to get this code:

    if (ToTime(Time[0]) > 210000 &&
    (Position.MarketPosition == MarketPosition.Flat) )​


    In ES strategy I would like to get this code, using 140000 as 1 hour previous market close while my local time is UTC+1

    if (ToTime(Time[0]) > 140000 &&
    (Position.MarketPosition == MarketPosition.Flat) )​


    Click image for larger version

Name:	image.png
Views:	120
Size:	41.4 KB
ID:	1237701

    Regards.​​

    #2
    Hello, thanks for writing in. Each instrument uses a Trading Hours template. The ES is using the CME US Index Futures ETH template and the FDAX uses the Eurex Equity Index Futures template. These can be viewed from Tools>Trading Hours. All trading should be managed in terms of your own time zone since NinjaTrader has a time zone setting which is set to your time zone by default. You will need to find out what time 2PM CST is in your time zone and just use that time. E.g. 2PM Central US time is 8PM in London.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hi NinjaTrader_ChrisL

      Thanks for your response. I know that but during some days per year EEUU change is time due to saving before than Europe then during several days there is a mismarching between hours, I would like to solve this in my strategy by coding and I had think to use original time from EEUU for ES. I found that Core.Globals.GeneralOptions.TimeZoneInfo containt the time zone used by ninjatrader and I wold like to modify it in my strategy. Could you help to me?





      Regards.

      Comment


        #4
        Hello, thanks for the follow up. The Time[] array is only going to be in terms of the time zone that you have set up under Tools>Options>General. If you need to convert any time it must be done "manually" from your own code. Unfortunately, I do not have any example of this. The documentation for the Time array is here for reference:

        Chris L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by lightsun47, Today, 03:51 PM
        0 responses
        5 views
        0 likes
        Last Post lightsun47  
        Started by 00nevest, Today, 02:27 PM
        1 response
        10 views
        0 likes
        Last Post 00nevest  
        Started by futtrader, 04-21-2024, 01:50 AM
        4 responses
        46 views
        0 likes
        Last Post futtrader  
        Started by Option Whisperer, Today, 09:55 AM
        1 response
        14 views
        0 likes
        Last Post bltdavid  
        Started by port119, Today, 02:43 PM
        0 responses
        10 views
        0 likes
        Last Post port119
        by port119
         
        Working...
        X