Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unmanaged approach - reverse order - change to market order

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

    Unmanaged approach - reverse order - change to market order

    Hello,

    I am using a logic based on the latest version of the unmanaged approach from ChelseaB given in this forum https://forum.ninjatrader.com/forum/...Tc.#post770579.

    My problem is that I have a long position with an oco bracket order (target and stop). At one point in time based on a signal I want to reverse the position and go short. My initial idea was to convert the target of the bracket order of my long position to a market order to get that filled and submit a new short order as a market order.

    How can I change the existing oco bracket long order in a market order using ChangeOrder? My understanding is that with ChangeOrder, a bracket order cannot be changed into a market order, right?

    Kind regards,
    Gerik

    #2
    Hello Gerik,

    You would need to cancel the target orders and wait for confirmation that they had been canceled in OnOrderUpdate before you submit an entry order into the opposite direction. That entry order can be used to close the position and enter into the opposite direction. You won't be able to convert an already submitted order into a market order, that order needs to be cancelled instead.

    Comment


      #3
      Thank you Jesse!

      Comment


        #4
        Hello Jesse,

        I have another question regarding this topic.

        Using the template of December 2020 shall I cancel the orders within OnBarUpdate and then in case I am short, first submit a cover order and then immediately a buy order? Or shall I - in case I want to be only one contract long -, immediately submit 2 buy orders in case I am short with 1 contract? Then I would need to submit again a bracket order, right?

        Kind regards
        Gerik

        Comment


          #5
          Hello Gerik,

          You would usually want to wait to confirm orders were cancelled by using OnOrderUpdate and then once the order has been canceled check if you are in a position and exit that position. To exit a short position with 1 contract you would submit a order with 1 contract to bring it back to flat, submitting two buy orders would effectively reverse the position. Once you confirm you are flat you can re submit any entries to start the process over again.

          Comment


            #6
            Hello Jesse,

            thank you for your answer.

            Having the template of Chelsea in mind, I would then need to cancel the orders first and then - as you said - wait & check with OnOrderUpdate whether these orders are really cancelled/finished cancelling. During this period of time I would then for consistancy not be able/allowed submit e.g. the reverse order. Independently, the code is still further executing (e.g. I am already on the next bar). Can I submit then in parallel an unmanaged order to avoid the time lag? In case I would submit in parallel a long order and the order has been executed, OnExecutionUpdate would then fire the stopLoss/targetLong orders to the execution network.

            I am confused if I should use for the cancellation the OnOrderUpdate or OnExeuctionUpdate, because Chelsea mentioned in the template
            "/* We advise monitoring OnExecution to trigger submission of stop/target orders instead of OnOrderUpdate()
            since OnExecution() is called after OnOrderUpdate() which ensures your strategy has received the execution
            which is used for internal signal tracking. */"


            Kind regards
            Gerik

            Comment


              #7
              Hello Gerik,

              You can submit orders in parallel like that however that exposes you to overfills. The purpose of waiting on order cancellations is to make sure the still active orders do not fill in addition to the new orders you submit. If you need it to work faster you can change the script to using OnEachTick processing so that your conditions can be checked more frequently.

              OnExecutionUpdate is triggered for just executions, a cancelled order is not an execution so you would need to use OnOrderUpdate for that portion. To submit targets based on a fill you can use OnExecutionUpdate

              Comment


                #8
                Hello, can you provide an example of entering market order and reversing if touched stop target ? I'm looking at the ChelseaB version and not sure to make sense of it

                Comment


                  #9
                  Hello Snoopy_trader,

                  While I wouldn't be able to create a fully working unmanaged example strategy we can go over the topics you may be having difficulty with. Was there a specific portion of that process which you are not clear on?

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by NullPointStrategies, Yesterday, 05:17 AM
                  0 responses
                  65 views
                  0 likes
                  Last Post NullPointStrategies  
                  Started by argusthome, 03-08-2026, 10:06 AM
                  0 responses
                  139 views
                  0 likes
                  Last Post argusthome  
                  Started by NabilKhattabi, 03-06-2026, 11:18 AM
                  0 responses
                  75 views
                  0 likes
                  Last Post NabilKhattabi  
                  Started by Deep42, 03-06-2026, 12:28 AM
                  0 responses
                  45 views
                  0 likes
                  Last Post Deep42
                  by Deep42
                   
                  Started by TheRealMorford, 03-05-2026, 06:15 PM
                  0 responses
                  50 views
                  0 likes
                  Last Post TheRealMorford  
                  Working...
                  X