Stochastic RSI Trading Strategy 427683
This strategy is based on the Stochastic RSI indicator, which combines the Stochastic oscillator and the Relative Strength Index (RSI). It generates trading signals when the Stochastic RSI lines cross overbought or…
Overview
This strategy is based on the Stochastic RSI indicator, which combines the Stochastic oscillator and the Relative Strength Index (RSI). It generates trading signals when the Stochastic RSI lines cross overbought or oversold levels.
Strategy Logic
Calculate the 14-period RSI of close price, rsi1.
Calculate the Stochastic K and D values based on rsi1.
Go long when K goes above 80, and go short when K falls below 20.
Close positions when K crosses the 80 and 20 levels.
Option to trade in the reverse direction.
Backtest on different products and timeframes to evaluate performance.
Advantage Analysis
The main advantages of this strategy are:
Stochastic RSI combines the strengths of RSI and Stochastic oscillators.
Overbought/oversold areas help filter false breakouts.
Flexibility to trade reversals when configured.
Simple and intuitive trading rules.
Clear visual signals easy for manual trading.
Risk Analysis
The main risks of this strategy are:
No stop loss exposes to large losses.
Oscillators prone to false signals without trend filter.
No position sizing control risks over-trading.
Lack of parameter optimization leads to overfitting.
Ignores trading costs.
Insufficient backtest data causes curve fitting.
Optimization Directions
The strategy can be improved by:
Adding stop loss and optimizing stop levels.
Optimizing parameters to reduce false signals.
Controlling position sizes and leverage.
Adding filters to avoid counter-trend trades.
Accounting for trading costs.
Validating over longer timeframes and instruments.
Summary
The Stochastic RSI strategy combines the strengths of RSI and Stochastic oscillators, generating signals when the lines cross key levels. Despite being simple to use, the strategy risks false signals. Further enhancements around stops, parameters, trend filters can help create a more robust short-term trading system.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 80 | TopBand |
| v_input_2 | 20 | LowBand |
| v_input_3 | false | Trade reverse |
| v_input_4 | 14 | lengthRSI |
| v_input_5 | 14 | lengthStoch |
| v_input_6 | 3 | smoothK |
| v_input_7 | 3 | smoothD |
Source Pine Script
/*backtest
start: 2023-08-23 00:00:00
end: 2023-09-22 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
////////////////////////////////////////////////////////////
// Copyright by HPotter v1.0 24/11/2014
// This strategy used to calculate the Stochastic RSI
//
// You can change long to short in the Input Settings
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
strategy(title="Stochastic RSI", shorttitle="Stoch RSI Backtest")
TopBand = input(80, step=0.01)
LowBand = input(20, step=0.01)
reverse = input(false, title="Trade reverse")
hline(TopBand, color=red, linestyle=line)
hline(LowBand, color=green, linestyle=line)
Source = close
lengthRSI = input(14, minval=1), lengthStoch = input(14, minval=1)
smoothK = input(3, minval=1), smoothD = input(3, minval=1)
rsi1 = rsi(Source, lengthRSI)
k = sma(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = sma(k, smoothD)
d_cross_80 = cross(d,TopBand)
dc80 = d_cross_80 ? red : green
pos = iff(k > TopBand, 1,
iff(k < LowBand, -1, nz(pos[1], 0)))
possig = iff(reverse and pos == 1, -1,
iff(reverse and pos == -1, 1, pos))
if (possig == 1)
strategy.entry("Long", strategy.long)
if (possig == -1)
strategy.entry("Short", strategy.short)
barcolor(possig == -1 ? red: possig == 1 ? green : blue )
plot(k, color= orange)
plot(d, color=dc80)Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-23. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Stochastic-RSI-Trading-Strategy-427683.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- Bull Market Tracking SystemPine Script · Breakout · 1h
- Dynamic Stop Loss Strategy Adaptive to ATR FluctuationsPine Script · Breakout · 1h
- Stochastic RSI and Volume Based Trading StrategyPine Script · Breakout · 2h
- Bollinger Bands Stochastic RSI Extreme Signal StrategyPine Script · Breakout · 1d
- CMO and WMA Based Dual Moving Average Trading StrategyPine Script · Breakout · 1h
- Dual Moving Average and MACD Combination Short term Trading StrategyPine Script · Breakout · 1h