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

Matching SignalName with Limit Orders: Bug?

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

    Matching SignalName with Limit Orders: Bug?

    I have a consistent problem when using limit and stop orders as a substitute for the NinjaTrader managed SetStopLoss and SetProfitTarget functions. I am calling ExitLongLimit and ExitLongStop after verifying that my entrance has been filled by monitoring OnExecution. Both order from ExitLongLimit and ExitLongStop enter their working states, and are filled.

    The profit target operates on a fraction of the original trade quantity. I want to exit the rest of the order quantity at a different point in time (with a different exit condition).

    This is where the troubles begin. Using ExitLong(0,....) fails with the error in the order trace: "SignalName does not have matching FromEmtrySignal to exit." I have checked and verified that my signal names are correct. It just does not exit.

    However, if I use ExitLong(), with no arguments, I exit as expected.

    I would like to exit with a limit order, and not simply exit with ExitLong().

    Is there a known bug regarding signalName for entrance/exit functions?

    This problem is very similar to an earlier problem I had here:



    Bertrand started to work on this problem, but I eventually discovered a workaround.

    Now, that workaround no logner works with my broker, and I am back to where I started.

    Suggestions?

    #2
    Hello Serac,

    This is because using the managed approach you would not be able to Exit() only a partial order based on a single order entry name as NinjaTrader will think the trade is done. To do Exit out on a partial order you would have to create two entry methods each with a different name so that you can split up the orders and each give them a different signal name to Exit. Note that you will have to change the Entry Handling in the Strategy Properties section to "UniqueEntries" to allow both order to get filled.


    Alternatively, you may setup an ATM Strategy with up to 3 different Profit Target and Stop Loss to each be managed differently. NinjaTrades comes with a preloaded SampleAtmStrategy that you may use as reference.


    Let us know if we can be of further assistance.
    JCNinjaTrader Customer Service

    Comment


      #3
      JC,

      Okay, I think I understand. So, are you saying that it should not work to exit a partial position with ExitLong()? If that is the case, then it does not make sense to be able to specify a quantity in any of the Exit functions. Am I missing something?

      I would like to go the ATM route. But, am I correct in understanding that this would not work on historcal data? My strategy already has a self-optimization and self-backtesting capabilities (that I added myself). Making another branch would be too complex (real time, backtest and self-backtest).

      Comment


        #4
        Hello Serac,

        I believe it is there for flexibility and to be able to dynamically define the parameters.

        That is correct, using an ATM Strategy inside of an Automated NinjaScript Strategy you would not be able to test it out using the Strategy Anlyzer or any Historical Data testing method. You may use Market Replay data to test this out.
        JCNinjaTrader Customer Service

        Comment


          #5
          JC,

          I just want to be very clear so I am sure I understand.

          Suppose, using Ninja's managed orders, I enter a trade long with quantity 100. Some time later, I exit via ExitLongLimit, of quantity 50. This means that there are still 50 units in a long position.

          1. My Position.MarketPosition == MarketPosition.Long continues to be true, correct?
          2. If I invoke ExitLong(), will either:
          2a). I exit the remaining 50 units at market and be flat; or
          2b). I exit the remaining 50 units at market and go short 50 units.
          2c) Neither 2a or 2b.
          3. If I invoke ExitLongLimit(blah, blah...) a second time with Quantity = 50, this will fail, by NinjaTraders managed order design. Yes?

          Thanks!

          Comment


            #6
            Originally posted by NinjaTrader_JC View Post
            Hello Serac,

            This is because using the managed approach you would not be able to Exit() only a partial order based on a single order entry name as NinjaTrader will think the trade is done. To do Exit out on a partial order you would have to create two entry methods each with a different name so that you can split up the orders and each give them a different signal name to Exit. Note that you will have to change the Entry Handling in the Strategy Properties section to "UniqueEntries" to allow both order to get filled.


            Alternatively, you may setup an ATM Strategy with up to 3 different Profit Target and Stop Loss to each be managed differently. NinjaTrades comes with a preloaded SampleAtmStrategy that you may use as reference.


            Let us know if we can be of further assistance.
            Please clarify the NT Help text on this page: http://www.ninjatrader.com/support/h...d_approach.htm (image below), which seems to imply that partial exits are possible. Are you saying that partial exits are only possible if using Market Orders with no signalEntryName?
            Attached Files

            Comment


              #7
              Hello Serac,

              1. Correct.
              2. It will try to make your account flat, but the order will be ignored stating 'There already is a matching, filled exit order in place' if you do not define a unique signal name for each
              3. It will not fail but NinjaTrader will ignore you order so it will not be processed unless you have two entry orders with a different signal name, and you call the ExitLong method for each one.

              Hello koganam,

              Thank you for pointing that out in our Help Guide, after the first call of ExitLong(1) the order will be ignored since NinjaTrader will think 'There already is a matching, filled exit order in place'. I will notify our Development Team to either change the Help Guide or the functionality of this example.
              Last edited by NinjaTrader_JC; 03-06-2013, 08:08 AM.
              JCNinjaTrader Customer Service

              Comment


                #8
                Serac,

                We looked into this further and have indeed incovered a bug that will be fixed with NinjaTrader 8. The scale out does work as per our Help Guide in backtest but does not work as expected in real-time. Thanks for your patience on working through this with us.
                RayNinjaTrader Customer Service

                Comment


                  #9
                  Thanks for the reply, Ray. Looking forward to NT8.

                  Comment


                    #10
                    Originally posted by NinjaTrader_Ray View Post
                    Serac,

                    We looked into this further and have indeed incovered a bug that will be fixed with NinjaTrader 8. The scale out does work as per our Help Guide in backtest but does not work as expected in real-time. Thanks for your patience on working through this with us.
                    Which does not work correctly in real time? The one that I pointed out, or the one that Serac pointed out? Or both?

                    Comment


                      #11
                      koganam,

                      Hopefully this will clear the air a bit. Both your and Serac's examples are scenarios of using ExitLong() market orders to try and scale out. Using market orders to scale out works in backtest, but NOT in real-time.

                      So to summarize this all up it is like this currently.
                      - ExitLong() scale out in backtest <-- works
                      - ExitLong() scale out in real-time <-- bugged
                      - ExitLongLimit/Stop() scale out in backtest or real-time with same fromSignalName <-- not designed to work in this manner
                      - ExitLongLimit/Stop() scale out in backtest or real-time with unique fromSignalName per scale out "leg" (a.k.a. you scaled in) <-- works
                      - unmanaged approach's SubmitOrder() scale out in backtest or real-time <-- works regardless of signal names
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_Josh View Post
                        koganam,

                        Hopefully this will clear the air a bit. Both your and Serac's examples are scenarios of using ExitLong() market orders to try and scale out. Using market orders to scale out works in backtest, but NOT in real-time.

                        So to summarize this all up it is like this currently.
                        - ExitLong() scale out in backtest <-- works
                        - ExitLong() scale out in real-time <-- bugged
                        - ExitLongLimit/Stop() scale out in backtest or real-time with same fromSignalName <-- not designed to work in this manner
                        - ExitLongLimit/Stop() scale out in backtest or real-time with unique fromSignalName per scale out "leg" (a.k.a. you scaled in) <-- works
                        - unmanaged approach's SubmitOrder() scale out in backtest or real-time <-- works regardless of signal names
                        Thanks for looking into it.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by bmartz, 03-12-2024, 06:12 AM
                        4 responses
                        31 views
                        0 likes
                        Last Post bmartz
                        by bmartz
                         
                        Started by Aviram Y, Today, 05:29 AM
                        4 responses
                        12 views
                        0 likes
                        Last Post Aviram Y  
                        Started by algospoke, 04-17-2024, 06:40 PM
                        3 responses
                        28 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Started by gentlebenthebear, Today, 01:30 AM
                        1 response
                        8 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Started by cls71, Today, 04:45 AM
                        1 response
                        7 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Working...
                        X