Markets will always exhibit trends.
It's part of human nature. Trends develop as people get excited about a new stock, or as technology or the regulatory environment changes. It's hard to know what trend is going to be successful and keep an eye out for everything, so we rely on algorithms to identify these.
The Parabolic Stop-and-Reverse (PSAR) is designed to catch these moves by identifying the start of a trend. Typically, charts overlain with the PSAR indicator look like this one:
Here we have the price of Microsoft (MSFT) with dots below and above the price line. The dots below indicate an up trend and the dots above are a down trend. When the dots switch, we have a trend reversal.
Prefer a video?
Watch us design and test a trend following trading algorithm with the PSAR in the video below!
Build a Trading Algorithm with the PSAR
Our Strategy Builder makes it easy to get started with systematic trading and to experiment with the PSAR (and other indicators).
To add it, go to the Strategy Builder and click the tab labeled When to Buy. Select PSAR from the dropdown and you should see something like this:
Go to the When to Sell tab and add the PSAR as well, just change it to sell when we see a down trend.
That's it! You've now added the PSAR indicator as a buy signal to your trading algorithm, so you can click Run Backtest to see how it performs.
Of course, you probably want to do a bit more customization, so let's look the Settings tab.
Instrument Selection and Risk Management
A trading system is more than just buy and sell signals, you need to know what you're going to trade and set up rules around position sizing and management. The Settings tab is where you'll add this info.
I'm partial to trading ETFs to get sector exposure rather than individual names - obviously, you can do either - and there are advantages to both. In Settings, go to Stock Selection and add a handful of tickers you'd like to trade (note subscribers get access to over 11,000 ETFs and stocks, free users only get names in the S&P 500).
Here, I chose some long/short levered S&P 500 ETFs (SSO and SDS), a NASDAQ ETF (QQQ), the JETS ETF that trades airlines, and the XLE ETF which is focused on energy stocks. This isn't terribly diversified, but good enough for a quick example!
We'll run this for the past 12 years, but we could go back to 2000 - just note that longer backtests will take more time to complete, but they'll see more market conditions. Also, going back further reduces the chance that your chosen instruments existed in the past (which is the case for a few of these ETFs).
Next, we'll choose a few key risk management parameters: Position Sizing and Position Management.
Position Sizing Selection: How much to Bet on Each Trade?
Position sizing is absolutely crucial to controlling your risk. Betting too large can make a profitable strategy blow up and wipe out your account, so its important to find something that works.
For this example, we'll use the Volatility Allocation setting which scales position sizes according to the risk. The Volatility Period sets the amount of time this is calculated for, the Risk Coefficient scales the risk metric (volatility in this case) up or down, while Max Risk Fraction sets the fraction of your account size you want to put into a position.
In short, if the volatility is really high (e.g. you're trading Bitcoin), then the risk-adjusted position size will be smaller. If you're trading something with very low volatility, then you'll increase your bet size because it's steadier. It's the same kind of volatility targeting rule as outlined in Carver's Starter System.
In this example, we'll use a 1-year or 252-day lookback period and set the the Max Risk Fraction to 0.3 because we only have a few instruments.
Position Management: Should I add to my Position or take Money off the Table?
Position Management defines how you handle a position once it has been opened. Say you bought 10 shares of QQQ and the volatility increases. Do you re-adjust due to increased risk or not? What if it increases in price, do you add to the position because the trend is working for you or take money off the table?
These are the types of questions our position management selection seeks to address.
There are a lot of options here, but as you can see in the screenshot above, I opted for No Risk Management meaning no position management rules will be applied. Once a trade is on, it's on until I hit my exit rules.
Backtesting the PSAR
To test this, simply click the Run Backtest button and see what your strategy does!
This doesn't look too great. Just having the PSAR yielded 2.2% percent returns over 12 years with a lot of trading involved.
These results shouldn't be surprising: no indicator is perfect and most backtests will fail, especially if designed in a rather naive way.
I have had good success applying solid trend following principles and combining the PSAR with a trend filter, so let's see how that works.
Improving your Backtest with a Trend Filter
Go back to the When to Buy tab and let's add a simple moving average (SMA) crossover as a second indicator. This will change the algorithm so it will only buy if both of these conditions are met.
The precise values of the SMA crossover aren't that important, just make sure it's fairly long term (>150 days) and we should be on solid ground.
The PSAR is good for finding entry points for your trading system. Adding this filter will make sure it buys during longer-term trends which will reduce the number of signals and hopefully lead to more valuable signals to trade.
We're going to make an update on the When to Sell tab too.
We don't want to look for long-term trends and then quickly exit a trade because a short-term momentum signal says so - that would defeat the purpose by cutting off trades too early in the trend and capping our profits. We'll just keep things simple and replace the PSAR sell signal with a trailing stop loss.
For long-term trend following strategies, I've found that you don't want to set your stop too tight because - just like with using the PSAR as an exit signal - you'll get knocked out of your trade early. However, you don't want to set it too loose either because you'll give back a lot of profit before reaching your stop.
There's a happy medium.
Usually, we can get some good results with trailing stops between 10-20% for this kind of strategy, so I'll split the difference and go with 15% to see how this performs.
Again, just click Run Backtest and wait for your strategy to load the data and run!
In this case, we've got a good looking strategy!
We've beat our baseline and turned in some decent risk metrics.
While our win rate has dropped below 50%, we've dramatically increased the typical return per trade. Think of this like a big-league slugger that goes up there and swings for the fences every time. He'll generate a lot of strikeouts, but he'll also hit a lot of home runs.
You can do some work to improve this strategy - add more instruments for better diversification, change the risk management, adjust stops or exits, and so on - to tailor it to your needs. But when you're satisfied with it, save your strategy and power it on in your Bot Garage to receive trade alerts at the end of each day and updates on your strategy's performance.