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 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.
    JimNinjaTrader Customer Service

    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.
        JimNinjaTrader Customer Service

        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.
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by jaybedreamin, Today, 05:56 PM
            0 responses
            2 views
            0 likes
            Last Post jaybedreamin  
            Started by DJ888, 04-16-2024, 06:09 PM
            6 responses
            18 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by Jon17, Today, 04:33 PM
            0 responses
            1 view
            0 likes
            Last Post Jon17
            by Jon17
             
            Started by Javierw.ok, Today, 04:12 PM
            0 responses
            6 views
            0 likes
            Last Post Javierw.ok  
            Started by timmbbo, Today, 08:59 AM
            2 responses
            10 views
            0 likes
            Last Post bltdavid  
            Working...
            X