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

Flat strategy position not recognized after resume

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

    Flat strategy position not recognized after resume

    I have strategies that close at the end of the day. If for whatever reason I stopped my strategy after the market has closed already, and re-enable the strategy (again, outside regular hours), NT8 will not recognize that my position was flat already, and assumes the position the strategy would have been in just before the end of trading (before it was closed at EOD).
    NT7 did the same, but the strategy automatically flattened at midnight, so it was in the proper state for the next morning. This doesn't seem to work in NT8... (or at least I haven't figured how it can be done). Any advice?

    #2
    Hello mic414, thanks for your post.

    What is your Start Behavior set to for the strategy? Does the strategy ignore an "Exit On Session Close" order if you start it up after hours like this?

    If you want the strategy to adopt the account position you can use AdoptAccountPosition, see here for details:

    https://ninjatrader.com/support/help...itionaware.htm - IsAdoptAccountPositionAware
    https://ninjatrader.com/support/help...rtbehavior.htm - StartBehavior

    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Yes, the strategy ignores "Exit on session close" indeed. When I restart the strategy - e.g. at the beginning of the week - the position is calculated as if it didn't close at session end in the previous session,
      I had "Wait until flat" start behavior set on the strategy. Should I use something else?

      Adopt account position probably won't work for me. I have 2-3 strategies trading the same instrument, so the actual account position is the superposition of 0-3 strategy positions.

      Comment


        #4
        Hello mic414,

        Thanks for your post.

        I would suggest checking a historical strategy performance report to see what trades the strategy has placed to open the position when you enable the strategy. If you are using Wait Until Flat, the strategy will wait until this position is flattened before it will submit a live order to your account. If you see a position which you do not expect, it would be advised to check the historical Strategy Performance report to see how the trade was made and if there needs to be additional logic added to prevent those trades from taking place.

        If you set the Data Series > Trading Hours break line brush to a visible color and you enable the SampleMACrossover strategy, you should see Exit On Session Close executions appear at the Trading Hours break line. You should see the same when testing your strategy.

        As I understand, you are disabling the strategy when it is flat, but when you re-enable it, it is calculating another trade which you do not expect. You will want to identify what this trade is and either implement time checks in the strategy or use a different Trading Hours template to prevent the strategy from processing data outside of your desired range.

        Strategy Performance reports - https://ninjatrader.com/support/help...egyPerformance

        Time checks (Strategy Builder) - https://ninjatrader.com/support/help...ateTimeFilters

        I look forward to assisting.
        JimNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Jim View Post
          ...
          As I understand, you are disabling the strategy when it is flat, but when you re-enable it, it is calculating another trade which you do not expect. You will want to identify what this trade is and either implement time checks in the strategy or use a different Trading Hours template to prevent the strategy from processing data outside of your desired range.
          ...
          I know what the trade is, it was the correct position in the last trading session, right before the "Close at session end" order was executed. The trading hours template is set to regular trading hours already. The problem is that when I re-enable the strategy outside of trading hours, it doesn't realize the position should be flat because of the "Close at session end" parameter.
          As I mentioned, NT7 had the same problem when I re-enabled a strategy, but it flattened the position at midnight. In order words, if I re-enabled the strategy after midnight, it worked properly. This seems to work differently in NT8.
          Last edited by mic414; 11-18-2019, 12:07 PM. Reason: typo edited

          Comment


            #6
            Hello mic414,

            I have found a difference in behavior for NT7 and NT8 using ExitOnClose/ExitOnSessionClose when the strategy is enabled after hours. I am discussing this difference in behavior with my colleagues and I will follow up after our review is complete.

            I look forward to assisting.
            JimNinjaTrader Customer Service

            Comment


              #7
              Thanks for investigating, Jim. Adding some more details, in case it's helpful.
              I double-confirmed it today: NT7 handles ExitOnClose strategies correctly, both against my IB and Ameritrade account. In NT7, I have "Immediately submit orders" selected on In the Strategies\NinjaScript settings (global setting in NT7). If I enable the strategy after mindight local time, the strategy will correctly recognize it should be in a flat state. If I enable before midgnight, it would assume the position the strategy was in before session close.
              The same definitely doesn't work in NT8 against Ameritrade. I'll try to test against IB tomorrow.

              I'm trying to migrate my scripts to NT8 finally (Ameritrade won't support NT7 from Jan 1st, 2020), and this is a big showstopper right now for me. (I'm still surprised no one ran into this problem before? Or could it be just an NT8+Ameritrade bug?)

              Comment


                #8
                Hello mic414,

                There were a few items blocking tests on our internal build, so we appreciate your patience while we investigated.

                To summarize, the issue we are encountering is that when the strategy is enabled after hours with ImmediatelySubmit when using ExitOnSessionClose on an RTH session, the ExitOnSessionClose functionality does not occur historically after hours and the strategy calculates a historical position. The strategy can also submit target/stop orders if the position would have had targets/stops.

                This is a technical limitation where ExitOnSessionClose does not occur historically, because we have not seen the tick of a new bar which would signal the bar closing. If you enable the strategy after the session starts, the strategy with the historical position closed and any target/stops associated with that position would not be fired as ExitOnSessionClose closes the position. This could be used as a workaround for the time being.

                You were able to workaround this with NT7 when enabling after midnight, but we would not consider this the ideal functionality to have in NinjaTrader 8.

                We are tracking interest behind improving the ExitOnSessionClose functionality so it can close out the position when enabled after hours. The ticket ID tracking this impact is SFT-1842.

                For any other community members that are encountering this behavior, please reply back here so we can track your impact.
                JimNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by tkaboris, Today, 08:01 AM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by Lumbeezl, 01-11-2022, 06:50 PM
                31 responses
                817 views
                1 like
                Last Post NinjaTrader_Adrian  
                Started by xiinteractive, 04-09-2024, 08:08 AM
                5 responses
                15 views
                0 likes
                Last Post NinjaTrader_Erick  
                Started by swestendorf, Today, 11:14 AM
                2 responses
                6 views
                0 likes
                Last Post NinjaTrader_Kimberly  
                Started by Mupulen, Today, 11:26 AM
                0 responses
                7 views
                0 likes
                Last Post Mupulen
                by Mupulen
                 
                Working...
                X