In this article I will create a trend filter also known as market mode filter or regime filter that is adaptable to volatility and utilizes some of the basic principles of hysteresis to reduce false signals whipsaws.
As you may know, I often will use the period simple moving average SMA to determine when a market is within a bull or bear mode on a daily chart. When price closes above our SMA we are in a bull market. Likewise, when price is below our SMA we are in a bear market.
Naturally, such rules will create some false signals. By the end of this article you will have a market mode filter that can be used in your system development that may produce better results than a standard SMA filter. To build our better market trend filter we will use the following concepts:. When building trading systems many of the decisions have a binary outcome.
For example, the market is bearish or bullish. Hysteresis was used in a previous article on reducing whipsaws within a moving average crossover trading system. While the word Hysteresis was not used specifically in that article, it was a good example. The common analogy to help understand the concept of hysteresis is to imagine how a thermostat works. When the temperature falls below our critical threshold the heaters turn on and begin blowing warm air into the room.
Taking this literally as soon as the temperature moves to Once the temperature reaches In a short time the room begins to cool and our heaters must turn on again.
What we have is a system that is constantly turning off and on to keep the temperature at 70 degrees. This is inefficient as it produces a lot of wear on the mechanical components and wastes fuel. As you might have guessed, hysteresis is a way to correct this issue. More in just a moment.
The purpose of this article is to improve our market mode filter. This is similar to our thermostat example. Instead of turning on the furnace to heat a room we are going to open a new position when a critical threshold SMA is crossed. In order to keep things simple, there is no shorting. The number of shares is scaled based upon a day ATR calculation. Going back to our thermostat example, how do we fix the problem of the furnace turning on and tuning off so many times?
How do we reduce the number of signals? This zone will turn on the heaters when the temperature reaches 69 degrees and turn off when the temperature reaches 71 degrees.
Our ideal temperature is in the middle of a band with the upper band at 71 and the lower band at The lower band is when we turn on the furnace and the upper band is when we turn off the furnace.
The zone in the middle is our hysteresis. There are many ways to create these bands. That is, for our upper band we will use the SMA of the daily highs and for the lower band we will use the SMA of the daily lows. This band floats around our ideal point which is the SMA. Both the upper and lower bands vary based upon the recent past. In short, our system has memory and adjusts to expanding or contracting volatility.
The EasyLanguage code for our new system look something like this:. Below is a screen shot showing the effect of opening a new trade after the daily bar closes above the upper band. We have reduced our five consecutive losing trades down to two trades. We also reduced the number of trades and the number of consecutive losing trades.
In the end we really end up with about the same amount of net profit but we accomplish this task with fewer, more profitable trades. A price proxy is nothing more than using the result of a price-based indicator instead of price directly.
This is often done to smooth price. There are many ways to smooth price. Such a topic is great for another article. For now, we can smooth our daily price by using a fast period exponential moving average EMA.
Below is an example of a trade entry. Notice the trade is opened when our price proxy yellow line crosses over the upper band. We have also reduced our losing trades to one. Looking at the strategy performance table above we are making slightly less money. So, which strategy is better? It all depends on what you want or what you are comfortable with. Some people will wish to simply take as much money as possible. Others will wish to reduce the number of consecutive losing trades.
If we want to use this in a trading system it would be ideal to create a function from this code that would pass back if we are in a bear or bull trend. However, the programming aspect of such a task is really beyond the scope of this article. Nonetheless, below is a quick example of setting two boolean variables in EasyLanguage that could be used as trend flags:. In this article we have created a dynamic trend filter that smooths price, adapts to market volatility and utilizes hysteresis principles.
Please log in again. The login page will open in a new window. After logging in you can close it and return to this page.
Download this free guide on how to stop curve fitting. Following these four simple steps can improve your trading dramatically! To build our better market trend filter we will use the following concepts: Hysteresis Price proxy Hysteresis Basics When building trading systems many of the decisions have a binary outcome.
Trading Bands Going back to our thermostat example, how do we fix the problem of the furnace turning on and tuning off so many times? The EasyLanguage code for our new system look something like this: Here are the results with using our new bands as trigger points. Price Proxy A price proxy is nothing more than using the result of a price-based indicator instead of price directly. Below is what the EasyLanguage code may look like. Nonetheless, below is a quick example of setting two boolean variables in EasyLanguage that could be used as trend flags: Session expired Please log in again.More...