PDA

View Full Version : if Target Profit reached on previous bar, dont trade current bar


paschall
09-01-2009, 11:16 PM
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

NinjaTrader_Josh
09-02-2009, 07:25 AM
Dwayne,

You can use if (BarsSinceExit() > 5) for instance to prevent reentry.

paschall
09-02-2009, 08:10 AM
Thanks Josh! I owe you a Super Grande Dr. Pepper next time I see you. Thanks for the info.

paschall
09-02-2009, 10:08 PM
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?

paschall
09-02-2009, 10:34 PM
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?