Strategy vault / Trend following
Price Drop Buy Strategy in Downtrend with Stop Loss
This strategy uses the RSI indicator to determine the potential market trend direction, combined with the Bollinger Bands indicator to identify key support and resistance areas, and looks for low absorption…

Overview
This strategy uses the RSI indicator to determine the potential market trend direction, combined with the Bollinger Bands indicator to identify key support and resistance areas, and looks for low absorption opportunities in trend shock markets to establish long positions and take profits at overbought areas.
Strategy Logic
Use the RSI indicator to determine the potential market trend direction. RSI below 40 is considered an oversold area where the market could turn bullish. RSI above 50 is considered an overbought area where the market could turn bearish.
Use the Bollinger Bands indicator to identify key support and resistance areas. The middle band of Bollinger Bands is the moving average line of price, and the upper and lower bands form the standard deviation channel of price. Prices approaching the lower band present low absorption opportunities.
When RSI <40 and price approaches the Bollinger lower band, it is determined as a low absorption long opportunity to establish a long position.
When RSI >50 or profits exceed 50%, close long positions to take profits and cut losses.
Advantage Analysis
Use RSI to determine potential market trend direction to avoid trading against the trend.
Identify precise entry timing combining with Bollinger Bands to locate low absorption points.
Adopt trend shock methodology to prevent being trapped.
Flexible stop profit and stop loss mechanism to maximize profits.
Risk Analysis
Improper Bollinger parameters may fail to correctly locate the support area.
Trend breakthroughs or false breakthroughs could lead to errors in overbought and oversold judgements.
Improper stop profit and stop loss points setting may lead to premature exit or enlarged losses.
Optimization Directions
Optimize Bollinger parameters for more accurate identification of support and resistance areas.
Incorporate other indicators like MACD and KDJ to filter false signals.
Dynamically optimize stop profit and stop loss algorithms to maximize profits while minimizing losses.
Summary
This strategy determines potential trend direction with RSI, combined with Bollinger Bands to identify support areas, realizing low buy high sell, which is a typical trend shock strategy. With proper optimization, it can become a reliable and stable profitable quantitative strategy.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | true | From Month |
| v_input_2 | true | From Day |
| v_input_3 | 2018 | From Year |
| v_input_4 | true | To Month |
| v_input_5 | true | To Day |
| v_input_6 | 9999 | To Year |
| v_input_7 | 60 | RSI Period Length |
| v_input_8 | 20 | Bollinger Period Length |
Source Pine Script
/*backtest
start: 2023-12-28 00:00:00
end: 2024-01-04 00:00:00
period: 30m
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
strategy("price drop buy in", overlay=true, initial_capital=1000, max_bars_back=24)
// === INPUT BACKTEST RANGE ===
FromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
FromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
FromYear = input(defval = 2018, title = "From Year", minval = 2017)
ToMonth = input(defval = 1, title = "To Month", minval = 1, maxval = 12)
ToDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31)
ToYear = input(defval = 9999, title = "To Year", minval = 2017)
// === FUNCTION EXAMPLE ===
start = timestamp(FromYear, FromMonth, FromDay, 00, 00) // backtest start window
finish = timestamp(ToYear, ToMonth, ToDay, 23, 59) // backtest finish window
window() => true // create function "within window of time"
///////////// RSI
RSIlength = input(60,title="RSI Period Length")
RSIoverSold = 40
RSIoverBought = 50
price = close
vrsi = rsi(close, RSIlength)
smaLong = sma(close,80)
smaShort = sma(close,40)
///////////// Bollinger Bands
BBlength = input(20, minval=1,title="Bollinger Period Length")
BBmult = 2 // input(2.0, minval=0.001, maxval=50,title="Bollinger Bands Standard Deviation")
BBbasis = sma(price, BBlength)
BBdev = BBmult * stdev(price, BBlength)
BBupper = BBbasis + BBdev
BBlower = BBbasis - BBdev
longcondition = (price < BBlower and vrsi < RSIoverSold)
// vrsi < RSIoverSold
shortcondition = (RSIoverBought and strategy.openprofit > 50 ) or price > BBupper
if(longcondition)
strategy.entry('buy', strategy.long, when = window())
if(shortcondition)
strategy.entry('sell', strategy.short, when = window())
Published by ChaoZhang on the FMZ strategy square · last modified 2024-01-05. 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/Price-Drop-Buy-Strategy-in-Downtrend-with-Stop-Loss.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
- Going with the Trend Moving Average Crossover StrategyPine Script · Trend following · 1d
- Concise Dynamic Trend StrategyPine Script · Trend following · 2h
- Bollinger Bands RSI Multi MA Trend StrategyPine Script · Trend following · 1d
- High Frequency Cryptocurrency Trading Strategy Combining TrippleMACD Crossover and Relative Strength IndexPine Script · Trend following · 1h
- Bollinger Bands and RSI Trend Following StrategyPine Script · Trend following · 1h
- EMA and RSI Trend Trading StrategyPine Script · Trend following · 1d