Trend Pullback - RSI(2) Template — Strategy by aleksandr0x

By aleksandr0x

Performance Metrics

Description

This strategy buys short, sharp dips inside a long-term uptrend and gets out as soon as price recovers. It is a clean, fully commented version of a well-known short-term pullback idea, written so that every rule and every fill assumption is visible in the inputs and in the code.How it worksThe script first checks the long-term trend: a bar only qualifies when it closes above its 200-period simple moving average. Inside that uptrend it looks for a very short-term oversold reading, defined as a 2-period RSI below 10. When both conditions are true on a closed bar and no trade is open, it enters long at the next bar's open. The position is closed by whichever of three exits comes first: a close back above the 5-period simple moving average, which means the dip has bounced; a time limit of 10 bars; or a protective stop placed 3 times the 14-period ATR below the signal bar's close. An optional fixed take profit in percent is available but off by default. The strategy trades long only and holds one position at a time.What makes this version differentThe classic form of this rule usually has no stop and no time limit, so one deep dip can turn into a long, painful trade. This template adds both as safety rails, measures the stop from the signal bar's close rather than from the fill, and states the fill timing explicitly, so the results can be reproduced in another backtester. The trend, RSI and exit settings are the common textbook values and were not tuned on this chart.How to use itUse it on daily candles. Start with the defaults, read the Strategy Tester results on several symbols, and only then change one input at a time. The orange line is the trend SMA, the green line is the exit SMA, small green triangles mark bars where the entry condition is met while flat, and the table in the corner counts closed trades.Settings used on the published chart10% of equity per trade, initial capital 10,000. Commission 0.06% per side, slippage 2 ticks. Orders fill at the next bar's open.LimitationsRules like this win often, but a single loss can be larger than several wins, which is why the stop and the time exit exist. On 4-hour and lower timeframes the same rules trade far more often and costs take a much larger share of each trade; in our tests the lower timeframes were not profitable after costs, so treat them as an experiment. The strategy uses a fixed share of equity and stays in cash most of the time, so in a strong bull market it will make much less than simply holding. Past results do not predict future results.

Browse all 5,900+ TradingView Pine Script strategies

View on TradingView