Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unmanaged stops

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

    Unmanaged stops

    I'm trying to create stop orders, after submitting buy order with a limit price. So I don't know if, when or how much of the order will be filled.
    So this is that I wrote. Does it make sense? Am I using the right parameters in SubmitOrder to create a stop order (_stp is my stop price)?

    Code:
    protected override void OnPositionUpdate(IPosition position){
                if (position.MarketPosition == MarketPosition.Long) {
                    int qnt = position.Quantity;
                    if(_o_stp!=null){
                        ChangeOrder(_o_stp, qnt, 0, _stp);
                    }else{
                        _o_stp = SubmitOrder(0, OrderAction.Sell, OrderType.Stop, qnt, 0, _stp, "", "Stop");
                    }
                    
                }
    }

    #2
    Hello benharper,

    Yes, all of the syntax looks correct. If you are ever unsure of what parameters a method can take you can use the Help Guide's Search feature or use the Intellesense feature to bring up the list by holding down "Ctrl + Shift" and press the Spacebar.
    JCNinjaTrader Customer Service

    Comment


      #3
      Thank you for the help. But besides the syntax, is this logic is solid to create stop orders? Am I understanding OnPositionUpdate and using it correctly?
      I read the documentation, just looking for a second opinion.
      Is this is the right way of creating stop orders? Is there another preferred method when using unmanaged approach?

      Thanks again.

      Comment


        #4
        Hello,

        This is a common approach. It will not submit the stop until the position has been updated. Some users prefer to use OnExecution to us submit the order as this will occur before the position is updated.

        You can see an example of this from the following link: http://www.ninjatrader.com/support/f...ead.php?t=7499
        MatthewNinjaTrader Product Management

        Comment


          #5
          Thank you.
          I see that the sample uses ExitLongStop. Can this method be used when Unmanaged = true?

          The reason I'm using Unmanaged is because I don't want to to use EnterLong for market order. I need to use Stop+Limit [entry is always above the current price] and if I'm not mistaken, managed approach doesn't have this option.

          EDIT: I found out that there's a method called
          EnterLongStopLimit(...)
          Is the part of the managed approach or unmanaged? Can I attached a stop order to that entry without using Events? not that I mind, I just prefer the code to be as simple as possible.
          Thanks again.
          Last edited by benharper; 02-20-2013, 01:28 PM. Reason: additional information

          Comment


            #6
            The example was made in the managed approach, but these methods can be used in unmanaged using SubmitOrder() as well.

            EnterLongStopLimit is a managed order type.

            You can use SetStopLoss() which will be submitted once an execution has occurred on an entry order -- but there are some limitations of it as outlined in the following link:



            Using events is going to give you better control.
            MatthewNinjaTrader Product Management

            Comment


              #7
              Okay so just to get it straight. If I'm using EnterLongStopLimit and in the OnExecution event I'm using ExitLongStop/ExitLongLimit (for stop/target) then basically I don't to use the unmanaged approach. Right?

              Comment


                #8
                Hello benharper,

                Correct, the Enter() methods are the Managed Approach.
                JCNinjaTrader Customer Service

                Comment


                  #9
                  Okay, thanks for all the help so far! I'm going to run it a little bit and see if I learned something.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by DavidHP, Today, 07:56 AM
                  1 response
                  5 views
                  0 likes
                  Last Post NinjaTrader_Erick  
                  Started by kujista, Today, 06:23 AM
                  3 responses
                  9 views
                  0 likes
                  Last Post kujista
                  by kujista
                   
                  Started by Mindset, Yesterday, 02:04 AM
                  2 responses
                  18 views
                  0 likes
                  Last Post NinjaTrader_RyanS  
                  Started by f.saeidi, Today, 08:03 AM
                  1 response
                  5 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Started by samish18, 04-17-2024, 08:57 AM
                  15 responses
                  53 views
                  0 likes
                  Last Post NinjaTrader_BrandonH  
                  Working...
                  X