• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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, 11:07 AM. 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

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by faisamtrader, Today, 10:31 AM
              1 response
              16 views
              0 likes
              Last Post NinjaTrader_Tyler  
              Started by ChazJ, Today, 09:48 AM
              1 response
              3 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by maxie, Today, 10:01 AM
              1 response
              7 views
              0 likes
              Last Post NinjaTrader_Melissa  
              Started by Bionian, Today, 09:36 AM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_PaulH  
              Started by tomd, Today, 09:48 AM
              1 response
              14 views
              0 likes
              Last Post NinjaTrader_Ariana  
              Working...
              X