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 Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          627 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          359 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          105 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          562 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          568 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X