This guide explains how the stochastic oscillator is calculated, a set of rules you can test, a worked example on Nifty, and how to filter, automate and backtest the strategy.
At a glance
| Stochastic oscillator strategy | |
|---|---|
| Type | Mean reversion within a trend |
| Indicator | Slow stochastic (14, 3, 3) |
| Markets | Nifty and Bank Nifty futures, liquid NSE stocks |
| Timeframes | 15-minute for intraday, daily for swing trades |
| Long entry | %K crosses above %D below 20, in an uptrend |
| Short entry | %K crosses below %D above 80, in a downtrend |
| Exit | Opposite zone, a target in points or a trailing stop |
| Stop | Below the recent swing low (long) or above the swing high (short) |
How the stochastic oscillator works
%D is a 3-period average of %K. The slow stochastic smooths %K once more with a 3-period average, which removes much of the noise. The settings are written as (14, 3, 3).
The stochastic oscillator was developed by George Lane in the 1950s. It measures where the price sits in its recent range, not how fast it is moving, which is what the RSI measures.
The rules
Long trades
- Trend filter: the price is above its 50-period exponential moving average.
- Setup: %K and %D are below 20.
- Entry: %K crosses above %D, and the candle closes above the previous candle's high.
- Stop: below the lowest low of the last 5 candles.
- Exit: %K crosses below %D above 80, or the price reaches 2 times the risk, whichever comes first.
Short trades
The mirror image: price below the 50-period average, a cross down above 80, a stop above the recent high, and an exit on a cross up below 20.
The trend filter matters. Without it, the strategy buys every dip in a falling market. In a strong trend the oscillator can stay above 80 or below 20 for a long time.
A worked example
Nifty futures on a 15-minute chart trade at 24,960, above their 50-period average. A pullback takes %K to 14 and %D to 18. The next candle closes at 24,945, above the previous high of 24,938, and %K crosses above %D.
- Entry: 24,945
- Stop: below the 5-candle low of 24,905, at 24,900, a risk of 45 points
- Target: 2 times the risk, 24,945 + 90 = 25,035
With one lot of 65, the risk is ₹2,925 and the target ₹5,850. These numbers are an illustration of the rules, not a result.
When the strategy works, and when it does not
Works best when:
- The market is trending with regular pullbacks.
- Volatility is moderate, so pullbacks reach the oversold zone and turn.
- You combine it with a level, such as support and resistance strategy or VWAP.
Struggles when:
- A strong trend reverses. The oscillator gives a buy signal into a new downtrend.
- The market chops sideways around the 50-period average and the trend filter flips often.
- News moves the price faster than a 14-period range can adapt.
Settings to test
| Setting | Faster | Default | Slower |
|---|---|---|---|
| Look-back | 5 | 14 | 21 |
| Smoothing | (5, 3, 3) | (14, 3, 3) | (21, 5, 5) |
| Zones | 25 / 75 | 20 / 80 | 10 / 90 |
Faster settings give more signals and more false ones. Wider zones give fewer, more stretched signals. Test a few settings and prefer ones that work across a range of values, not one exact setting.
Automating a stochastic strategy
In QuantPower's strategy builder, set the rules as indicator conditions:
- Trend condition: price above the 50-period EMA.
- Entry condition: stochastic %K crosses above %D with both below 20.
- Stop at the 5-candle low and a target at 2R, or a trailing stop loss.
- A time exit for intraday trades, such as 15:15.
Run it in paper trading for a few weeks before going live, and add an MTM stop loss for the day.
Backtesting a stochastic strategy
- Test on several years, including trending and sideways periods.
- Compare the results with and without the trend filter.
- Include brokerage, STT and slippage, because the strategy trades often.
- Look at the average trade, the maximum drawdown and the longest losing streak.
See how to backtest trading strategies and avoiding overfitting.
Common mistakes
- Trading every cross. Most crosses in the middle of the range are noise.
- Ignoring the trend. Oversold in a downtrend often gets more oversold.
- Optimising the settings to one period. A setting that fits one year perfectly rarely fits the next.
Frequently asked questions
What are the best stochastic settings for intraday trading?
(14, 3, 3) on a 15-minute chart is a common starting point. Test faster settings, such as (5, 3, 3), on your own instruments before using them.
What is the difference between the stochastic oscillator and RSI?
The stochastic compares the close with the recent high-low range. RSI compares the size of recent gains and losses. Both are bounded from 0 to 100 and both mark overbought and oversold zones.
Is the stochastic oscillator good for Bank Nifty?
It can be used on Bank Nifty futures with the same rules. Bank Nifty moves more per day than Nifty, so stops and targets in points need to be wider.
What does a stochastic divergence mean?
The price makes a new low but the stochastic makes a higher low, which suggests selling is weakening. Divergences are covered in our RSI divergence strategy.
Sources
- Lane, G. C. (1984). Lane's Stochastics. Technical Analysis of Stocks & Commodities, 2(3)
- Murphy, J. J. (1999). Technical Analysis of the Financial Markets. New York Institute of Finance
