Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

if Target Profit reached on previous bar, dont trade current bar

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

    if Target Profit reached on previous bar, dont trade current bar

    I have a strategy that is working nicely except for one situation. In a trend, I can get multiple signals during that trend. That's fine, but what I am trying to avoid is once my profit target is reached (and the positions is closed out), do not enter a new position on the VERY next bar. I want to force the strategy to wait X-number of bars before being ok to enter a long or short position again. What is the best way to approach this?

    Thanks,
    Dwayne

    #2
    Dwayne,

    You can use if (BarsSinceExit() > 5) for instance to prevent reentry.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thanks Josh! I owe you a Super Grande Dr. Pepper next time I see you. Thanks for the info.

      Comment


        #4
        HI Josh,
        The code you recommended is going to work, I think. Here's how I implemented it:

        bool tradeallowed = false;
        .
        .
        .
        if (BarsSinceExit() > 2)
        tradeallowed = true;
        .
        .
        .
        if(<several set up conditions> && tradeallowed) { execute trade}

        However, when I start the strategy, it has obviously not exited ANY trades because I just turned it on, right? SO it will never satisfy the condition BarsSinceExit() > 0. But if I set the basic boolean condition to true, it will bypass the "dont trade again so soon" condition that I am trying to avoid.

        Any suggestions on how to get the strategy going to first make a trade then do the update?

        Comment


          #5
          Glad the sun didn't rise before you read my last post! I think I figured it out. I'll post here for other people who have the same question.

          Before you enter & exit the first trade, BarsSinceExit() == -1. So you just have to add an OR statement to the if() clause:

          if (BarsSinceExit() == -1 || BarsSinceExit() > 2)
          tradeallowed = true;

          Then BOOM! See how your strategy now works?

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          59 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          143 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          161 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          97 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          283 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X