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

problems with ChangeOrder() in Unmanaged mode

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

    problems with ChangeOrder() in Unmanaged mode

    Hi everyone, i've detected a problem in unmanaged mode (SIM101 no Replay). It happens that as you can see in the picture the TPorder (can also be the SL order) is not selected correctly. I only use the OnOrderUpdate() method and calculate the positions myself.from the logic it should be logically that an order size of 10 long (position: 10, TP: 5) is sent by limit. at the first partialfill 2 are executed (position now: 2, TP: 2), at the second partialfill 1 is executed (position now: 3, TP now: should be 3 it stays at 2!!!). As shown in the picture, the position size for the TP is calculated correctly (PartFill TP: 3). How is it possible that Print("PartFilled TP: " + positiontotalTP); and right after that ChangeOrder(TPL, positiontotalTP, targetPrice, 0); is called and the positiontotalTP are not correctly taken over? the problem does not always occur, possibly in 10 percent of cases.

    Click image for larger version  Name:	Screenshot_6.jpg Views:	0 Size:	385.9 KB ID:	1129146

    Click image for larger version  Name:	Screenshot_7.jpg Views:	0 Size:	18.9 KB ID:	1129147

    Video good Fill: https://youtu.be/ozd8gCMzlUs
    Video bad Fill: https://youtu.be/h0zmBF-HdY0
    Last edited by sidlercom80; 11-24-2020, 11:55 AM.
    sidlercom80
    NinjaTrader Ecosystem Vendor - Sidi Trading

    #2
    have added a print statement to every ChangeOrder() that affects this order. Here you can clearly see that the order size should be changed to 5 pieces.

    Code:
    Print("1positiontotalTP: " + positiontotalTP);
    ChangeOrder(TPL, positiontotalTP, targetPrice, 0);
    Print("2positiontotalTP: " + positiontotalTP);
    Click image for larger version

Name:	Screenshot_3.jpg
Views:	326
Size:	376.4 KB
ID:	1129232
    sidlercom80
    NinjaTrader Ecosystem Vendor - Sidi Trading

    Comment


      #3
      Hello slidercom08,

      I just wanted to share that I have been able to reproduce these symptoms and I am currently looking into the matter.

      I will follow up with more information as it becomes available.
      JimNinjaTrader Customer Service

      Comment


        #4
        Hello sidlercom80,

        After testing with my Unmanaged OnOrderUpdate example, I was seeing some issues handling partial fills when SubmitOrderUnmamanged gets called multiple times before the order object for the target/stop orders get assigned.

        I have made modifications to add a bool to ensure the target/stop orders only get submitted once. After making these changes, I am not seeing any ill behavior with partial fills. I have enabled the Control Center's Tools > Options > Trading > Force partial fills property to reproduce partial fills consistently.

        Please test this strategy to confirm it is not having any issues with partial fills. I would then suggest using it as a guide to model your strategy.

        We look forward to assisting.
        Attached Files
        JimNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Jim View Post
          Hello sidlercom80,

          After testing with my Unmanaged OnOrderUpdate example, I was seeing some issues handling partial fills when SubmitOrderUnmamanged gets called multiple times before the order object for the target/stop orders get assigned.

          I have made modifications to add a bool to ensure the target/stop orders only get submitted once. After making these changes, I am not seeing any ill behavior with partial fills. I have enabled the Control Center's Tools > Options > Trading > Force partial fills property to reproduce partial fills consistently.

          Please test this strategy to confirm it is not having any issues with partial fills. I would then suggest using it as a guide to model your strategy.

          We look forward to assisting.
          Hi _Jim, I have found almost the same solution as you that I am testing. I will get back to you as soon as I have also tested your solution. I noticed an error in your script, or an unneeded entry, can you please check, thanks:

          Click image for larger version

Name:	Screenshot_2.jpg
Views:	292
Size:	175.2 KB
ID:	1129796
          sidlercom80
          NinjaTrader Ecosystem Vendor - Sidi Trading

          Comment


            #6
            Hello sidlercom80,

            It is intended. I try to separate what we would handle in OnExecutionUpdate (following SampleOnOrderUpdate) in a separate method so the code structure looks similar. Since the an execution can be a fill/part fill, I only check for that before calling my InlineExcutionUpdate method.
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by jclose, Today, 09:37 PM
            0 responses
            5 views
            0 likes
            Last Post jclose
            by jclose
             
            Started by WeyldFalcon, 08-07-2020, 06:13 AM
            10 responses
            1,414 views
            0 likes
            Last Post Traderontheroad  
            Started by firefoxforum12, Today, 08:53 PM
            0 responses
            11 views
            0 likes
            Last Post firefoxforum12  
            Started by stafe, Today, 08:34 PM
            0 responses
            11 views
            0 likes
            Last Post stafe
            by stafe
             
            Started by sastrades, 01-31-2024, 10:19 PM
            11 responses
            169 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Working...
            X