# Stochastics: Testing the Trading Oscillator

# REVISED - ERRORS CORRECTED

See this article on how I solved the problem.

The stochastics indicator is titled "an accurate buy and sell indicator" by Investopedia with no evidence supporting the claim besides its popularity.

Part of my mission with this project is to put a "citation needed" troll on everyone's shoulder through incessant repetition. I'm happy for things to be accurate, but we should expect evidence before we accept these kinds of claims.

A friend of mine uses the stochastics indicator, so I thought I'd test it with their favourite parameters. We agreed on the parameters and time period used below.

## Tested Allegation

The probability distribution of the 10 trading day return following an upward cross of the oversold line by the "D" stochastic line is different from that of a non-oversold condition. Specifically: it is "bullish".

The oversold condition is determined using the stochastic indicator's "D" line only.

### Parameters

K period = 14

D period = 3

Moving average type = simple

Oversold level positioned at 20

### Time Period

Ten trading days. The signal's freshly not-oversold condition, following being oversold days prior, is assumed to affect the return of the following 10 trading day period, signal day not inclusive.

**RETRACTION NOTE: this is where I went wrong. The trading periods overlapped which introduces auto-correlation.** This has been corrected.

## Data and Priors

Data used is the Dow Jones Industrial Average daily close from

**1928-09-30**to**2020-07-30**.

### Bayesian Estimation Priors

The following trading

**10 day**returns for both the overbought and non-overbought series follow the StudentT distribution.The mean values of these distributions follow a normal distribution, with the same mean as the mean and standard deviation for the overall return series

The standard deviation of the return series follow a uniform distribution between

**0.001%**and**100%**(naive prior)The StudentT distribution's degrees of freedom parameter is represented by an exponential distribution (plus 1) with a lambda parameter of

**1/29.0**.The StudentT distribution's lambda parameters are separately represented by the inverse squaring of the standard deviation for the trigger and non trigger return series respectively

## Method

Bayesian estimation using the pymc3 library. See this test of the RSI indicator for more details.

The posterior distribution of 10-day returns following the signal triggering is compared to the same where the signal was not triggered.

## Results

### Charts

The exploratory data analysis function plot shows the proportion of returns that are less than the return found on the bottom axis. This chart shows that trigger returns are almost always below non-trigger returns, especially on the positive side of the curve. The corrected chart shows that trigger returns largely sit between non-trigger conditions, except for buy-trigger returns which are skewed slightly higher.

This next charts show the difference in the means of the posterior distributions of trigger and non-trigger returns. Again, trigger and non-trigger are determined by the stochastics "D" line.

The sensitivity index tells us how seriously we should take the statistically significant differences found above. Surprisingly to me, this is a statistically significant result. The mean sensitivity index of 1.0 approximately translates to a confidence interval of 69%.

The corrected result is far less significant. The mean sensitivity index of -0.25 for buy-signal returns corresponds to something like a 20% confidence level. This means that the 0.6% mean difference we found above between buy-signal returns and non-signal returns should not be taken very seriously.

For sell-signal returns I found a sensitivity index value of 0.66 which corresponds to something like a 49% confidence level. That's something, but not very high. This means that we're about 49% confident in the average 1.4% return difference between sell-signal returns and non-signal returns we found above. Given that this is over 10 trading days and the confidence level is so low, that's not much.

### Stochastics Effect Through Time

The below chart shows the trigger-return value through time. As you can see, the sell return mean is very flat through time, and the buy return has a slight skew to it. There are some interesting outliers after the great depression, but overall this is what you'd expect to see when your signal has no trading value.

## Backtesting Stochastics

We didn't find a significant effect with stochastics, but why not try backtesting it anyway! The below graphs show the equity curve of an account that starts at $100,000. It buys or sells when the stochastics signal is oversold or overbought and closes that position after ten days to stay consistent with our above analysis. You could certainly trade it differently, but this approach would confirm or deny any result we found above.

Those curves are pretty negative! I hear your brilliant plan through the screen - lets treat it as a momentum indicator! Below are the equity profiles for that approach.

Looks quite positive, right? Well, it's also important to consider what kind of return we're showing here. The annualized internal rate of return of the momentum buy-signal equity curve is 1%. The buy and hold return over this period was an annualized 5.3%, ignoring significant dividend payouts. Also consider that for most of the backtested period (which covers 90 years) this approach lost money.

The internal rate of return for the momentum sell-signal backtesting was an annualized 0.75%. Honestly, I'm pretty surprised this result is positive at all given the bullish bias of the market. However, I don't like that for almost all of the history of this strategy it lost money before exploding near the end there.

The parabolic rise of these equity charts near the end make me worry that there is a flaw in my backtesting system, I'll update if I find one.

## Conclusions on Stochastics

The statistical results found very small, but technically statistically significant differences between signal-returns and non-signal returns. 10 day returns following buy signals are on average **0.6%** **less **than returns that do not occur around buy signals. 10 day returns following sell signals are on average **1.4% higher** than returns that do not occur around sell signals. The statistical significance of both results is low: approximately 20% and 49% confidence respectively.

Backtesting results seem to back up the results: contrary to popular use of the stochastics indicator, the "bullish" indicator of a security no longer being oversold is actually bearish. If you're going to use this indicator at all, you should be looking at it as a momentum indicator.

Overall the effect is very small and the confidence level is too low for it to be worth putting this indicator on your charts, in my personal opinion. **If I want 50% confidence, I'll ask a coin.**

**Stochastics is noise, not signal. (for this set of parameters and ****corrected ****data)**

The original report had a serious error in the data processing that introduced an auto-correlation effect. See this article on how I solved this problem.

## Create your profile

## Only paid subscribers can comment on this post

Sign in## Check your email

For your security, we need to re-authenticate you.

Click the link we sent to , or click here to sign in.