The idea
This long/short system looks for short-term reversals. It compares a short window of price extremes with the same window on RSI: a lower price low plus a higher RSI low counts as bullish divergence, and a higher price high plus a lower RSI high counts as bearish divergence. On a confirmed bar it enters, then places a fixed-percent stop and target from average entry price.
The publication write-up presents volume, volatility and trend filters as part of the setup, but in the source those four filters—volume, ADX, Bollinger close confirmation and the fast/slow RSI cross—are optional and off by default. With the defaults unchanged, entries depend only on that simplified divergence. This guide follows the source. The script is Pine Script v6 strategy() code with process_orders_on_close enabled.

Indicators
- Main RSI: ta.rsi(close, rsiLength), default length 8; the script uses the previous bar’s value in the rules.
- Divergence window: 5 bars by default. For longs it compares the lowest low of the last 5 bars with the lowest low of that window shifted one bar earlier, and does the same for RSI troughs; a lower price low with a higher RSI low is bullish divergence. Shorts use highs and RSI peaks the same way.
- This is not classic pivot divergence (no confirmed swing high/low first). It is a sliding-window high/low comparison.
- Optional filters (all off by default): previous volume at least twice its 20-bar SMA; ADX(14,14) above the threshold (default 20) with DI alignment; previous close below the lower band for longs or above the upper band for shorts (Bollinger length 20, 2 standard deviations); fast RSI(14) crossing slow RSI(21).
- DMI, Bollinger Bands and the volume SMA also use the previous bar, so decisions are not taken on an unfinished candle.
Entry rules
- Both long and short; strategy.entry runs when barstate.isconfirmed is true.
- Long: bullDiv is true and every enabled filter passes.
- Short: bearDiv is true and every enabled filter passes.
- Default size is 30% of equity, with initial_capital set to 1000. calc_on_every_tick = false and process_orders_on_close = true, so orders are processed on the close.
- Alert conditions exist for long and short entries. They are plain-text notices; the script does not fill exchange or bot credentials.
Exits and position sizing
- Longs stop at average entry × (1 − stop-loss %) and target average entry × (1 + take-profit %). Shorts use the inverse.
- Defaults are a 1% stop and a 2% target, placed together with strategy.exit as stop and limit.
- There is no trailing stop and no time-based exit; the trade stays open until stop or target.
- Dashed green and red lines mark the target and stop after entry and are deleted on exit. They are visual only and do not add a second exit rule.
Inputs (source defaults)
| Input | Default | Purpose |
|---|---|---|
| RSI Length | 8 | Main RSI period used for divergence |
| Fast / Slow RSI Length | 14 / 21 | Optional crossover filter RSIs |
| BB Length | 20 | Bollinger period (std-dev multiplier is fixed at 2) |
| ADX Threshold | 20 | Minimum ADX for the optional trend filter |
| Divergence Lookback | 5 | Window for price and RSI extremes |
| Volume ≥ 2× SMA | false | Optional volume filter, off by default |
| ADX Strength & Alignment | false | Optional ADX and DI filter, off by default |
| BB Close Confirmation | false | Optional Bollinger close filter, off by default |
| RSI Crossover Confirmation | false | Optional RSI cross filter, off by default |
| Stop-Loss % / Take-Profit % | 1.0 / 2.0 | Fixed percentages from average entry |
| default_qty_value | 30 | 30% of equity per entry |
Things to know before using it
- The publication text reads as if several filters are always in play; in the source they default to off. Turn them on in settings if you want the multi-condition behaviour described on the page.
- The divergence test is a sliding-window comparison, so the rhythm will differ from hand-marked pivot divergence, especially in a run of new highs or lows.
- Most series use the previous bar, and orders process on the close, so signals lag the live RSI you see mid-bar.
- A 30% equity default with a 1% stop can still stack losses on a 15-minute chart. Reduce size to match the drawdown you can tolerate.
- The author chart is BTCUSDT on 15 minutes. Backtest other intervals or markets on their own, and consider retuning RSI length and the divergence window.
Installing it on TradingView
- Download the .pine file from Coinpred (active membership required, see below), or check the original page for the latest version.
- Open the Pine Editor on TradingView, create a blank script, paste the full source and save.
- Click Add to chart; start with BTCUSDT 15-minute so you can compare with the author image.
- If you want volume, ADX, Bollinger or RSI-cross confirmation, enable those inputs, then tune the stop and target percentages.
- Study signals and fills in the Strategy Tester before setting alerts. Past results do not guarantee future returns.
About backtest figures
Source, license and version
- Author: BullByte. Original title: Reversal Trading Bot Strategy [BullByte] Final Version. Version 8.0 (pine-facade).
- License: Mozilla Public License 2.0 (MPL 2.0). Coinpred provides the full, unmodified source.
- Original page: https://www.tradingview.com/script/cXVnf1WH-Reversal-Trading-Bot-Strategy-BullByte/
- Pine version: v6; script type: strategy().
- Images come from the author’s publication page, are not covered by the MPL, and are captioned “Author chart”.
- Downloads are subject to Coinpred membership terms. If you modify the source file, the modified file must remain under MPL 2.0.