• 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.


No announcement yet.

Partner 728x90


Exit On Close vs. Strategy Position

  • Filter
  • Time
  • Show
Clear All
new posts

    Exit On Close vs. Strategy Position


    Hopefully one could help me with the following problem I am stuck with:

    When trading different strategies on the same underlying (E-Mini) I want to close all open positions a few seconds before market closes. So I enabled Exit On Close with the standard 30 seconds on all strategies and template session CME US Index Futures ETH.
    Now, every strategy has it's own label name for the entry and exit, so under the execution tab all trades are gathered and the different trades can be seen. I assume these names are also used by Ninjatrader to figure out which strategy holds what position, or better said, holds a position or not.
    It happens that one of the strategies holds a long position, where another is short. So NT has two open positions, a long and short on the same underlying. In my trading platform (IB's TWS) there are no running positions, which is correct while the long and short flattened each other with the last trade. When this situation still is when the Exit On Close is triggered, two things happen which I would like to alter:

    1. First of all NT initiate two orders for TWS; to close the long and the short. This while there are no physical open positions, but these only is the 'technical' individual state of the two strategies with both an open position. So two orders are executed while this is not neccesary. I only want to have NT set the positions of all strategies on zero again, when there are no running positions in TWS, which also can be seen under the positions tab in NT.

    2. When the Exit On Close orders are executed, these orders get the name 'Exit on close' labeled and NT probably no longer matches the correct open positions to each individual strategy. The Exit On Close did close two positions (not needed as stated under previous point) and thus closed the overall positions to zero, but the two strategies who needed to be closed still state to hold their position. It seems that the label name Exit On Close does not match the exit position name each strategy needs to calculate it's theoretical position, so these open positons stay unchanged while NT closed them with the forced Exit On Close. From this moment strategies need to be disabled manually to set them on zero position again, otherwise no new entries are triggered.

    Is there any way to work this out another way? TheToTime method is not an option, while the strategies trigger on the On Bar Update and not every day a new bar is triggered near the end of a session (2 renko strategy). Flatten everything under the Initialize isn't an option also, while this disables all strategies. I just need the name label Exit On Close to match the open strategies. Now the Exit On Close orders are unique orders not matching the one they are in fact closing.

    Kind regards,

    Hello Francis,
    The strategy will close the positions as per the strategy position and not the Net position (total of all strategies + manually placed trades).

    Any system generated orders will be tagged the default name (like "Exit on close" or "Stop loss" etc).

    Unfortunately these are default behavior and to change this you have to custom code your own logic/exit codes.
    JoydeepNinjaTrader Customer Service


      Hello Joydeep,

      Thanks for responding.

      So there is no way to match the Exit On Close orders with the strategies? This way the Exit On Close is a one time daily action, after which the strategies with open positions have to be resetted manually when using the Exit on Close feature. Is that what you say?

      When using the Exit On Close and Exit On Close Seconds code under Initialize in de strategy code, is this any different then setting the Exit On Close by the UI strategy settings? Is there a chance NT sees this Exit On Close as a part of that individual strategy, or is it the exact same exit as when using the UI?


        Hello Francis,
        If you set Exit on close to true, then the exit orders will be sent by NinjaTrader as per the strategy position and there's no way to override it. However if you want to place the exit orders by further custom coding your strategy then you can check the net position of the instrument via unsupported NinjaScript codes.

        The functionality for Exit on close will be the same, whether set via the Strategy parameter box or via setting in in the Initialize section of the code. Exit on close will be as per strategy position only.
        JoydeepNinjaTrader Customer Service


        Latest Posts


        Topics Statistics Last Post
        Started by JAtrades, Today, 02:44 PM
        1 response
        Last Post NinjaTrader_ShawnB  
        Started by mr_trade, Today, 01:32 PM
        0 responses
        Last Post mr_trade  
        Started by sgordet, Today, 10:44 AM
        1 response
        Last Post bltdavid  
        Started by Parmenides48, Today, 08:37 AM
        2 responses
        Last Post Parmenides48  
        Started by EnveousColnago, 08-06-2020, 08:31 AM
        8 responses
        Last Post Emma1
        by Emma1