Indicator · Pine Script v5 · On the chart

Datsana V.1

by g-moe· code credited to goodgains

This indicator plots RSI divergence lines at resistance and support levels based on 14-period RSI crossing above 70 or below 30 within a search window of 141 bars.

View on GitHub

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code101
Settings11inputs
LicenceNone statedfile: MPL-2.0
Last update5 months ago27 May 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 indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

101 lines of Pine Script v5 from Tradingview/datsana-v-1.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

datsana-v-1.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © goodgains


//@version=5
indicator('datsana V.1', overlay=true)

// @keywords: rsi-divergence-lines, resistance-support-levels, dual-ema-trend-fill, vwap-filter, tick-pattern-diamonds, demark-indicator, ehler-ratio, bollinger-bands, deceleration-filter, tpo-extremes, arrow-signals, buy-sell-labels, inverse-trend-toggle, rsi-overbought-oversold, ema-199-299, momentum-exhaustion, price-reversal-markers, multi-filter-entries, gradient-candles, plotshape-markers


dlenuli = float(na)
dleodin = float(na)
dletri = float(na)



search = input.int(141, title='rsi div. search length', group='rsi div')
highrsi = input.int(70, title='high rsi', group='rsi div')
lowrsi = input.int(30, title='low rsi', group='rsi div')
rsi = ta.rsi(close, 14)
mprx = ta.highest(close, search)  // mx
mprm = ta.lowest(close, search)  // mn
dleodin := close == mprx and rsi > highrsi ? close : dleodin[1]
dletri := close == mprm and rsi < lowrsi ? close : dletri[1]
isu = high > dleodin
iso = low < dletri
plot(dleodin, color=#ee524f41, linewidth=4, title='rsi div. res line')
plot(dletri, color=#26a79a41, linewidth=4, title='rsi div. sup line')


// ema
ema199 = ta.ema(close, 199)
ema299 = ta.ema(close, 299)
plm1 = plot(ema199, color=#00000000, title='ema199', style=plot.style_stepline)
plm2 = plot(ema299, color=#00000000, title='ema299', style=plot.style_stepline)
trend = ema199 > ema299
fill(plm1, plm2, color=trend ? #26a79a31 : #ee524f31, title='ema fill', transp=90)

// vwap / sma
ma17 = ta.sma(close, 17)
plot(ta.vwap, color=color.new(#e35c8d, 0), title='vwap', display=display.none)

// tkps
acctkpsfl = input.bool(true, title='filter tkps', group='tkps')
tkps = (acctkpsfl ? isu and close > ta.vwap ? true : false : true) and close[1] > high[2] and close < high[2] ? 1 : (acctkpsfl ? isu and close < ta.vwap ? true : false : true) and close[1] < high[2] and close > high[2] ? 3 : 0
plotshape(tkps == 1, title='tkps', location=location.abovebar, color=#ee524f41, style=shape.diamond, size=size.tiny)
plotshape(tkps == 3, title='tkps', location=location.belowbar, color=#26a79a41, style=shape.diamond, size=size.tiny)

// demark
dmrkx = high > high[1] ? high - high[1] : 0
dmrkm = low > low[1] ? low - low[1] : 0
rkxse = ta.sma(dmrkx, 17)
rkmse = ta.sma(dmrkm, 17)
demark = rkxse / (rkxse + rkmse)

// ehler
hlr = float(na)
lvw = ta.lowest(hlc3, 17)
hlr := (hlc3 - lvw) / (ta.highest(hlc3, 17) - lvw)

// bb
dev = ta.stdev(close, 21)
bbup = ma17 + dev * 2
bbdw = ma17 - dev * 2
tcbb = high > bbup or low < bbdw
plot(bbup, color=hlr == 1 ? #ee524f : #ee524f41, title='upper bbands', linewidth=2, style=plot.style_stepline)
plot(bbdw, color=hlr == 0 ? #26a79a : #26a79a41, title='lower bbands', linewidth=2, style=plot.style_stepline)

// deceleration
accdc = input.bool(false, title='active deceleration', group='deceleration')
dsn = input.float(1.035, title='deceleration density', step=0.001, group='deceleration')
change = math.abs(ma17 - ta.sma(ma17, 7))
// tcbb == false and 
isdecc = accdc ? change < change[1] * dsn and tcbb : true

// is tpo
istpx = ta.highest(close, 247) == close
istpm = ta.lowest(close, 247) == close



// signals
bstop = isdecc and isu and istpx[1] and close < open
bsbtm = isdecc and iso and istpm[1] and close > open
inverse = input.bool(true, title='reverse trend for signals', group='trend')
plotshape(bstop, location=location.abovebar, color=color.new(#ee524f, 0), style=shape.arrowdown, size=size.small)
plotshape(bsbtm, location=location.belowbar, color=color.new(#26a79a, 0), style=shape.arrowup, size=size.small)
plotshape(bstop and (inverse ? trend : trend == false), location=location.abovebar, color=color.new(#ee524f, 0), style=shape.triangledown, size=size.tiny)
plotshape(bsbtm and (inverse ? trend == false : trend), location=location.belowbar, color=color.new(#26a79a, 0), style=shape.triangleup, size=size.tiny)

// plotchar(bstop and (inverse ? trend : trend == false), char='Sell', location=location.abovebar, color=color.new(#ffffff, 0), size=size.tiny)
// plotchar(bsbtm and (inverse ? trend == false : trend), char='Buy', location=location.belowbar, color=color.new(#ffffff, 0), size=size.tiny)


buy_color = input.color(#27a69b, title='Buy Color', inline='6', group='Signal Settings')
sell_color = input.color(#b63632, title='Sell Color', inline='6', group='Signal Settings')
neutral_color = input.color(color.yellow, title='Neutral Color', inline='6', group='Signal Settings')
color_candles = input.string('Gradient', title = 'Color Candles', options = ['Gradient', 'Two-Colors', 'None'], inline = '7', group = 'Signal Settings')

plotshape(bsbtm and (inverse ? trend == false : trend) ? low - (syminfo.mintick * 20) : na, style=shape.labelup, editable=false, text= "BUY", textcolor=color.white, location= location.absolute, color=color.new(buy_color, 30), size=size.tiny)
plotshape(bstop and (inverse ? trend : trend == false) ? high + (syminfo.mintick * 20) : na, style=shape.labeldown, editable=false, text='SELL', textcolor=color.white, location=location.absolute, color=color.new(sell_color, 30), size=size.tiny)

Overview

Datsana V.1 displays dual EMA trend fill between periods 199 and 299, VWAP filter, TKPS tick pattern diamonds, Demark indicator ratio, Ehlers ratio, Bollinger Bands with conditional colors, active deceleration filter, and TPO extremes. Buy and sell signals appear as plotshapes when deceleration occurs alongside trend and TPO conditions, with an option to reverse signals. Candles can be colored via gradient. All elements draw on the price chart as overlay.

Details

Published by

g-moe on GitHub

Code credit

goodgains, as written in the script's header

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Oscillators & momentum, Moving averages, Support & resistance, Volatility & bands

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

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

SettingTypeDefaultVariable
rsi div. search lengthint141search
high rsiint70highrsi
low rsiint30lowrsi
filter tkpsbooltrueacctkpsfl
active decelerationboolfalseaccdc
deceleration densityfloat1.035dsn
reverse trend for signalsbooltrueinverse
Buy Colorcolor#27a69bbuy_color
Sell Colorcolor#b63632sell_color
Neutral Colorcolorcolor.yellowneutral_color
Color CandlesstringGradientcolor_candles
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

Super Algo Setup [Aura]

by IAMATOMIC001
3 stars

This overlay indicator combines SuperTrend, RSI, MACD, and an EMA to mark labeled tops and bottoms on the price chart. Optional filters hide repeating signals and keep only relevant exits, and a Krypton fear-and-greed filter can limit bottoms and tops to overs

Indicator v5 Oscillators & momentumMoving averages
Updated 12 months ago · None stated GitHub repository of Super Algo Setup [Aura]
1 stars

This indicator plots envelope bands based on a moving average or exponential moving average of a chosen price source. It computes RSI with user-set length and source. Signals trigger on crossovers: buy when price crosses the lower envelope band while RSI falls

Indicator v5 Oscillators & momentumMoving averages
Updated 1 year ago · None stated GitHub repository of ENVELOPE - RSI - Buy Sell Signals
1 stars

US Momentum Swing Screener is a daily chart overlay indicator for US equities and ETFs. It plots a composite score based on an EMA ribbon (9/21/50/200), RSI and StochRSI momentum, MACD confluence, volume surge detection, ADX trend strength, Bollinger Band posi

Indicator v5 Oscillators & momentumMoving averages
Updated 4 months ago · None stated GitHub repository of US Momentum Swing Screener

Composite Market Bias

by mrme000m
1 stars

Composite Market Bias is a separate-pane indicator that scores bullish and bearish conditions from RSI, fast versus slow EMA, MACD histogram, Bollinger Band position, and price versus a 50-period EMA. It plots the resulting bias score with RSI, EMA trend, MACD

Indicator v5 Oscillators & momentumMoving averages
Updated 6 weeks ago · None stated GitHub repository of Composite Market Bias

This overlay indicator plots a Supertrend from an ATR length and factor, four exponential moving averages, and a selectable VWAP or TWAP taken from a chosen timeframe on the price chart. It also shows MACD and stochastic with adjustable lengths, smoothing, ver

Indicator v5 Oscillators & momentumMoving averages
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup: Vijay Thakare Option Buying Scalping Setup

This indicator plots trade entry and exit signals on the price chart by combining Bollinger Bands with optional filter conditions. It calculates standard Bollinger Bands along with RSI, Aroon, and moving average filters. Reversal signals trigger when price bre

Indicator v4 Volatility & bandsOscillators & momentum
Updated 2 months ago · None stated GitHub repository of Bollinger Bands Winner IND [Alorse]

More indicators

Trade Your Charts With a Regulated Broker

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

Compare brokers