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

ExitShortStopLimit error

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

    ExitShortStopLimit error

    Hi,

    My strategy did an EnterShort on YM, and got a (simulated) fill at 12630. I then wanted to place bracket orders for profit target and stop loss. Once the position was filled (Position.Quantity != 0), I did ExitShortStopLimit(12550, 12750). I got an error message saying that limit price has to be greater than stop price! That is true on a long position, but this was a short position.

    How do I place bracket orders? (I don't want to use SetStopLoss() and SetProfitTarget(), because the offsets change for each order, but I want the same type of dual exit strategy, with one canceling the other).

    For example, before I place the order, I know that whether I get filled at 12700, 12705 or 12695, I want my limit to be 12650 and my stop to be 12750. That's all I want to accomplish, and that's why I can't use SetStopLoss and SetProfitTarget, because they are relative to the fill price.

    Thanks
    Last edited by andrewbee; 02-01-2008, 11:06 AM.

    #2
    I also tried doing:

    ExitShortLimit(limit);
    ExitShortStop(stop);

    instead of ExitShortStopLimit(), with the same exit points. The orders showed up in the orders window, but the state was 'Canceled'

    How can it be so difficult to set up a simple OCA exit strategy?

    Comment


      #3
      On your first post -

      That is expected. You are placing a buy stop limit (to exit a short) and thus the limit price must be greater or equal to the stop price. 12550 is less than your stop of 12750.

      On your second post -
      This is not enough information for me to comment on. I suggest changing your logic so that only one position is opened and see if the orders behave as you expect. If not, try to debug why that may be the case.
      RayNinjaTrader Customer Service

      Comment


        #4
        Originally posted by NinjaTrader_Ray View Post
        On your first post -

        That is expected. You are placing a buy stop limit (to exit a short) and thus the limit price must be greater or equal to the stop price. 12550 is less than your stop of 12750.
        Maybe I don't understand what ExitShortStopLimit is supposed to do...

        What I am aiming to do is simply enter a pair of bracket orders, to close the position if either the profit target or stop loss are hit. What is the best way to do this (without using SetStopLoss() and SetProfitTarget(), because those have to be set before you place the order, and you don't yet know what price you will get filled at).

        Thanks

        Comment


          #5
          Before I comment -

          How do you determine at what price you will want your stop loss and profit target?
          RayNinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_Ray View Post
            Before I comment -

            How do you determine at what price you will want your stop loss and profit target?
            By an automated trading algorithm.

            Comment


              #7
              if (signalCondition == true)
              EnterLong();

              ExitLongLimit(yourLimitPrice);
              ExitLongStop(yourStopPrice);
              RayNinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_Ray View Post
                ExitLongLimit(yourLimitPrice);
                ExitLongStop(yourStopPrice);
                If you look at my posts above, I already said that I tried using ExitShortLimit() and ExitShortStop() (and also the long equivalents), but the orders come up as 'Cancelled' in the orders window. And yes, there is a position open prior to making those calls.
                Last edited by andrewbee; 02-01-2008, 11:25 AM.

                Comment


                  #9
                  This is not enough information for me to comment on. I suggest changing your logic so that only one position is opened and see if the orders behave as you expect. If not, try to debug why that may be the case.
                  RayNinjaTrader Customer Service

                  Comment


                    #10
                    Not enough to comment on? I thought I'd spelled it out pretty clearly: the orders that arise from calls to ExitLongLimit, ExitLongStop, ExitShortLimit or ExitShortStop appear in the orders window, but the state is 'Cancelled', not 'Working' or 'Accepted' as I would have expected.

                    Why is this happening?

                    Comment


                      #11
                      - Maybe the orders are DAY and they are not triggered within the span of a session and then they are cancelled?

                      I really don't know why you are experiencing the behaviour you are. That is why I asked you to strip down your strategy so that we can start very simple to see if it works as you expect.

                      Debugging is frustrating and time consuming. We unfortunately can not debug everyones code from start to finish and thus my suggestions are aimed to boil it down to a level where I can provide some deeper assistance.

                      Thanks for understanding.
                      RayNinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by giulyko00, 04-24-2024, 12:03 PM
                      9 responses
                      43 views
                      0 likes
                      Last Post giulyko00  
                      Started by memonic, Yesterday, 01:23 PM
                      2 responses
                      24 views
                      0 likes
                      Last Post memonic
                      by memonic
                       
                      Started by merc410, Today, 03:41 AM
                      2 responses
                      15 views
                      0 likes
                      Last Post merc410
                      by merc410
                       
                      Started by sugalt, 04-30-2024, 04:02 AM
                      2 responses
                      13 views
                      0 likes
                      Last Post sugalt
                      by sugalt
                       
                      Started by Ndakotan1313, 03-14-2024, 05:02 PM
                      2 responses
                      64 views
                      0 likes
                      Last Post blaise_code  
                      Working...
                      X