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

Order Management on Exiting a Position at Multiple Instances

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

    Order Management on Exiting a Position at Multiple Instances

    I am trying to develop a more complicated order management on exiting positions for my strategy. Say my strategy enters me into a position of 2 contracts, what I want the exit strategy to do, is to sell 1 contract once a certain profit is seen and sell the other 1 contract on a trailing stop. Another method I want to test is to sell 1 contract once a certain profit is seen and sell the other 1 contract on a condition. I am at a complete loss of how to do this. Thanks

    #2
    And if the profit target is not met for the one contract then close the full position of two contracts on the trailing stop or exit condition.

    Comment


      #3
      Hello Chris001,

      Thank you for your post.

      You can achieve this by entering the quantity with separate orders and then setting up exits that are appropriate to each entry. The main item to focus on is the signalName and fromEntrySignal strings which will allow you to tie entries and exits together. You will also need to implement your own trailing stop logic as the SetTrailStop() and Exit() methods will conflict based on the Internal Order Handling Rules: http://www.ninjatrader.com/support/h...d_approach.htm

      Comment


        #4
        I think I can define my own trailing stop. So should I create two identical conditions for two separate orders? One order with a set profit target, the other with none, then with separate conditions I define the trailing stops to these orders? I think I can manage that. Will there be any conflict with NT or the broker if I submit two simultaneous orders? Also to try and condense the code a bit, can I place two orders per condition?

        Comment


          #5
          Correct you are on the right track of a valid way to approach the situation.

          There will be no issue with submitting both orders to the broker at the same time.

          Comment


            #6
            Thanks,

            My strategy is now entering two orders per direction. Say my strategy goes long, it purchases two contracts from two identical entry conditions, one contract has an exit signal, the other has the same exit signal and a profit target in a addition. The problem is that immediately after the profit target is met and an exit is made, a re-entry is then made unless both contracts per direction close at the same time (since the entry conditions are still met). I don't want this to happen, I only want both entries to occur together. help please.
            Attached Files

            Comment


              #7
              Hello Chris001,

              You may add a check for your entry orders to make sure you are flat before entering in your orders again using Position.MarketPosition. Here is a link to our Help Guide that you may view that will give you an example of this.
              JCNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by nandhumca, Yesterday, 03:41 PM
              1 response
              12 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by The_Sec, Yesterday, 03:37 PM
              1 response
              11 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by vecnopus, Today, 06:15 AM
              0 responses
              1 view
              0 likes
              Last Post vecnopus  
              Started by Aviram Y, Today, 05:29 AM
              0 responses
              5 views
              0 likes
              Last Post Aviram Y  
              Started by quantismo, 04-17-2024, 05:13 PM
              3 responses
              27 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Working...
              X