Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ExitLongStop, ExitLongLimit and OCO

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

    ExitLongStop, ExitLongLimit and OCO

    I am using ExitLongStop and ExitLongLimit to set a profit target and stop order once I get a fill on my entry (in OnExecution event).

    I am specifying the correct "fromEntrySignal" parameter on both. I am wondering if there is a way to tie these two together as an OCO. Or must I use CancelOrder on the Stop or Target that didnt process?

    I was hoping to use OCO instead, but I cant seem to find a way to do this or do I just set the .Oco value on the IOrder of each to the same string? Does it matter what this string is or does it just need to be the same?

    #2
    There is internal OCO handling in place where if the stop is filled, it will cancel the target...Please verify this in your situation.
    RayNinjaTrader Customer Service

    Comment


      #3
      This is not working in my case. But could it be because I am using the method signature

      Code:
       
      ExitLongStop(int barsInProgressIndex, bool liveUntilCancelled, int quantity,double stopPrice,string signalName,string fromEntrySignal)
      Per the example for using OnExecution? If I use one of the other signatures that does not have bool liveUntilCancelled, maybe that will have the OCO working correctly then?

      Comment


        #4
        I changed to
        Code:
         
        ExitLongStop(int quantity, double stopPrice, string signalName, string fromEntrySignal)
        method signature (on both ExitLongStop and ExitLongLimit and still no OCOs are getting set)

        Comment


          #5
          To make sure we are on the same page -

          - Enter long 1 contract
          - You call ExitLongStop() and ExitLongLimit for 1 contract
          - If the limit is filled --> You are saying the stop is not cancelled and stays there?
          RayNinjaTrader Customer Service

          Comment


            #6
            Correct. And when looking in the "Orders" tab when Stop/Limit is Working and Accepted, the OCO column is blank for both of them.

            Comment


              #7
              Right, OCO being blank is expected since the OCO is not an OCO order but part of internal strategy handling that cancels out orders.

              - This can be reproduced in a backtest? If yes, can you post us a simple stripped down strategy that demonstrates this problem?
              RayNinjaTrader Customer Service

              Comment


                #8
                Seems to work properly during backtest. I will run again during real-time and see if it is still a problem or just some weird code issue on my side. I will post stripped down code if I can confirm it happens again in real-time.

                Comment


                  #9
                  Thanks for your efforts in this matter bigtrade5. We appreciate it.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Confirmed the issue today in Real-time with IB connection. Have taken some screen shots of "Orders" tab, but once stop was filled, target was left in "Working" state.

                    The code is as you describe above.

                    Code:
                     
                    In OnBarUpdate()
                    EnterLong(DefaultQuantity, "1 Entry");
                     
                    In OnExecution()
                    ExitLongStop(0, true, execution.Order.Filled, execution.Order.AvgFillPrice - Loss * TickSize, "1 Stop","1 Entry");
                    ExitLongLimit(0, true, execution.Order.Filled, execution.Order.AvgFillPrice + Profit * TickSize, "1 Target","1 Entry");
                    I can code around it for now without a problem. Dont know why it would matter but so you know, I am taking the IOrder returns from the above and placing them into a Class I am using for tracking my orders.

                    Comment


                      #11
                      Would be great if you had a simple sample strategy excluding any of your own classes that can replicate this so we can look into it.
                      RayNinjaTrader Customer Service

                      Comment


                        #12
                        Can do, I will create something more basic and give it a test tomorrow, then upload it if I have the same issue.

                        Comment


                          #13
                          Same issue. Attached slimed down strategy (based on Josh's "Using OnOrderUpdate() and OnExecution() methods to submit protective orders" code)

                          I have a word doc with more details and screenshots, but its too large (347 kB) to upload here.
                          Attached Files
                          Last edited by bigtrade5; 05-15-2008, 07:51 AM.

                          Comment


                            #14
                            I have ran this for 1.5 hours now and its working so far as expected in real-time.
                            RayNinjaTrader Customer Service

                            Comment


                              #15
                              What broker? Again I am using IB. Let me try running it against the simulation account using R/T rather than my IB account which is where I am having the problems.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              558 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              324 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              101 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              545 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              547 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X