Avoiding Immediate Re-Enry After A Trading Strategy Exit

This tip is similar to the earlier one called “Avoiding immediate re-entry after a stop”, but the technique is different. This one is more brute force. You should read the earlier one too, and decide which is right for you. Another related tip is in the section “Tips from NeuroShell Trader Users” called “What to Do if Your Optimized Trading Strategy Trades Too Much”. That user tip is a more brute force solution to our tip of the same name in this section. Please read them all. Lets say the situation is this: your strategy trades too much and you just can’t figure out how to make more effective rules, so you just want some brute force method to make sure there is no re-entry until at least X bars have passed since your trading strategy last exited.

The solution lies in the indicator category called “Trading Strategy: Position Information”. The first indicator of interest is called “Bars Since Exit Filled”. It tells you the number of bars that have passed since the last trading strategy exit got it’s fill. So your first attempt at a solution might be to just add a second long and/or short entry condition such as:

Bars Since Exit Filled > X

The only problem is that Bars Since Exit Filled is zero if there have never been any trades at all, so your new rule would work except that it never lets you get into the very first trade. Try it and you’ll see.

To solve the problem you need to see if you are trying to get into the first trade or not. For that you can use the indicator “Value when Entry Activated” and apply it to the close. That will give you the value of the close when the last trade was signaled. If there were no previous trades (i.e, you are entering the first one), then it has a value of zero.

So the final solution is this: Add a second long and/or short entry condition as follows using the “If CONDITION then” indicator from the Rules section:

IF
Value when Entry Activated >0
THEN
Bars Since Exit Filled > X
ELSE
1

The net result of the above is that if there have been no previous trades, then the rule is true (1). If there have been previous trades, the rule is true if and only if Bars Since Exit Filled > X is true.

If you want to set up your trading strategy to go both long and short, then the conditions will be a bit more complicated due to avoiding reversals which cause immediate re-entry.

One word of caution, however. Our use of the Trading Strategy: Position Information indicators will make our trading strategy very, very slow, since these indicators are internally recursive in nature. In particular, optimization may be very painful.

Click here to download a chart where we have demonstrated both techniques.

Was this article helpful?

Related Articles