NEWCard payments are live · from $18/month, USDT also acceptedSee plans
COINPRED / STRATEGY LIBRARY

BTC trend pullback re-entry: After the EMA regime is set, buy a short-RSI dip only when price reclaims the prior high, then trail with ATR

An open-source trend strategy by JayadevRana (MPL 2.0). Both sides are on by default. A 55/233 EMA pair sets the regime, and the slow EMA must slope with it. A short RSI must first reach the pullback depth, then the close must break the prior bar's high or low in a short window. Size risks 0.5% of equity; the stop starts beyond the pullback extreme and trails the close by ATR. The author's chart is BINANCE:BTCUSDT, 1-hour. The rules follow the source; this page invents no backtest figures.

Illustrated guidesPine Script®Included with monthly & annual plans
← All strategies
JayadevRana · 1.0 · 2026-12-01 · Trend following
BTC trend pullback re-entry: After the EMA regime is set, buy a short-RSI dip only when price reclaims the prior high, then trail with ATR

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.

Author chart of JayadevRana's trend pullback re-entry strategy on BINANCE:BTCUSDT 1-hour
Author chart: BINANCE:BTCUSDT, 1-hour, from the script's publication page. The image shows the two EMAs, the trailing stop, and trade markers. It is only a visual example, not a performance record.

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)

InputDefaultWhat it does
Fast EMA / Slow EMA / Slope Lookback55 / 233 / 10Regime: placement of the two EMAs, and the slope of the slow EMA
Pullback RSI Length / Pullback Depth / Trigger Window5 / 25 / 3Short-RSI pullback depth, and how many bars the breakout trigger may arrive in
Allow Longs / Allow Shortstrue / trueWhether longs or shorts may be opened
Risk per Trade (% Equity) / Maximum Leverage0.5 / 1.0Sizes the position from the stop distance, and caps notional as a multiple of equity
Stop Buffer (ATR) / Trailing Stop (ATR)0.5 / 5.0Initial stop buffer beyond the pullback extreme, and the later trail distance from the close
Show Dashboard / Positiontrue / Top RightOptional 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

  1. Download the .pine file from Coinpred (a current membership is required; see the page) or check the original publication for a newer revision.
  2. Open the symbol and timeframe you want in TradingView, open the Pine Editor, paste the source, and add it to the chart.
  3. Start from the script defaults, then change inputs for your market and timeframe.
  4. The order size, margin, commission, and slippage in the source apply to the strategy tester only. Live order routing has to be set separately.
  5. 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.

Source, license and version

Licensed under MPL 2.0 per the source header, (c) Jayadev Rana. Redistribution must keep the copyright and license notices; modified files must remain under MPL 2.0. Coinpred ships the unmodified source.

View original source ↗

Check the script license and your TradingView account features. Historical results do not guarantee future performance.

More strategies

All strategies →