Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to distinguish between overnight session and regular sesion

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

    How to distinguish between overnight session and regular sesion

    Hello,

    I am tying to set up a strategy that enters a position afterhours and exits at regular trading hours i.e. when the market opens

    What is the way to distinguish what part of the session we are trading?

    rgds

    Ioannis

    #2
    Hello im197,

    Thanks for your post.

    You could use time checks with Time[0] to check if the iterating data is outside of some predefined hours, our you could add an additional data series with a different Trading Hours template, and use that data series' Bars object to drive a SessionIterator to be able to reference specific session times from that data series' Trading Hours template.

    For adding another data series to the script, please see the Multi Time Frame and Instruments documentation.

    Multi Time Frame and Instruments - https://ninjatrader.com/support/help...nstruments.htm

    For adding an additional data series which follows a specific Trading Hours template, please see overloads and documentation below.

    AddDataSeries(string instrumentName, BarsPeriod barsPeriod, string tradingHoursName)
    AddDataSeries(string instrumentName, BarsPeriod barsPeriod, string tradingHoursName, bool? isResetOnNewTradingDay)
    AddDataSeries(string instrumentName, BarsPeriod barsPeriod, int barsToLoad, string tradingHoursName, bool? isResetOnNewTradingDay)

    AddDataSeries - https://ninjatrader.com/support/help...dataseries.htm

    For adding a SessionIterator to interact with the Trading Hours template of a script's data series, please see the SessionIterator documentation.

    SessionIterator - https://ninjatrader.com/support/help...oniterator.htm

    Please let me know if I can be of further assistance.

    Comment


      #3
      Hello again

      say I want to use this syntax

      AddDataSeries(string instrumentName, BarsPeriod barsPeriod, string tradingHoursName, bool? isResetOnNewTradingDay)

      1. how do I refer to the current instrument loaded in Bars[0] in instrument name ?

      2. what are valid tradingHoursName strings to use?

      thanks in advance

      Comment


        #4
        Hello im197,

        Thanks for your questions.

        1. how do I refer to the current instrument loaded in Bars[0] in instrument name ?
        The Help Guide notes that using null for the Instrument Name will use the primary data series of the script.

        4. For the instrument name parameter null could be passed in, resulting in the primary data series instrument being used.

        2. what are valid tradingHoursName strings to use?
        The Trading Hours template will match what is entered in the Data Series window. I.E:
        • "CME US Index Futures ETH"
        • "Default 24 x 7"
        • "US Equities RTH"
        Example:

        AddDataSeries(null, new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1440 }, "US Equities RTH");

        I look forward to being of further assistance.

        Comment


          #5
          Is there an NT8 Enum that can be used to identify the Trading Hours Template selected?

          Comment


            #6
            Hello parkinsonbr,

            There is not an enum to to identify the selected Trading Hours template, these must be entered as a string. The TradingHours property will reflect the template that is selected in the Data Series window, but keep in mind that this would be dependent on loading data (State.DataLoaded) and may not be available in State.Configure when a data series gets added. This would specifically be the case for optimization backtests.

            TradingHours - https://ninjatrader.com/support/help...adinghours.htm

            Let us know if you have any additional questions.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Today, 05:17 AM
            0 responses
            38 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            124 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            64 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            41 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            46 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X