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

Exit Conditions

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

    Exit Conditions

    Hi,

    I've built a strategy using strategy builder and tested successfully with fixed target and stop.

    I'd like to add an exit condition as per the below logic. Any idea how do I add to the existing code? Appreciate the help

    Close Buy: If 3 POSITIVE MACD histogram bars close. One closes, then the next closes
    lower, then the next closes lower.

    Close Sell: If 3 NEGATIVE MACD histogram bars close. One closes, then the next closes
    higher, then the next closes higher

    #2
    Hello ark321,

    Thanks for your post.

    In a new set(s) in your strategy, you would add the condition that checks for the market position being long or short. Reference: https://ninjatrader.com/support/help...ionComparisons

    In addition, you would check the Macd.diff plot for the 3 bars. I've added a screenshot of what the long side would look like. Note that you have to select the "Diff" for the value plot each time and note that you have to set the "Bars ago" . For your understanding, bars ago of 0 is the current bar, 1 is the previous bar and 2 is the bar before that.
    For the exit order, you could select Order Management> Exit long position under the do the following section.

    Click image for larger version

Name:	ark321-1.PNG
Views:	361
Size:	58.1 KB
ID:	1169155
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      This helps! Thanks a lot.

      Comment


        #4
        btw, do you enter the entry conditions and exit conditions in two separate tabs (Set1, Set 2 )?

        Comment


          #5
          Hello ark321,

          Thanks for your reply.

          Typically yes you would have entry conditions and entry method in one set and another set with exit conditions and the exit method.

          Paul H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by carnitron, Today, 08:42 PM
          0 responses
          5 views
          0 likes
          Last Post carnitron  
          Started by strategist007, Today, 07:51 PM
          0 responses
          6 views
          0 likes
          Last Post strategist007  
          Started by StockTrader88, 03-06-2021, 08:58 AM
          44 responses
          3,973 views
          3 likes
          Last Post jhudas88  
          Started by rbeckmann05, Today, 06:48 PM
          0 responses
          8 views
          0 likes
          Last Post rbeckmann05  
          Started by rhyminkevin, Today, 04:58 PM
          4 responses
          58 views
          0 likes
          Last Post dp8282
          by dp8282
           
          Working...
          X