Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

"Close Position" as Exit name

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

    "Close Position" as Exit name

    Hello all - I have been working on a few strategy entries. I finally was able to combine entries into one strategy. However, I just noticed that when I combined, in some occasions, I get an exit name of "Close Position" instead of the name of the order. It seems like if when I am shorting and I set long it close automatic my short position.

    When I do the same on separate strategies, it doesn't do that.

    Is there is any way I could potentially know what is happening? I have 4 all entries as settings. my combined strategy only gets a single position per signal. So, total I could have 4 positions but only one per signal. Maybe I need to share the code, but I was wondering if there is a setting that I might need to update, since I am getting an Exit Name of Close Position.

    #2
    Hello felixolmo,

    Thanks for your post.

    Please note the following from the Managed Approach help guide: Entry() methods will reverse the position automatically. For example, if you are in a 1 contract long position and now call EnterShort(), you will see 2 executions. One to close the prior long position and the other to get you into the desired 1 contract short position.

    The execution to close the prior position will be named 'Close position' and the second execution will be the name of the order being placed.

    Managed Approach: https://ninjatrader.com/support/help...d_approach.htm

    Ultimately, to understand why the script is behaving as it is, such as placing orders or not placing orders when expected, you would need to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

    Below is a link to a forum post that demonstrates how to use prints to understand behavior.
    https://ninjatrader.com/support/foru...121#post791121

    Let us know if we may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Hi Brandon!

      I believe that is what is happening. I assume that because I have different names, it will not interfere with my other orders. Is there another way to do this or do I need to work with a separate strategy when it comes to long vs short?

      Comment


        #4
        Hello felixolmo,

        Thanks for your note.

        You would not necessarily need to create a separate strategy for placing long or short orders.

        If you are using unique signal names for each order being placed it would not be expected that the 'Close position' execution interferes with orders. The 'Close position' execution will be called if an Entry method is placed in the opposite direction. For an example, see post #2.

        To understand how the strategy is behaving and placing orders, debugging steps using prints would need to be taken. See the forum post linked in post #2 regarding using prints to understand a strategy's behavior.

        Let us know if we may further assist.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          Brandon - I know about the Print and all. I have been trying to debug the script. The only problem I am having is that I do not see the "Close Position" Order coming thru. The Entries have unique names, so they are different if they are Short vs Long, so that is out of the picture.

          I am good at debugging scripts, however this time I do not know where to start because I do not see that closure of the position. Any other ideas on how at least I can figure out how this "Close Position is coming from?

          Comment


            #6
            Hello felixolmo,

            Thanks for your note.

            how at least I can figure out how this "Close Position is coming from?

            The 'Close position' execution is likely occurring because an Entry method is being called in the opposite direction of your current position. Calling an Entry order method in the opposite direction will reverse the position automatically. Two executions will occur when you call an entry method in the opposite direction, a 'Close position' execution to close the current position and a second execution to place the entry order in the opposite direction.

            For example, if you are in a 1 contract Long position and now call EnterShort(), you will see 2 executions. One to close the prior long position (Close position) and the other to get you into the desired 1 contract short position (signal name of EnterShort()).

            This means that the execution to close the prior position will be named 'Close position' and the second execution that occurs will be the signal name of the order being placed.

            An example of this could be seen by testing the SampleMACrossOver strategy that comes default with NinjaTrader.

            If you do not want this 'Close position' execution to occur, you could consider exiting your current position before placing an order in the opposite direction. Or, you could consider checking if you are in a flat MarketPosition before calling your entry order methods.

            Position.MarketPosition: https://ninjatrader.com/support/help...etposition.htm

            Let us know if we may assist further.


            <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            66 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            141 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            76 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            47 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            51 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X