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

Exit On Close vs. Strategy Position

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

    Exit On Close vs. Strategy Position

    Hello,

    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,
    Francis

    #2
    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

    Comment


      #3
      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?

      Comment


        #4
        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

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by trilliantrader, 04-18-2024, 08:16 AM
        4 responses
        15 views
        0 likes
        Last Post trilliantrader  
        Started by mgco4you, Today, 09:46 PM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by wzgy0920, Today, 09:53 PM
        0 responses
        4 views
        0 likes
        Last Post wzgy0920  
        Started by Rapine Heihei, Today, 08:19 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by Rapine Heihei, Today, 08:25 PM
        0 responses
        6 views
        0 likes
        Last Post Rapine Heihei  
        Working...
        X