Announcement

Collapse
No announcement yet.

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:	229
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.

    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:

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        57 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        133 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        73 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        50 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X