Buying every oversold RSI reading can mean repeatedly entering a falling market. Can a recovery trigger combined with a longer trend filter separate a temporary pullback from persistent weakness? This TradingView strategy turns that hypothesis into a reproducible experiment.

What you will learn

  • Distinguish a recovery crossing from a low RSI reading.
  • Define entries, brackets and defensive exits.
  • Understand Pine order timing and tick units.
  • Test sensitivity to costs and market regimes.

Trading hypothesis

Use RSI(14) crossing above 40 while the closing price is above EMA(100). This is a long-only hypothesis, not evidence of profitability. A crossing requires the preceding RSI to be at or below 40 and the current value above 40. Wait for a completed bar. Only enter when flat.

RSI Recovery with a Long-Term Trend Filter

Illustrative price and RSI paths, not market data. Green marks recovery and the rising trend filter; the red horizontal line marks RSI 40.

Orders and risk

Attach a 40-tick stop and 80-tick target relative to the entry fill. Exit additionally if RSI crosses below 50 or price closes below the EMA. The RSI exit requires a crossing, not simply a reading below 50. With a hypothetical tick size of 0.25 and entry at 100, the stop is 90 and target 120. If each tick is worth $1.25, one unit risks $50 before fees and slippage. Configure quantity in strategy properties; do not assume the default quantity suits your account. A stop does not cap losses during gaps.

Pine Script implementation

//@version=6
strategy("RSI recovery", overlay=true, pyramiding=0)
r = ta.rsi(close, 14)
trend = ta.ema(close, 100)
recover = ta.crossover(r, 40)
exitSignal = ta.crossunder(r, 50)
if barstate.isconfirmed and strategy.position_size == 0 and close > trend and recover
    strategy.entry("L", strategy.long)
    strategy.exit("Bracket", "L", loss=40, profit=80)
if barstate.isconfirmed and strategy.position_size > 0 and (exitSignal or close < trend)
    strategy.close("L")

By default, market orders created at bar close can fill at the next available tick, typically the following bar open in historical tests. The bracket uses relative tick distances, not absolute prices. The broker emulator may infer intrabar price paths; if both exits are touched on one bar, sequencing matters. Bar Magnifier can improve historical granularity where available, but does not reproduce live liquidity. Strategy alerts and external execution require separate integration and reconciliation.

Testing plan

Compare against the same entry without the EMA filter. Keep quantity and costs constant. Test RSI thresholds 35, 40 and 45 and EMA lengths 80, 100 and 120 on a training period, then freeze parameters for a later untouched period. Include commissions and realistic slippage in properties. Inspect trade count, drawdown, average net trade and gap losses; reject fragile results that depend on one instrument or a narrow parameter choice. Use standard candles rather than synthetic prices. This example has not been compiled or backtested.

Reference: Pine strategy documentation.

For custom sizing, session controls or execution integration, see Custom TradingView strategy Development Services.

Educational only. Trading involves risk of loss; simulated performance does not guarantee future results.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.