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

End on Session close on Daily charts?

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

    End on Session close on Daily charts?

    Hello,

    For some reason the "End on Session Close" option does not work on Daily charts. Is there another option specifically for Daily Charts to end a strategy and the close of the trading day?

    #2
    Hello omermirza,

    Thanks for your post.

    Exit On Session Close is derived from the Trading Hours template and these are not applied to daily bars, which are provided as is from the data provider.

    You could consider building a 1440 minute chart with a Trading Hours template you like and you will have a daily bar that follows those hours, and ExitOnSessionClose would be used. However, if the strategy is backtesting or is otherwise processing OnBarClose, order submissions that are triggered on bar closes would be cancelled. This may not be a viable solution for your needs.

    My suggestion to move forward would be to create a Multi Time Frame strategy and use a time check in the smaller timeframe to call ExitLong/ExitShort to close the position.

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

    ToTime can be used to convert bar timestamps (Time[0]) to an integer format that is easy to create time filters/time checks.

    ToTime - https://ninjatrader.com/support/help...t8/?totime.htm

    We look forward to assisting.
    JimNinjaTrader Customer Service

    Comment


      #3
      Hi Jim,

      Thanks - Where can I find the Trading Hours template? Also, what If I do the following:

      Create at 1440 min chart
      Exit the position after one bar since entry

      I think that might accomplish what I need as long as I utilized Tick Replay.

      -Omer

      Comment


        #4
        Hello Omer,

        Trading Hours templates are applied to a Data Series. This can be set in the Data Series window of a chart or in the Data Series parameters section of the property grid when adding the strategy to the Control Center or backtesting in the Strategy Analyzer.

        Please note that bar closures are signaled on the first tick of a bar, so if you wait on bar since the entry was executed to close the position, and the entry was made mid bar, you would be waiting for another bar to close which may be longer than your want.

        Try having a look at the SampleIntrabarBacktest example which submits orders to a single tick data series. This can be applied against a daily data series and you can see ExitOnSessionClose happening when we backtest and test in realtime. I would suggest this as a first step, and if you need intrabar Calculate.OnPriceChange or Calculate.OnEachTick when backtesting, you can enable Tick Replay.

        SampleIntrabarBacktest - https://ninjatrader.com/support/help...ipt_strate.htm

        Note that Tick Replay allows intrabar logic to be processed, but orders will still be filled by the data series we submit the order to. To achieve intrabar OnEachTick/OnPriceChange AND have orders filled intrabar, Tick Replay must be used AND orders must be submitted to a single tick data series.

        Please let us know if you have any additional questions.
        JimNinjaTrader Customer Service

        Comment


          #5
          Thanks alot - I think I've got it now. So basically I need to:
          • Set up a 1440 min chart with the proper Trading Hours Template
          • Ensure TIck Replay is enabled
          • Add a secondary Data Series - 1 tick
          • Ensure that the order are passed to the 1 tick Data Series

          I can then use "End on Session Close" and this will also be accurately backtestable ?

          Comment


            #6
            Hello Omer,

            Thanks for your reply.

            I would suggest using a 1440minute bar instead of a daily bar when you want to use a specific Trading Hours template since the Trading Hours templates would not filter the data in a daily bar, which is provided from the data provider as-is.

            You could still use a daily bar with ExitOnSessionClose and have orders submitted to a single tick data series, but if your strategy is calculating OnEachTick or OnPriceChange and Tick Replay is not used, you will see cases where positions get opened on the next bar and closed on the same bar. You can test our SampleIntrabarBacktest strategy to observe (screenshot attached.)



            We look forward to assisting.
            Attached Files
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by fmbraga, Today, 10:09 AM
            0 responses
            1 view
            0 likes
            Last Post fmbraga
            by fmbraga
             
            Started by StealthM93, Today, 09:57 AM
            0 responses
            2 views
            0 likes
            Last Post StealthM93  
            Started by Kdevineni, Today, 08:56 AM
            2 responses
            7 views
            0 likes
            Last Post Kdevineni  
            Started by Nyman, Yesterday, 02:27 PM
            1 response
            15 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by Ndakotan1313, Today, 08:54 AM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Working...
            X