“Initial Balance” Rotation Strategy: Part 8 – Stop Loss

Posted in RTL by astoeckley on March 9, 2011

(This is a continuation in our blog series on creating a trading system from start to finish. Want to see more? Click here for our main RTL support page, which links to all the articles in this series and many more tutorials. Questions? Click here for the RTL Community Forum where you can get help on your programming.)

Our trading system currently has 7 rules:

  • 2 entry rules; one for long, one for short
  • 2 profit target rules, for each long or short
  • 2 end-of-day exits, for each long or short
  • 1 “Main” rule that currently limits the number of trades per day to just 1

You can see all seven rules in our Trading Rules list for this system, which we have already setup:


Once a system enters a trade, long or short, it ignores all other entry rules (except in the case of multiple entries, which are a special case that we will discuss soon). The system only considers the exit rules once a position is active. If a profit target rule is met, the system exits at that price, for a profit. If this target is never met, then our system waits until the end of the day and exits then.

Most traders add additional exit criteria to their trading, “stop losses,” which limit the amount that a position can move against them before exiting and accepting a loss.

Considerations

It is important to understand the reality of this type of exit rule. While it may seem to positively benefit a trading system, by reducing the size of your losses, it can also whipsaw you out of potentially winning trades. For example, a trade might move against you by 3 points before reversing and leading you to profit. If, however, your stop loss takes you out at a 2-point loss, this trade is a loser instead of a winner.

On the flip side, a trade that moves against you by several points could have been a much larger loser without a stop loss.

There is a very delicate balance that traders must carefully consider when choosing stops that work for them.

Today, we will build the stop loss rules into our system. During our optimization phase, which is our next article in this series, we will analyze what are truly the best profit and stop loss levels for our strategy.

The Rules

An exit for a specific loss amount is not unlike an exit for a specific profit amount.

You can either create new signals from scratch, or just open the existing profit target rules and Save As with basic modifications.

For example, we previously built this rule for exiting a long at a 5-point profit:

HI >= ENTRY+5 AND SET(V#1,ENTRY+5)

We set V#1 as the Rule Price so we got out right at that price, even if it was intrabar.

Here is the code for a similar long stop-loss rule:

LO <= ENTRY-2 AND SET(V#1,ENTRY-2)

This provides a 2-point stop level. The stop loss for a short position would be:

HI >= ENTRY+2 AND SET(V#1,ENTRY+2)

When you add the stop signals to the rule list, you may want to use a quantity of “All”. This way, if you later create multiple exits, entries, etc, the stop will always exit whatever position you have, regardless of its amount:

Very Important: As always, the order of the rules in your trading system is crucial to its behavior and backtest results. Remember, the rules are evaluated from the top rule to the last rule for each bar on the chart. If you place your new stop loss rules after the entry rules, it is conceivable that you could enter and get stopped out all on the same bar. If instead your entry rules are the last rules in your list, then your exits, whatever they may be – targets, stops or end-of-day – will always be on at least the bar following your entry.

Backtest Results

Here is a sample trade that shows the stop working:

If you do a lot of backtesting, you will see that stops very often reduce long-term profitability. Here is same 250-day backtest we’ve performed before, using 2-point stops we’ve created here:

This is about half the profit we had before adding stop loss rules for 2 points.

If you want to test the strategy by removing the stops, one way to do so without erasing all your RTL code we’ve created is to simply change the stop to something particularly large, like 50 points. Since it will usually never get triggered, you can compare a more meaningful stop to results without stops, but still keep the stop rules in place.

Avoiding Re-Entry after a Stop Exit

While I won’t go into all the different programming possibilities for different scenarios, here are some issues to consider as you code stop rules.

If you get stopped out, the conditions for an entry may still exit. If you do not limit your trades, as described in our last article, our current backtest system will immediately get you back into a trade, because the entry rules we created simply require that the low has reached or extended beyond the 2X IB level. Thus, when the stop is triggered, the entry rule is still valid and the system gets you back in.

As a more advanced technique, you could allow for multiple entries except when a stop order is triggered. You could add an IF/THEN statement to the stop loss rule that sets a V# to a number, similar to what we did last week, and then use this V# as the condition to limit new entries. It would be similar to the code used in the Main rule last week, but placed inside the stop rules instead of a Main rule, using the condition of the stop rule as the IF condition.

Alternately, and without an IF/THEN statement, you could instead change the entry rules to only enter when prices are, for example, within a 1-point range extending beyond the 2XIB. Currently our entry rules are not this specific. This way, if the stop rule was beyond this range, it would not re-enter immediately after the stop exit, but it could re-enter if prices came back to the 2XIB.

There are  many different ways to code a system like this, and it is open to individual creativity and requirements.

0 Responses to “Initial Balance” Rotation Strategy: Part 8 – Stop Loss

No comments.


Add a Comment