The idea
This is JayadevRana's open-source script, published as "Trend Pullback Re-Entry Strategy [Jayadev Rana]". It does not chase a freshly formed trend. It waits for a short RSI to reach a set depth, then, inside a short window, for the close to break the previous bar's high (or low). Both longs and shorts are enabled by default. The only exit is an ATR trailing stop; there is no separate take-profit.
The author's published chart is BINANCE:BTCUSDT on the 1-hour timeframe, so this page lists it as a BTC strategy. The script does not hard-code a symbol. Signals are evaluated only on confirmed, closed bars (barstate.isconfirmed), and only after enough bars have passed for the slow EMA lookback.

How the indicators are built
- The fast line is a 55-period EMA of close; the slow line is a 233-period EMA of close.
- An uptrend requires the fast EMA above the slow EMA and the slow EMA above its value slopeLen bars ago (default 10). A downtrend is the mirror image. If neither side qualifies, there is no regime and no entry.
- Pullback depth uses a pbLen-period RSI (default 5). In an uptrend, RSI must fall to pbLevel or lower (default 25). In a downtrend the threshold is 100 minus that level.
- The ATR length is hard-coded as 14. unit is the larger of ATR and (high - low), and is never smaller than the minimum tick. That unit is used for the initial stop buffer and the later trail.
Entries
- The bar index must already exceed slowLen + slopeLen, the book must be flat, and the bar must be confirmed closed.
- Long (order name Long): Allow Longs is on (the default), the regime is an uptrend, the most recent RSI dip to pbLevel or below is no more than pbWindow bars ago (default 3), and this bar's close is above the previous high.
- Short (order name Short): Allow Shorts is on, the regime is a downtrend, the most recent RSI rise to 100-pbLevel or above is no more than pbWindow bars ago, and this bar's close is below the previous low.
- The initial stop for a long is the lowest low over the last pbWindow+1 bars, minus stopBuf times unit (default 0.5). For a short it is the matching highest high plus the same buffer. If the size computed from that distance is not greater than 0, no order is sent.
Exits and sizing
- Position size is equity times Risk per Trade, divided by the stop distance. The default risk is 0.5% of equity. It is also capped by Maximum Leverage, default 1.0, so notional cannot exceed current equity. The strategy() declaration still says a fixed 1 unit, but live tester orders use this computed qty.
- After entry, a long stop only ratchets up toward close minus trailMult times unit (default 5 ATR) and never moves down; a short stop only ratchets down. There is no take-profit order.
- Commission is 0.05%, slippage is 2 ticks, initial capital is 10,000, and pyramiding is 0. Both margin_long and margin_short are 100, so the tester treats margin as 1-to-1.
Inputs (defaults in the source)
| Input | Default | What it does |
|---|---|---|
| Fast EMA / Slow EMA / Slope Lookback | 55 / 233 / 10 | Regime: placement of the two EMAs, and the slope of the slow EMA |
| Pullback RSI Length / Pullback Depth / Trigger Window | 5 / 25 / 3 | Short-RSI pullback depth, and how many bars the breakout trigger may arrive in |
| Allow Longs / Allow Shorts | true / true | Whether longs or shorts may be opened |
| Risk per Trade (% Equity) / Maximum Leverage | 0.5 / 1.0 | Sizes the position from the stop distance, and caps notional as a multiple of equity |
| Stop Buffer (ATR) / Trailing Stop (ATR) | 0.5 / 5.0 | Initial stop buffer beyond the pullback extreme, and the later trail distance from the close |
| Show Dashboard / Position | true / Top Right | Optional status table, top right by default |
Caveats
- The ATR length is hard-coded as 14 and cannot be changed from the inputs.
- Signals fire only after the bar has closed. A dip or break you see mid-bar may not still be valid at the close.
- Maximum Leverage defaults to 1.0, so notional stays at or below equity. Raising it increases tester size and live risk together.
- Commission is 0.05%, slippage is 2 ticks, and initial capital is 10,000. Live fee schedules, contract multipliers, and quote currencies often differ, so tester results are not exchange fills.
- The author showed 1-hour BTC. A 55/233 EMA pair will lag much more on a shorter timeframe; revisit the inputs if you change the chart.
Install it on TradingView
- Download the .pine file from Coinpred (a current membership is required; see the page) or check the original publication for a newer revision.
- Open the symbol and timeframe you want in TradingView, open the Pine Editor, paste the source, and add it to the chart.
- Start from the script defaults, then change inputs for your market and timeframe.
- The order size, margin, commission, and slippage in the source apply to the strategy tester only. Live order routing has to be set separately.
- Crypto trades around the clock. The tester's timezone and session settings may differ from your venue by several hours.
About backtest figures
Source, license, and version
- Source: https://www.tradingview.com/script/G6KZH6HX-Trend-Pullback-Re-Entry-Strategy-Jayadev-Rana/
- Author: JayadevRana (the header is written as (c) Jayadev Rana)
- License: Mozilla Public License 2.0 (the header names the license but does not include a mozilla.org URL). Redistribution must keep the original copyright and license notices; if you modify the source file, the modified file must remain under MPL 2.0. Coinpred ships the unmodified source.
- Version: 1.0 in the publication record and pine-facade. Pine v6, scriptAccess open_no_auth.



