There are many ways to determine whether the market is trending or sideways. Here are a couple ideas:
Take a fast moving average and a slower moving average and measure how far apart they are. If they are not at least X far apart the market is sideways. You might use MACD to do the same analysis.
Look at Momentum or Rate of Change indicators and set a minimum level that would define sideways
You can also use ATR for finding out whether the market is volatile or range bound.
Welles Wilder’s ADX (sometimes called DMI) is specifically designed to differentiate between trending vs. sideways markets. Like any indicator, there are limitless ways to interpret it. Personally, I largely ignore the level of ADX (contrary to Wilder’s methodology). What I use to determine trend is the direction and rate of change in the ADX line. Interpretation is largely subjective and very visual. Since it, like any indicator, is simply a manipulation of price, many would argue that you are better off visually detecting trend vs. range directly from price and not from an indicator, which will always lag behind price.
Take a look into ADX. It’s not a very intuitive indicator and therefore not very popular. It takes some getting used to. Those who are comfortable with it swear by it, and it often becomes their favorite indicator.
Using bollinger bands at one deviation, if they’re moving sideways, and with the price oscillating between the inner and outer bands at 1 deviation, thats a good clue its going sideways. Also the if the width of the channel formed by the deviation lines is narrowing thats another good clue prices have stopped. (if prices are trending and this is happening thats a whole new story..)
Also more loosely, if you can get a histogram of MACD, if the volume of the histogram is near 0, thats also a seems like a good indication its sideways.
Now here’s my DISCLAIMER:
By definition any indicator dedecting trending/sidweways markets will be slow and lagging and it can only tell you that the past x period was sideways, but it doesn’t tell you anything about the future. The only way to accurately detect a trend/sideways market is AFTER THE FACT.. Unfortunately you will never know early enough if a market is trending/sideways.
This is why trend following systems have such low winning percentage, because they assume all breakouts will be the start of a trend and they keep cutting losses until they hit a trend.