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

Strategy issue placing duplicate exit orders

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

    Strategy issue placing duplicate exit orders

    Hello,

    I created a simple EMA crossover long strategy using the strategy builder.

    It works fine in a sim account, buys on the crossover, and sells on the crossunder. Still, when I connect it to a rithmic account (apex funding), it sometimes generates duplicate exit orders, causing it to go in the opposite direction instead of closing the position.

    To be sure, I have the same strategy running on a sim account and a rithmic account, and the issue is only present in the rithmic account.

    I noticed when I connected the rithmic account this disclaimer is attached below,
    Click image for larger version  Name:	multiple fills issue.png Views:	0 Size:	14.1 KB ID:	1246321

    so I am wondering,


    1. Is this the cause of the issue I am having?

    2. if it is, what is the best way to solve it, considering I am using the condition builder and not the code? And will I have the same issue using a Ninja brokerage account, or is this issue isolated to rithmic?

    3. if it is not the issue, what can I do to figure out how to fix it?

    Thanks in advance for your help
    Last edited by anotherone1; 04-14-2023, 05:03 PM.

    #2
    Hello anotherone1,

    The warning is stating that code should not have code that is depending on the sequence of OnExecutionUpdate() and OnPositionUpdate(). Do you have code in both OnExecutionUpdate() and OnPositionUpdate()? Are you sending exit orders from both methods?

    Debug the script by enabling TraceOrders and adding prints above any conditions that submit the orders, include labels in the prints. Also print the order object in OnOrderUpdate().

    Below is a link to a forum post that demonstrates using Print() to understand behavior.


    Save the output to a text file and include this with your next post if you would like assistance analyzing the print output.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello anotherone1,

      The warning is stating that code should not have code that is depending on the sequence of OnExecutionUpdate() and OnPositionUpdate(). Do you have code in both OnExecutionUpdate() and OnPositionUpdate()? Are you sending exit orders from both methods?

      Debug the script by enabling TraceOrders and adding prints above any conditions that submit the orders, include labels in the prints. Also print the order object in OnOrderUpdate().

      Below is a link to a forum post that demonstrates using Print() to understand behavior.


      Save the output to a text file and include this with your next post if you would like assistance analyzing the print output.
      I am using the strategy builder, so I am not sure if I am using code in both OnExecutionUpdate() and OnPositionUpdate(). I am not even sure if that is the issue.


      what is a good way to avoid this issue?

      Comment


        #4
        Hello anotherone1,

        If you are not overriding OnExecutionUpdate() or OnPositionUpdate() then the warning message would not apply to this strategy.

        The most common reason you will see a position become double in the opposite direction is an exit order and an entry order being submitted on the same bar.

        This forum post discusses.
        https://ninjatrader.com/support/foru...16#post1036616

        To determine if this is what is occurring, enable TraceOrders and provide the output saved to a text file.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello anotherone1,

          If you are not overriding OnExecutionUpdate() or OnPositionUpdate() then the warning message would not apply to this strategy.

          The most common reason you will see a position become double in the opposite direction is an exit order and an entry order being submitted on the same bar.

          This forum post discusses.
          https://ninjatrader.com/support/foru...16#post1036616

          To determine if this is what is occurring, enable TraceOrders and provide the output saved to a text file.
          This only happens in live accounts and not in sim, so it will be hard to reproduce without risking capital. I noticed it places 2 exit orders a few mili seconds apart, possibly not getting confirmation on the first one fast enough so then it submits another one which in fact ends up reversing the position. if that is the issue, what would be a good way to prevent it?

          Comment


            #6
            Hello anotherone1,

            Correcting the behavior would depend on what is sending those orders.

            The TraceOrders information would provide insight.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Haiasi, 04-25-2024, 06:53 PM
            2 responses
            16 views
            0 likes
            Last Post Massinisa  
            Started by Creamers, Today, 05:32 AM
            0 responses
            0 views
            0 likes
            Last Post Creamers  
            Started by Segwin, 05-07-2018, 02:15 PM
            12 responses
            1,785 views
            0 likes
            Last Post Leafcutter  
            Started by poplagelu, Today, 05:00 AM
            0 responses
            3 views
            0 likes
            Last Post poplagelu  
            Started by fx.practic, 10-15-2013, 12:53 AM
            5 responses
            5,407 views
            0 likes
            Last Post Bidder
            by Bidder
             
            Working...
            X