0bps

Strategy vault / Mean reversion

Relative Strength Index strategy

This script is written in Pine Script for TradingView platform and implements a simple RSI (Relative Strength Index) strategy for trading the Litecoin (LTC) to USDT pair on Binance exchange using a 5-minute chart…

Author
ChaoZhang
Complexity
Starter · 34 lines
Parameters
3
Backtest bar
1d · swing
Tested on
BTC/USDT · futures

This script is written in Pine Script for TradingView platform and implements a simple RSI (Relative Strength Index) strategy for trading the Litecoin (LTC) to USDT pair on Binance exchange using a 5-minute chart.

Here's a brief explanation of this strategy:

Parameters:

  • RSI Length: 3, which means it calculates the RSI based on the last 3 periods.
  • RSI OverSold level: 47, which means it considers the market oversold (a potential buying opportunity) when the RSI falls below 47.
  • RSI OverBought Level: 56, which means it considers the market overbought (a potential selling opportunity) when the RSI rises above 56.

Operations:

  • If the RSI crosses over the oversold level, the strategy enters a long position (buys).
  • If the RSI crosses under the overbought level, the strategy enters a short position (sells).

This particular backtest has resulted in a profit of 391%, executed over 2400 trades, with a 42% profitability rate, a 14.6% drawdown, and a Sharpe ratio of 0.65.

However, it's important to remember that past performance doesn't guarantee future results. Also, the author suggests that additional filters can be added to this strategy to improve its performance.

Parameters

NameDefaultWhat it controls
v_input_13length
v_input_247overSold
v_input_356overBought

Source Pine Script

/*backtest
start: 2022-09-01 00:00:00
end: 2023-08-14 05:20:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
strategy("QuantNomad - RSI Strategy - LTCUSDT - 5m", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)

length     = input(3)
overSold   = input(47)
overBought = input(56)

price = close

// 
// author: QuantNomad
// date: 2019-06-06
// RSI Strategy - LTCUSDT - 5m
// https://www.tradingview.com/u/QuantNomad/
// https://t.me/quantnomad
//

vrsi = rsi(price, length)

if (not na(vrsi))
    if (crossover(vrsi, overSold))
        strategy.entry("RsiLE", strategy.long, comment="RsiLE")
    if (crossunder(vrsi, overBought))
        strategy.entry("RsiSE", strategy.short, comment="RsiSE")

//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)

Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-08. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.

Build this with AgenKit

A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Relative-Strength-Index-strategy.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. Get tests, backtest, risk controls and a paper-trading switch

Understand it first

Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.

Related specs

esc

Try , , or .

↑↓ move↵ open