0bps

Strategy vault / Mean reversion

Parabolic SAR RSI Reversal Strategy

The Parabolic SAR RSI reversal strategy generates trading signals based on the "Parabolic Stop and Reverse" and "Relative Strength Index" indicators to identify potential price reversals. It takes opposite positions…

Author
ChaoZhang
Complexity
Intermediate · 44 lines
Parameters
7
Backtest bar
2h · intraday
Tested on
BTC/USDT · futures

Overview

The Parabolic SAR RSI reversal strategy generates trading signals based on the "Parabolic Stop and Reverse" and "Relative Strength Index" indicators to identify potential price reversals. It takes opposite positions when the price breaks the upside or downside trendlines. This allows catching opportunities from price reversals.

Strategy Logic

The strategy mainly utilizes two technical indicators:

  1. Parabolic SAR: Plots a parabolic SAR line as a dynamic stop-loss line. When the price breaks this line, the position and direction of the stop-loss line are reset, generating buy or sell signals.

  2. RSI: Reflects the speed and change of price rises and falls over a period of time. Above 70 is the overbought zone and below 30 is the oversold zone.

Specifically, the strategy first sets the initial value, step, and maximum value of the Parabolic SAR based on user input. It then determines entry and exit timing according to whether the price breaks the SAR line:

  • When the price breaks above the SAR line, a sell signal is generated.
  • When the price breaks below the SAR line, a buy signal is generated.

Meanwhile, the strategy also monitors the RSI to determine if it is in the overbought/oversold zone. Long positions are closed when RSI enters the overbought zone. Short positions are closed when RSI enters the oversold zone.

By combining the SAR reversal signals and RSI filter signals, the strategy can make opposite moves in a timely manner when prices reverse to achieve buy low sell high.

Advantage Analysis

The main advantages of this reversal tracking strategy are:

  1. Capture Price Reversal - Uses breakouts to generate reversal signals and make opposite moves when prices reverse.

  2. Dynamic Stop Loss - SAR acts as a moving stop loss that adjusts stop levels based on real-time prices to protect profits.

  3. Adaptability - Adjustable parameters make the strategy adaptable to different market environments.

  4. RSI Filter - Filters out false breakouts and avoids wrong moves.

  5. Easy to Implement - Uses simple indicators with little code, easy to implement and backtest.

Risk Analysis

The risks include:

  1. Whipsaw Risk - False breakouts cause wrong stop and reverse signals, leading to repeated losses.

  2. Over Optimization - Optimizing parameters may lead to overfitting and lack of robustness.

  3. No Fundamental Basis - Driven purely by technical indicators, ignores fundamentals.

  4. Ignore Transaction Costs - Frequent trading increases transaction costs.

  5. Subject to Price Gaps - Gaps may trigger incorrect stop and reverse signals.

Enhancement Opportunities

The strategy can be enhanced from the following aspects:

  1. Combine with other indicators - Confirm signals with other indicators to avoid false signals. Such as adding volume indicators.

  2. Parameter tuning - Test and optimize parameters to find the optimal parameter combinations.

  3. Position sizing - Adjust position size based on market conditions to control risk.

  4. Trade at significant levels - Only trade around key support/resistance levels to reduce frequency.

  5. Consider fundamentals - Add fundamental factors to avoid trading against major trends.

Conclusion

The reversal tracking strategy generates signals using SAR and RSI to capture reversals. It dynamically adjusts stops to capture short-term profits from breakouts. But it is also exposed to risks of following noise. Optimizing parameters, improving decision quality will enhance strategy stability and profitability.

Parameters

NameDefaultWhat it controls
v_input_1_close0Source: close | high | low | open | hl2 | hlc3 | hlcc4 | ohlc4
v_input_214Length
v_input_382RSI Overbought Level
v_input_421RSI Oversold Level
v_input_50.007SAR Start
v_input_60.017SAR Increment
v_input_70.24SAR Maximum

Source Pine Script

/*backtest
start: 2023-09-07 00:00:00
end: 2023-10-07 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
// strategy("SARSI",overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, pyramiding = 0, commission_type = strategy.commission.percent, commission_value = 0.0675, initial_capital = 10000, currency = currency.USD, calc_on_order_fills = true, calc_on_every_tick = true) 

//study("SARSI",overlay = true)

src     = input(close, title="Source")
len     = input(14, minval=1, title="Length")
rob     = input(title="RSI Overbought Level", defval=82, minval=1, maxval=100)
ros     = input(title="RSI Oversold Level", defval=21, minval=1, maxval=100)
start   = input(title="SAR Start", defval=0.007, minval=0.001, maxval=10)
inc     = input(title="SAR Increment", defval=0.017, minval=0.001, maxval=100)
max     = input(title="SAR Maximum", defval=0.24, minval=0.01, maxval=10)
asar    = sar(start,inc,max)
xrsi    = rsi(close,len)
date    = timestamp(2018, 8, 1, 00, 00)
up      = crossunder(asar,src)
dn      = crossover(asar,src)

//ob      = crossunder(xrsi,rob)
//os      = crossover(xrsi,ros)

strategy.entry("long", strategy.long, when=up and time>=date, comment="Long")
strategy.entry("short", strategy.short, when=dn and time>=date, comment="Short")

//strategy.close("long", when=ob)
//strategy.close("short", when=os)

alertcondition(up,  "Long",  "Long Msg")
alertcondition(dn, "Short", "Short Msg")

//uptrend=plotshape(up,"uptrend",shape.triangleup,color=#48A498,transp=0, size = size.tiny, location = location.belowbar,text="฿")
//downtrend=plotshape(dn,"downtrend",shape.triangledown,color=#E25655,transp=0, size = size.tiny, location = location.abovebar,text="$")
//plotshape(ob,"overbuy",shape.triangleup,color=#48A498,transp=0, size = size.small, location = location.belowbar,text="0฿")
//plotshape(os,"oversell",shape.triangledown,color=#E25655,transp=0, size = size.small, location = location.abovebar,text="0$")

plot(asar, style=cross, color=gray, transp=0, linewidth=1, title="SAR")

Published by ChaoZhang on the FMZ strategy square · last modified 2023-10-08. 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.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Parabolic-SAR-RSI-Reversal-Strategy.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. 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

esc

Try , , or .

↑↓ move↵ open