|
|
|
Log In | Sign Up | ||
Stop Loss, Take Profit and Trailing Stops in BacktestsStops and targets often decide a strategy’s result more than its entry rule does. In a backtest they also behave in ways that aren’t obvious: when they become active, what happens on a gap, and which one wins when both are hit on the same day. Here’s how stop loss, take profit, trailing stops and time limits work in MarketInOut’s backtester, with examples. Where to set themOn the strategy page, the Position Maintenance section has four exits. You can use any combination, together with a closing formula:
Percent or ATRDistances can be set in percent or in multiples of the 14-day Average True Range (ATR), a measure of how much the stock usually moves in a day. In percent. You buy at $100 with a 15% stop loss, a 35% take profit and a 20% trailing stop:
In ATR. You buy at $160 when the ATR is $12, with a 2 ATR stop loss, a 5 ATR take profit and a 2 ATR trailing stop:
ATR-based stops adapt to each stock: a volatile stock gets a wider stop, a quiet one a tighter stop. Percent stops are simpler to reason about but treat a utility and a biotech the same way. When stops become active
When stop and target are hit on the same dayOn daily data the backtester sees each day’s open, high, low and close, but not the order in which they happened. If a day’s low touches the stop and its high touches the target, it can’t know which came first, so it assumes the worse: the stop. This makes results slightly pessimistic, which is the safer mistake to make. Stops and targets are the only way a position can close in the middle of a bar. A closing formula is checked at the close. Time limits and rebalancingClose position after a number of bars suits short-term strategies where the edge, if any, lasts a few days. Close position at the end of a month, quarter or year empties the portfolio at that point, and new positions open from the next bar. That’s how to test a strategy that rebalances regularly, such as holding the ten strongest stocks each month. Finding good settings with the optimizerThe optimizer tests a range of stop and target values in one go. Give it a start, a step and an end, such as 10 / 2 / 20, and it runs 10, 12, 14, 16, 18 and 20 side by side, in the strategy’s unit (percent or ATR). Use it to see how sensitive the strategy is, not to find the single best number. If results change a lot between a 12% and a 14% stop, the strategy is fragile. If they are similar across the range, the exit rule is robust, and a value in the middle of that range is a reasonable choice. Practical tips
More detail in the help pages: position maintenance. See also how the backtester simulates trades. |
Disclaimer - Privacy Policy - Terms of Service - Cookies - FAQ - Affiliates - Blog |