RSI mean reversion¶
Enter a long position when RSI is below 30. Exit when RSI rises above 70.
Complete strategy¶
//@version=1
symbol: RELIANCE
run: each bar
size: 100 shares per instrument
entry:
long when: rsi(14) < 30
exit:
long when: rsi(14) > 70
Read the rule¶
This is a state test, not a crossing event. Read RSI arguments, readings and warmup. Try changing the entry threshold and compare the resulting trades under the same backtest settings.
Try it in the editor¶
Copy the script into a TradeScript draft, resolve diagnostics and use the historical backtest flow. Start by inspecting an entry and exit or a portfolio rebalance. Change one value at a time.
Follow the thresholds¶
| Rule | Declaration in the sample |
|---|---|
| Entry | long when: rsi(14) < 30 |
| Exit | long when: rsi(14) > 70 |
| Size | size: 100 shares per instrument |
An RSI of 29 can match entry. A later RSI of 55 does not match this sample's exit; RSI must exceed 70. Exactly 30 or 70 satisfies neither respective strict comparison. The sample holds a fixed 100-unit target and has no price stop.
RSI uses a 14-bar period and reports a 0–100 value. These thresholds are indicator readings rather than portfolio percentages. The rule describes buying a low reading and exiting on a high reading; the language does not establish whether that idea is profitable.
Try an earlier recovery exit¶
Change only the exit threshold from 70 to 55 if you want to compare an earlier recovery condition. That produces a new strategy variant. Keep the interval, capital, costs and history identical, and inspect both exit timing and the resulting trades.
Learn the concept Understand conditions →