Announcement

Collapse
No announcement yet.

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, 10:55 AM.

    #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:	86
Size:	376.4 KB
ID:	1129232

    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:	72
Size:	175.2 KB
ID:	1129796

          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 sidlercom80, Today, 02:40 AM
            0 responses
            7 views
            0 likes
            Last Post sidlercom80  
            Started by b16_aln, Today, 01:52 AM
            0 responses
            8 views
            0 likes
            Last Post b16_aln
            by b16_aln
             
            Started by junkone, Yesterday, 08:55 PM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_Jason  
            Started by adaeiqendqw, 01-16-2021, 02:56 AM
            1 response
            15 views
            0 likes
            Last Post NinjaTrader_Jason  
            Started by [email protected], Yesterday, 06:10 PM
            5 responses
            16 views
            0 likes
            Last Post NinjaTrader_ChrisSch  
            Working...
            X