Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Real dynamics of limit orders

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

    Real dynamics of limit orders

    Hi Ninjas,

    I've always worked with market orders to avoid a lot of issues, but now I see the convenience in some moments of limit orders. I've been reading in the help guide for a complete configuration, but I'm a little confused about the right configuration by some examples, so these are my doubts:

    - What is the correct configuration ? When I try as this example of yours:
    if (BarsSinceEntry() > 10 && CrossAbove(SMA(10), SMA(20), 1))
    EnterLongLimit(GetCurrentBid(), "SMA Cross Entry"); The system shows a compilation error, BUT when I invert positions, first Quantity and then price it goes well

    - If I'm Short and I'd like to change to a long position, should i do this:
    a) Simply put EnterLongLimit(100000, GetCurrentBid() ); and the system will take care of exiting the Long position and opening the short one?

    b) Should I set first : ExitShortLimit(double limitPrice) and then EnterLongLimit(100000, GetCurrentBid() ?

    - If an order is not totally filled and suddenly the system triggers a contrarian order, will the system take care of reverse the uncompleted position to a new completed one?

    Thanks

    #2
    HI pstrusi,

    Originally posted by pstrusi View Post
    Hi Ninjas,

    - What is the correct configuration ? When I try as this example of yours:
    if (BarsSinceEntry() > 10 && CrossAbove(SMA(10), SMA(20), 1))
    EnterLongLimit(GetCurrentBid(), "SMA Cross Entry"); The system shows a compilation error, BUT when I invert positions, first Quantity and then price it goes well
    What is the compile error you're getting? This works fine here and that's the same example from our help guide:


    Originally posted by pstrusi View Post
    - If I'm Short and I'd like to change to a long position, should i do this:
    a) Simply put EnterLongLimit(100000, GetCurrentBid() ); and the system will take care of exiting the Long position and opening the short one?
    Yes, that is correct, although you will still have to be mindful of internal order handling rules.



    Originally posted by pstrusi View Post
    If an order is not totally filled and suddenly the system triggers a contrarian order, will the system take care of reverse the uncompleted position to a new completed one?
    This would likely cause an overfill scenario.
    An overfill is categorized as when an order returns a "Filled" or "PartFilled" state after the order was already marked for cancellation. The cancel request could have been induced by an explicit CancelOrder() call, from more implicit cancellations like those that occur when another order sharing the same OCO ID is filled, or from things like order expirations.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Are really limit orders working under managed approach?

      Hi Ninjas,

      I have a script that sometimes has to send only limit orders, which I understand work under managed approach. I was asking about a couple hypothetical situations and I have many doubts, so I'd like a fresh start asking this questions.

      1. Imagine a script that goes from a Short position to Long Position and again to Short position, these positions has to set at limit orders. Each time that script has to change the position, it will be good enough just to set EnterLongLimit or EnterShortLimit and the system will take care of exiting the old positions and entering the new one?
      I was told that the system correctly will do that BUT I will still have to be mindful of internal order handling rules, What does this mean? in which situations doesn't the managed approach work right?
      Should I instead, Exiting the positions with another limit order before opening the new one?

      2. The scenario where a limit order wasn't completed and suddenly the system has to reverse the position, Should I trust that simply setting the right actual order, the system will be reverse the position to a new one, managing correctly all orders pending? I was told that I might have some overfill order situations.

      Ninjas, my goal is pretty simple. I want to able to send often limit orders that open and reverse positions as the script triggers. Which configurations and steps should I set in order to achieve this correctly?

      Thanks for your help

      Comment


        #4
        Hello pstrusi,

        Thanks for your post.

        1) NinjaTrader will exit your old position and enter your new position automatically. This means that if you exit a position and then enter the opposite position on the same bar, this will cause you to enter double your position. NinjaTrader will see that your position has not updated yet (it takes a few moments after an order is submitted before the position is updated) and will send an order to exit your position. That will be combined with your exit order and this will cause you to be double in the opposite direction.

        2) When changing direction on a partial fill, NinjaTrader will cancel the remaining order, submit an order to exit the partial filled, and then submit an order to enter the new position.

        Keep in mind for this, cancelling a fully filled order will cause an overfill error. So you will want to be sure the order is only part filled before cancelling.

        There may be other considerations but using an entry order in the opposite direction sounds like it will accomplish what you need.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          No problem. I merged your threads since they are the same questions and a direct follow-up to my response.

          Originally posted by pstrusi View Post
          Hi Ninjas,

          1. Imagine a script that goes from a Short position to Long Position and again to Short position, these positions has to set at limit orders. Each time that script has to change the position, it will be good enough just to set EnterLongLimit or EnterShortLimit and the system will take care of exiting the old positions and entering the new one?
          I was told that the system correctly will do that BUT I will still have to be mindful of internal order handling rules, What does this mean? in which situations doesn't the managed approach work right?
          Should I instead, Exiting the positions with another limit order before opening the new one?
          The managed system will take care of the reversal, meaning you only need an EnterLongLimit statement that would both exit the short position and enter long. Internal order handling rules come into play as you would not be able to submit a working limit order in opposite direction, while having active stop loss and profit target.

          2. The scenario where a limit order wasn't completed and suddenly the system has to reverse the position, Should I trust that simply setting the right actual order, the system will be reverse the position to a new one, managing correctly all orders pending? I was told that I might have some overfill order situations
          .

          As mentioned earlier this would likely lead to overfill. You have working orders near the market, a cancel request comes in (implicit with the reversal) and they can't be cancelled since they're already partially filled.

          Ninjas, my goal is pretty simple. I want to able to send often limit orders that open and reverse positions as the script triggers. Which configurations and steps should I set in order to achieve this correctly?
          I recommend practicing as simple as possible with simulated data feed and trend slider. That way you could code a basic limit order reversal strategy and control market direction to force it any time you want. Once you got a basic feel for that you could work in advanced concepts using IOrders, which allows you to cancel and monitor fill status.
          Ryan M.NinjaTrader Customer Service

          Comment


            #6
            Thanks Chelsea for your response.

            I have a doubt with this:

            2) When changing direction on a partial fill, NinjaTrader will cancel the remaining order, submit an order to exit the partial filled, and then submit an order to enter the new position.

            Keep in mind for this, cancelling a fully filled order will cause an overfill error. So you will want to be sure the order is only part filled before cancelling.
            Why would a filled order still exist in the system, it's supposed that it did its job and now is gone, isn't it ?

            Comment


              #7
              Originally posted by pstrusi View Post
              Hi Ninjas,

              I have a script that sometimes has to send only limit orders, which I understand work under managed approach. I was asking about a couple hypothetical situations and I have many doubts, so I'd like a fresh start asking this questions.

              1. Imagine a script that goes from a Short position to Long Position and again to Short position, these positions has to set at limit orders. Each time that script has to change the position, it will be good enough just to set EnterLongLimit or EnterShortLimit and the system will take care of exiting the old positions and entering the new one?
              I was told that the system correctly will do that BUT I will still have to be mindful of internal order handling rules, What does this mean? in which situations doesn't the managed approach work right?
              Should I instead, Exiting the positions with another limit order before opening the new one?

              2. The scenario where a limit order wasn't completed and suddenly the system has to reverse the position, Should I trust that simply setting the right actual order, the system will be reverse the position to a new one, managing correctly all orders pending? I was told that I might have some overfill order situations.

              Ninjas, my goal is pretty simple. I want to able to send often limit orders that open and reverse positions as the script triggers. Which configurations and steps should I set in order to achieve this correctly?

              Thanks for your help
              That will depend on the details of what you are trying to do.

              Is this a Stop&Reverse system, where the reversals are the exits? IOW, no exit targets or Stop Loss set orders? If so, each order will reverse, taking care of the exits. If you have protective orders, the situation gets a bit more complex.

              Comment


                #8
                Thanks Ryan for your response, but reading Chelsea's answer and yours regarding cancelling remaining orders are very confused, Chelsea says:

                When changing direction on a partial fill, NinjaTrader will cancel the remaining order, submit an order to exit the partial filled, and then submit an order to enter the new position.
                And you say :

                You have working orders near the market, a cancel request comes in (implicit with the reversal) and they can't be cancelled since they're already partially filled.
                So, I really don't understand

                Comment


                  #9
                  Hi Koganan, thanks for your response.

                  Yes the orders are exit and reversal positions. Very often I put in parallel Stop/profit orders as extreme emergency measure ( case in massive disconnection or similar ). But for now let's say that I need just a simple system to set and reverse positions with just limit orders.

                  Comment


                    #10
                    Chelsea, let's suppose that is the case, what happens next after the overfill message ? system stops? general fail or the system will try to normalize itself?

                    Comment


                      #11
                      Originally posted by pstrusi View Post
                      Hi Koganan, thanks for your response.

                      Yes the orders are exit and reversal positions. Very often I put in parallel Stop/profit orders as extreme emergency measure ( case in massive disconnection or similar ). But for now let's say that I need just a simple system to set and reverse positions with just limit orders.
                      As long as there are no existing protective orders, calling the reverse order will take care of the reversals automatically: you should NOT issue an Exit() order first. If you are long, a EnterShort...() will exit the long and take you short automatically. Unfortunately, it will do it in 2 steps: an explicit exit followed by the reverse entry. The converse for if you are short.

                      Comment


                        #12
                        Originally posted by koganam View Post
                        As long as there are no existing protective orders, calling the reverse order will take care of the reversals automatically: you should NOT issue an Exit() order first. If you are long, a EnterShort...() will exit the long and take you short automatically. Unfortunately, it will do it in 2 steps: an explicit exit followed by the reverse entry. The converse for if you are short.
                        It makes sense absolutly. Now if you'd want to put simultaneous emergency stop orders with any actual position ( with prices pretty far of market ), will it be for the system a very problematic situation ? I think the system easily could cancel and re-send these kind of orders

                        I appreciate your help.

                        This forum is a great site to clear doubts, excellent support team and expert members like yourself

                        Comment


                          #13
                          Hello pstrusi,

                          I was incorrect about this. Its not really possible to cancel a part filled order and you will always receive an overfill message about this. This is also true when changing your position by using an entry order when the original entry has not finished filling.

                          The best option is to prevent your subsequent orders from being submitted until the order has finished filling.

                          An overfill message will disable your strategy unless you are using the unmanaged approach.
                          If using the unmanaged approach there is a setting to ignore the overfill.
                          http://www.ninjatrader.com/support/h...reoverfill.htm
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            Thanks for clarifying this important point Chelsea

                            Comment


                              #15
                              Originally posted by pstrusi View Post
                              It makes sense absolutly. Now if you'd want to put simultaneous emergency stop orders with any actual position ( with prices pretty far of market ), will it be for the system a very problematic situation ? I think the system easily could cancel and re-send these kind of orders

                              I appreciate your help.

                              This forum is a great site to clear doubts, excellent support team and expert members like yourself
                              It is just as I said. If you have protective orders, the internal order handling rules will prevent this kind of reversal. How far away they are is not germane to the issue.

                              We have had some rather long discussion about this on this board, many of them with me as the protagonist.

                              ref:
                              http://www.ninjatrader.com/support/forum/showthread.php?p=271704
                              http://www.ninjatrader.com/support/f...ad.php?t=39971
                              http://www.ninjatrader.com/support/f...ad.php?t=43855

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by FishTrade, Yesterday, 11:11 PM
                              3 responses
                              11 views
                              0 likes
                              Last Post FishTrade  
                              Started by Graci117, Today, 09:02 PM
                              1 response
                              11 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by ETFVoyageur, Today, 07:55 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post ETFVoyageur  
                              Started by janio973, Today, 07:24 PM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by aligator, 01-06-2022, 12:14 PM
                              4 responses
                              250 views
                              0 likes
                              Last Post john_44573  
                              Working...
                              X