2
$\begingroup$

I'm a novice in time series analysis and I'm trying to detect trend reversals automatically. In the example below, a heuristic rule would say that a trend reversal has occurred if the value has been trending in a direction for t1 seconds, then in the other direction for t2 = t1/k seconds.

Trend reversal example

I've tried to parse the answer on detecting trends but it went beyond my head. While I know I need to read up way more on time series analysis, I wonder if there are simpler (and more coarse) methods for detecting trends and trend reversals. Something like detecting slopes and calculating the angle between them?

$\endgroup$
  • $\begingroup$ Can you define what counts as a "trend reversal" with a bit more specificity? A single example graph is not a definition. You might look into the literature on changepoint detection, though since it's not clear exactly what you mean by "trend reversal" it's not clear to me whether this will be exactly what you are looking for. $\endgroup$ – D.W. Jan 26 '18 at 1:27
3
$\begingroup$

With realistically noisy signals, this is not a simple problem. For example, you write

a heuristic rule would say that a trend reversal has occurred if the value has been trending in a direction for $t1$ seconds, then in the other direction for $t2 = t1/k$ seconds.

What if the signal would rise for $t1$ seconds by a total of $5\%$, then fall for $t1 / k$ seconds by a total of $6\%$, except for some time point in the second part where it rises by a negligible $0.0000001\%$?

A refinement on your idea would be to spot some difference between some types of moving averages between two time intervals. The moving averages would (hopefully) smooth out these problems, and the difference would be more indicative of a trend change.

In econometric technical analysis, one implementation of this is through the MACD (moving average convergence divergence).

The idea is

  1. take a "slow" exponential moving average (in the original context, 26 days)

  2. take a "fast" exponential moving average (in the original context, 12 days)

  3. subtract the former from the latter

  4. take an exponential moving average of 3. (in the original context, 9 days)

When the difference between 3. and 4. crosses 0, it's an indication that the trend reverse.

You can see an example in the following diagram (taken from the Wikipedia entry).

enter image description here

In the top diagram, the red/green lines indicate the market price. The purple and black lines indicate the fast and slow moving averages.

In the bottom diagram, the blue line is 3., and the red line is 4. The difference between them is the grey bar chart.

You can see that a zero crossing of the grey bar chart, roughly corresponds to a trend change in the original green/red prices.

$\endgroup$
0
$\begingroup$

This is not an easy fix and not "simple". Please see this paper from Tsay and Balke on the papers titled "Outliers, level shifts, and variance changes in time series" & "Detecting Level Shifts in Time Series".

We implemented this in Autobox 25 years ago(I am affiliated with them).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.