Strategy · Pine Script v6 · On the chart

Customizable Dual-Timeframe RSI Strategy

by Ahmed-GoCode· code credited to Ahmed - Quant-Edge Indicators

This strategy evaluates two Relative Strength Index (RSI) indicators across two user-defined timeframes to generate trading signals.

View on GitHub

GitHub stars53on the repository
Pine versionv6current
Lines of code50
Settings8inputs
LicenceMPL-2.0
Last update2 months ago17 Aug 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

50 lines of Pine Script v6 from Quant-Edge-Indicators/RSI & Momentum/Double RSI Strategy.pinescript, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.

Double RSI Strategy.pinescript
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Ahmed - Quant-Edge Indicators
//@version=6
strategy("Customizable Dual-Timeframe RSI Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)

// === User Inputs ===
// RSI 1 (Higher Timeframe)
rsi1_tf = input.timeframe("15", "Higher RSI Timeframe")
rsi1_len = input.int(14, "Higher RSI Period", minval=1)

// RSI 2 (Lower Timeframe)
rsi2_tf = input.timeframe("1", "Lower RSI Timeframe")
rsi2_len = input.int(7, "Lower RSI Period", minval=1)

// Customizable Levels
buy_entry_level = input.int(30, "Buy Entry Level", minval=1, maxval=100)
sell_entry_level = input.int(70, "Sell Entry Level", minval=1, maxval=100)
buy_exit_level = input.int(70, "Buy Exit Level", minval=1, maxval=100)
sell_exit_level = input.int(30, "Sell Exit Level", minval=1, maxval=100)

// === RSI Source ===
rsi_source = close

// === Calculate RSI across both timeframes ===
rsi_higher = request.security(syminfo.tickerid, rsi1_tf, ta.rsi(rsi_source, rsi1_len))
rsi_lower = request.security(syminfo.tickerid, rsi2_tf, ta.rsi(rsi_source, rsi2_len))

// === Entry Conditions ===
can_long = rsi_higher > 50
can_short = rsi_higher < 50
long_signal = can_long and ta.crossover(rsi_lower, buy_entry_level)
short_signal = can_short and ta.crossunder(rsi_lower, sell_entry_level)

// === Exit Conditions ===
exit_long = ta.crossunder(rsi_lower, buy_exit_level)
exit_short = ta.crossover(rsi_lower, sell_exit_level)

// === Position Entries ===
if (long_signal)
    strategy.entry("Buy RSI", strategy.long)

if (short_signal)
    strategy.entry("Sell RSI", strategy.short)

// === Position Exits ===
if (exit_long)
    strategy.close("Buy RSI")

if (exit_short)
    strategy.close("Sell RSI")

Overview

The higher-timeframe RSI acts as a trend filter, enabling long trades when above 50 and short trades when below 50. Lower-timeframe RSI crossovers trigger entries when crossing oversold or overbought levels, while exits occur on opposite crossover thresholds. Settings allow users to customize both timeframes, RSI lengths, and entry or exit levels. Executed trades are plotted directly on the price chart. The strategy contains no default stop loss.

Details

Published by

Ahmed-GoCode on GitHub

Code credit

Ahmed - Quant-Edge Indicators, as written in the script's header

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

Oscillators & momentum, Trend

Markets

Any symbol

Timeframes

M1-M5, M15-H1

Risk Notes

  • The strategy enters trades without a stop loss

Topics

fair-value-gapfibonaccimarket-structurepine-scriptrsi-strategysmart-money-conceptstechnical-analysistradingviewalgorithmic-tradingcrypto-trading

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Higher RSI Timeframetimeframe15rsi1_tf
Higher RSI Periodint14rsi1_len
Lower RSI Timeframetimeframe1rsi2_tf
Lower RSI Periodint7rsi2_len
Buy Entry Levelint30buy_entry_level
Sell Entry Levelint70sell_entry_level
Buy Exit Levelint70buy_exit_level
Sell Exit Levelint30sell_exit_level
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

330 stars

2 EMA/SMA + RSI Strategy [Alorse] combines three configurable moving averages with a short-period Relative Strength Index filter. It plots fast, slow, and trend moving averages on the price chart. Long entries trigger when the fast moving average is above the

Strategy v4 TrendOscillators & momentum
Updated 2 months ago · None stated GitHub repository of 2 EMA/SMA + RSI Strategy [Alorse]

Acrypto - Weighted Strategy

by AlbertoCuadra
318 stars

This strategy plots on the price chart and opens long or short positions when a weighted score from MACD, Stochastic RSI, RSI, Supertrend and a moving-average crossover exceeds a user-set trigger. Each component has its own weight and candle delay. Entries can

Strategy v5 TrendOscillators & momentum
Updated 3 years ago · Custom licence GitHub repository of Acrypto - Weighted Strategy
285 stars

Mean Reversion Strategy is an overlay strategy that identifies pullbacks using a long-term EMA, RSI, and candlestick patterns. It generates long signals when a bullish engulfing candle forms below the EMA while RSI is oversold, and short signals when a bearish

Strategy v4 Mean reversionCandlestick patterns
Updated 3 years ago · None stated GitHub repository of Mean Reversion Strategy
218 stars

This strategy generates trading signals based on a selectable momentum engine, supporting MACD, RSI, Stochastic, or Rate of Change. Entries trigger on signal crosses, zero-line crosses, or threshold crosses, with an optional moving average trend filter. Risk m

Strategy v6 Oscillators & momentumTrend
Updated 3 months ago · None stated GitHub repository of Momentum Strategy Template

255 EMA Strategy

by hasnocool
106 stars

255 EMA Strategy combines an exponential moving average with Average True Range bands and standard MACD crossovers to generate entry signals. Drawn directly on the price chart, it plots the central 255 EMA along with upper and lower volatility envelopes. Trade

Strategy v4 Moving averagesOscillators & momentum
Updated 2 years ago · GPL-3.0 GitHub repository of 255 EMA Strategy

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers