1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
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
60 lines of Pine Script v4 from BB + RSI double strategy develope.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.
BB + RSI double strategy develope.pine
//@version=4
strategy("Ezieh Str.v2", shorttitle="Ezieh Str.v2", overlay=true, pyramiding=10, currency=currency.USD, slippage=3, commission_type=strategy.commission.cash_per_order, commission_value=0.04, initial_capital=1000)
UseDateFilter = input(title="Enable Date Filter" ,type=input.bool ,defval=false ,group="Date & Time" ,tooltip="Turns on/off date filter")
StartDate = input(title="Start Date Filter" ,type=input.time ,defval=timestamp("1 Jan 2000 00:00 +0000") ,group="Date & Time" ,tooltip="Date & time to start excluding trades")
EndDate = input(title="End Date Filter" ,type=input.time ,defval=timestamp("1 Jan 2100 00:00 +0000") ,group="Date & Time" ,tooltip="Date & time to stop excluding trades")
UseTimeFilter = input(title="Enable Time Session Filter" ,type=input.bool ,defval=false ,group="Date & Time" ,tooltip="Turns on/off time session filter")
TradingSession = input(title="Trading Session" ,type=input.session ,defval="1000-2200:1234567" ,group="Date & Time" ,tooltip="No trades will be taken outside of this range")
In(t) => na(time(timeframe.period, t)) == false
TimeFilter = (UseTimeFilter and not In(TradingSession)) or not UseTimeFilter
DateFilter = time >= StartDate and time <= EndDate
DateTime = (UseDateFilter ? not DateFilter : true) and (UseTimeFilter ? In(TradingSession) : true)
///////////// RSI
L_RSI_Length = input(7 , title="L_Length")
L_RSI_OverSold = input(45 , title="L_OverSold")
S_RSI_Length = input(14 , title="S_Length")
S_RSI_OverBought = input(65 , title="S_OverBought")
price = close
Lvrsi = rsi(price, L_RSI_Length)
Svrsi = rsi(price, S_RSI_Length)
///////////// Bollinger Bands
BBlength = input(title="Bollinger Period Length", type=input.integer, defval=100, minval=2)
BBmult = 2.1 // input(2.0, minval=0.001, maxval=50,title="Bollinger Bands Standard Deviation")
BBbasis = sma(price, BBlength)
BBdev = BBmult * stdev(price, BBlength)
BBupper = BBbasis + BBdev
BBlower = BBbasis - BBdev
source = close
plot(BBbasis, color=color.aqua,title="Bollinger Bands SMA Basis Line")
p1 = plot(BBupper, color=color.silver,title="Bollinger Bands Upper Line")
p2 = plot(BBlower, color=color.silver,title="Bollinger Bands Lower Line")
fill(p1, p2)
///////////// Colors
switch1=input(true, title="Enable Bar Color?")
switch2=input(true, title="Enable Background Color?")
///////////// Condition
LongCondition = crossover(Lvrsi, L_RSI_OverSold) and crossover(close ,BBlower)
ShortCondition = crossunder(Svrsi, S_RSI_OverBought) and crossunder(close,BBupper)
Longexcon = crossunder(low, BBupper)
Shortexcon = crossover(low, BBlower)
qt = round(strategy.equity/price, 3)
///////////// RSI + Bollinger Bands Strategy
if (not na(Lvrsi))
if LongCondition and DateTime
strategy.entry("RSI_BB_L", strategy.long, qty=qt, oca_type=strategy.oca.cancel, comment="Long")
else
strategy.cancel(id="RSI_BB_L")
if Longexcon
strategy.close("RSI_BB_L", qty_percent = 100, comment = "L_exit")
if ShortCondition and DateTime
strategy.entry("RSI_BB_S", strategy.short, qty=qt, oca_type=strategy.oca.cancel, comment="Short")
else
strategy.cancel(id="RSI_BB_S")
if Shortexcon
strategy.close("RSI_BB_S", qty_percent = 100, comment = "S_exit")
//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)
Expand (75 lines)
Overview
Ezieh Str.v2 opens long positions when a fast RSI crosses above an oversold threshold while price crosses over the lower Bollinger Band. Short positions trigger when a slow RSI crosses below an overbought threshold while price crosses under the upper band. Trades exit when price crosses the opposing Bollinger Band line, without a fixed stop loss. The strategy plots Bollinger Bands directly on the price chart.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Enable Date Filter
bool
false
UseDateFilter
Start Date Filter
time
timestamp("1 Jan 2000 00:00 +0000")
StartDate
End Date Filter
time
timestamp("1 Jan 2100 00:00 +0000")
EndDate
Enable Time Session Filter
bool
false
UseTimeFilter
Trading Session
session
1000-2200:1234567
TradingSession
L_Length
int
7
L_RSI_Length
L_OverSold
int
45
L_RSI_OverSold
S_Length
int
14
S_RSI_Length
S_OverBought
int
65
S_RSI_OverBought
Bollinger Period Length
int
100
BBlength
Enable Bar Color?
bool
true
switch1
Enable Background Color?
bool
true
switch2
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.
This strategy plots MACD line, signal line, Bollinger Bands, and RSI on the price chart. It signals long entries on MACD crossover above signal with RSI below 50 and price below BB basis, plus optional DMI filter. Short entries are available but disabled by de
This educational strategy demonstrates moving average crossovers filtered by RSI momentum, incorporating ATR-based risk management. It calculates a 10-period SMA, a 30-period SMA, a 14-period RSI, and a 14-period ATR. Long entries trigger when the fast SMA cro
This strategy combines exponential moving averages (EMA 9, 21, 50), RSI, MACD, and Supertrend indicators to enter long positions. It triggers trades using six dynamic setups based on momentum breakouts, EMA crossovers, and pullbacks. Position sizing is compute
This strategy plots exponential-moving-average Bollinger bands on the price chart and calculates RSI. It opens a long position when close crosses above the upper band while RSI is at or above a threshold, the date filter allows trading, and no position is open
CombinedBinHAndClucV6 is a trading strategy based on the popular BinHV45 and ClucMay72018 algorithms. It calculates dual Bollinger Bands, Exponential Moving Averages, Relative Strength Index, Average True Range, and volume metrics across primary and one-hour h
This strategy calculates Bollinger Bands, a configurable moving average slope, Stochastic RSI, ATR, and ADX directly on the price chart. It evaluates trend bias and momentum conditions to generate long and short swing entries using percent-of-equity sizing. Th