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

Limit or Stop order not getting cancelled with real money account

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

    Limit or Stop order not getting cancelled with real money account

    I have a strategy that I ran in sim mode for a few weeks, and just this week switched it to work in a Forex.com account.

    The strategy is executing orders as expected, and its putting in the stop and limit orders as well.

    However, when a limit order is hit, the stop orders isnt cancelled and is left as an order, and vice versa with the stop order being hit, it doesnt seem to cancel the limit order.

    This was not happening in the SIM account, is there something different I need to do in a real account?

    #2
    Hello ErikY,

    Thanks for your note.

    Please answer the questions below so I may accurately assist.
    • What version of NinjaTrader are you using? Please provide the entire version number. This can be found under Help -> About (Example: 8.0.?.?)​
    • Was the strategy created by you? Or, was the strategy created by a third-party developer?
    • If you created the strategy, did you use the Strategy Builder to create the strategy? Or, was the NinjaScript Editor used?
    • Are you using Set methods or Exit methods to place the target and stop orders?
    • How exactly are your profit target and stop orders being called in the strategy's code?
    Thanks in advance; I look forward to further assisting.

    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_BrandonH View Post
      Hello ErikY,

      Thanks for your note.

      Please answer the questions below so I may accurately assist.
      • What version of NinjaTrader are you using? Please provide the entire version number. This can be found under Help -> About (Example: 8.0.?.?)​
      • Was the strategy created by you? Or, was the strategy created by a third-party developer?
      • If you created the strategy, did you use the Strategy Builder to create the strategy? Or, was the NinjaScript Editor used?
      • Are you using Set methods or Exit methods to place the target and stop orders?
      • How exactly are your profit target and stop orders being called in the strategy's code?
      Thanks in advance; I look forward to further assisting.
      8.0.22
      I created it
      I did not use the strategy builder, I created it in Strategy Builder and then used Visual Studio to code it
      I am using ExitLongLimit, ExitLongStop, ExitShortLimit, ExitShortStop
      I have a method called SetStopLimit which gets called from OnExecutionUpdate in which I do

      Code:
       if (IsEntryOrderFilled(execution))            
      {
                      IdentifyDirection(execution);          
                      if (MyExitType == StopType.Static)                    
                           SetStopProfit(execution);              
      }

      Comment


        #4
        Hello ErikY,

        Thanks for your notes.

        I see that you are using an outdated version of NinjaTrader. The current version of NinjaTrader 8 is 8.1.1.1 which contains many updates and fixes.

        Please update to the latest version of NinjaTrader Desktop by following the steps below.
        • Login into the NinjaTrader Account Dashboard
        • Click "Download" in the bottom left-hand corner of the sidebar
        • Next select "Download" in the "Most Recent Release" Window in the main screen
        • Once the installation had downloaded, ensure any previous version of NinjaTrader is closed before running the installation package.
          • Note: You may need to locate this in your "Downloads" folder in a Windows File Explorer

        After the installation package is completed you will be able to log into NinjaTrader Desktop with the connection guide linked below.

        Connecting in NinjaTrader Desktop

        After updating NinjaTrader, test to see if the behavior persists.

        Note that Exit methods and Set methods cannot be used in the same strategy as this goes against the Managed Approach Internal Order Handling Rules linked below.

        Internal Order Handling Rules: https://ninjatrader.com/support/help...rnalOrderHandl ingRulesThatReduceUnwantedPositions

        You must remove the Set method in your script and replace it with an Exit method, such as ExitLongLimit().

        Note that you would also need to make sure that you are using SignalName and FromSignalName when calling your Entry and Exit order methods to tie the exits to the entry order.

        ​This sample can assist further with managing multiple exit/entry signals:
        https://ninjatrader.com/support/helpGuides/nt8/en-us/using_multiple_entry_exit_sign.htm

        Please let me know if I may assist further.​
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Brandon, Thanks for your help on this, I am in the process of upgrading, but I am looking at my code and I have a further question.

          One thing I noticed is I do not have any specific code to actually cancel my profit order if my stop order is hit, and I don't have any specific code to cancel my stop order if my profit order is hit.

          I created this strategy based on an example I got from someone else and modified it quite a bit, but the original example did not cancel the opposing profit/stop order when one or the other is hit.

          What I cannot figure out is the majority of my trades this seems to be happening automatically, even without the cancel code in place, however, some are not cancelling and I have to cancel manually.

          My question is do I need to figure out on execution, if the execution is the profit order or the limit order, and cancel the opposing one respectively, or is that supposed to happen automatically?

          Comment


            #6
            Hi Erik, We have an existing example here that implements Exit orders and the OCO functionality. This example works as expected to cancel the opposing order if the stop or target gets filled:
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_ChrisL View Post
              Hi Erik, We have an existing example here that implements Exit orders and the OCO functionality. This example works as expected to cancel the opposing order if the stop or target gets filled:
              https://ninjatrader.com/support/help...and_onexec.htm

              Chris, thanks much for the example.

              This is doing things different than how I am doing them, but I am largely tracking the differences.

              Two questions if you don't mind

              1) Is the OCO implied and handled by Ninja, or is the developer doing something to create the OCO condition? I don't see anything being done, but I may be missing something.

              2) I wrote some code to cancel the opposing stop/limit order when the other one is executed through the OnExecutionUpdate method checking to see if the execution was the profit order, then I cancel the stop order, and vice versa on the stop order. If the OCO is implied, will this new code break anything to where it needs to be removed, or will it just move on if the order doesnt exist?

              Comment


                #8
                Hi Eric, the OCO is inferred because the Exit methods take a "FromEntrySignal", in this case, "MyEntry". Once the system sees that the position created by "MyEntry" is closed, it will cancel the associated Exit orders.

                You should remove the code that cancels the orders since it will be done automatically. By the time the order is canceled by the behavior described above, using CancelOrder will do nothing as the order no longer exists.
                Chris L.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_ChrisL View Post
                  Hi Eric, the OCO is inferred because the Exit methods take a "FromEntrySignal", in this case, "MyEntry". Once the system sees that the position created by "MyEntry" is closed, it will cancel the associated Exit orders.

                  You should remove the code that cancels the orders since it will be done automatically. By the time the order is canceled by the behavior described above, using CancelOrder will do nothing as the order no longer exists.
                  Got it, thank you!

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by lightsun47, Today, 03:51 PM
                  0 responses
                  5 views
                  0 likes
                  Last Post lightsun47  
                  Started by 00nevest, Today, 02:27 PM
                  1 response
                  10 views
                  0 likes
                  Last Post 00nevest  
                  Started by futtrader, 04-21-2024, 01:50 AM
                  4 responses
                  46 views
                  0 likes
                  Last Post futtrader  
                  Started by Option Whisperer, Today, 09:55 AM
                  1 response
                  14 views
                  0 likes
                  Last Post bltdavid  
                  Started by port119, Today, 02:43 PM
                  0 responses
                  10 views
                  0 likes
                  Last Post port119
                  by port119
                   
                  Working...
                  X