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

How to set a Profit Target that closes only a specified quantity ?

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

    How to set a Profit Target that closes only a specified quantity ?

    Hello

    I have coded a strategy that opens positions with the EnterLong(int quantity) function.
    I would like to know if it is possible to set a profit target that will automate the closing of a part of the position ?

    Example :
    - open a position with function call EnterLong(10000, "mystrategy");
    - some minutes later, when the target profit is reached, automatically close a part of the position as if were called function ExitLong(5000);

    Thanks

    #2
    Hello,

    Thank you for the post.

    In this case, if you have only a single entry you would want to avoid using the Set methods as they dont take a quantity but are based off signal names. If you have multiple entries you could use the Set methods and associate the different quantities with the different signal names.

    You could also utilize the other types of order methods such as limit or stop limit orders depending on the target needed. The Exit methods as you have noted as also an option, it would really depend on what type of target is needed and what type of order you want to use for that target and what your overall goals are.

    In your strategy, you would need to create an additional set of logic to control the target order methods. The condition could be a price condition for the Exit orders or could be based on Entry fills. This again depends on your overall goals for the script.

    If you have not yet reviewed the references section here on the forum, there are a few different examples of various ways to manage targets. Here is a link to the references: https://ninjatrader.com/support/foru...ead.php?t=3220

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Ok thank you for your answer and tips.

      Comment


        #4
        Hello

        I have mutiple entries so I will try to use the SetProfitTarget() as you described.
        Thanks

        Comment


          #5
          Hello

          The issue is now resolved

          As you suggested, I open 2 orders at the same time, with different Signal Names and I use the Set functions to define the SL and TP on each order.

          Thanks !!!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Irukandji, Yesterday, 02:53 AM
          2 responses
          17 views
          0 likes
          Last Post Irukandji  
          Started by adeelshahzad, Today, 03:54 AM
          0 responses
          3 views
          0 likes
          Last Post adeelshahzad  
          Started by CortexZenUSA, Today, 12:53 AM
          0 responses
          3 views
          0 likes
          Last Post CortexZenUSA  
          Started by CortexZenUSA, Today, 12:46 AM
          0 responses
          1 view
          0 likes
          Last Post CortexZenUSA  
          Started by usazencortex, Today, 12:43 AM
          0 responses
          5 views
          0 likes
          Last Post usazencortex  
          Working...
          X