Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using an indicator to exit positions

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

    Using an indicator to exit positions

    Hi,

    My current strategy has a calculated entry, which attaches a fixed profit target and stop loss. I want to change this to use an indicator to exit an active trade.

    That being said, so I rewrote my strategy that still uses the same entry conditions, calculate the entry and stop loss. I am now stuck on how to add an indicator to exit the position when a certain condition is met.

    For instance, let's say I enter a long trade at X price. The order is filled and attaches my calculated stop loss as an OCO. Now let's say price rallies up and close outside of a channel, I want to use that indicator to exit the trade and cancel the OCO order to flatten the position. Secondly, let's say price retraces under a MA the I also want to exit the trade and cancel all other attached orders.

    Is this possible through the builder or what will the code look like in the script editor?

    thanks

    #2
    Hello Induna,

    You can set the stop or limit price of an exit order to an indicator.

    You would want to first check that the indicator price is valid for the order type and side of the market. (Meaning above or below the ask or bid as appropriate)

    This would be possible with the strategy builder by clicking set in the Stop or Limit price of an exit order and selecting the indicator. This would not be possible using the stop loss and profit targets on the last page in the strategy builder as these are not updated dynamically.

    True OCO is not possible in the strategy builder and would require unlocking the script, but NinjaTrader will send cancellation orders for any orders attached to a position and the position closes.

    Exit orders submitted by the strategy will automatically be cancelled if they are not called on each new bar as they will be submitted without using isLiveUntilCancelled as true.

    Below is a link to an example script that sets the price of an exit order created with the strategy builder.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Let me rephrase, I want to exit a position for instance when the double stochastic crosses above its oversold line. I do not want to look at price at this moment when closing the position. I want to close a position when an indicator is above or below a specified parameter, not the price. Another example is I maybe want to close the position when the Keltner Channel closes above the upper line of the channel for a long position.

      On the ExitLong method I can only specify price, and this is not what i want to do. If this cannot be done, how can I do it by unlocking the code? Typically what will the code be for this method?

      Comment


        #4
        I found the answer to my own question... I just had to create additional sets in the builder and then add the conditions and then an exit action, based upon those conditions.

        Thanks

        Comment


          #5
          Hello Induna,

          The exit long position is a market order which does not accept a price (as it fills immediately at market price), and you can send this in a condition set with conditions for a Keltner Channel Midline being greater than the Keltner Channel Upper.

          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Good evening,

            Can you be more specific about how to set the exit order to an indicator? I can't tell based on the examples provided.

            Comment


              #7
              Hello conniejforextrader,

              If you want to set the stop or limit price of your exit order, you need to click on 'set' in the Stop or Limit price section of the exit order properties, then select the indicator you want to use.

              Please let us know if you have any further questions.
              Attached Files

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Yesterday, 05:17 AM
              0 responses
              56 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              132 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              73 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              45 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              49 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X