This indicator calculates a modified version of the Traders Dynamic Index (TDI) in a separate pane using RSI, fast and slow moving averages, and volatility bands.
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 indicator, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.
Source Code
95 lines of Pine Script v6 from TDI-EB.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.
TDI-EB.pine
// This script was created by Evan Barth. evanbarth.com
// Dean Malone is the original creator of the TDI, of which this is modified. Thanks, Dean.
//@version=6
indicator("TDI-EB - Traders Dynamic Index", shorttitle = "TDI-EB")
// ── Inputs ──────────────────────────────────────────────────────────────
rsiPeriod = input.int(21, "RSI Period", minval = 1)
bandLength = input.int(34, "Band Length", minval = 2)
bandMult = input.float(1.6185, "Band Multiplier", minval = 0.1, step = 0.1)
priceLen = input.int(2, "Price Line (fast MA of RSI)", minval = 1)
signalLen = input.int(7, "Signal Line (slow MA of RSI)", minval = 1)
grpSig = "Sharkfin signals"
maxBars = input.int(10, "Max bars after leaving band", minval = 1, group = grpSig,
tooltip = "The cross must happen within this many bars of the last bar the price line was outside the band.")
requireReentry = input.bool(false, "Require price line back inside band", group = grpSig,
tooltip = "Off: fire on the price/signal cross, even if the price line is still outside the band.\nOn: fire on the first bar the price line is back inside the band AND on the other side of the signal line (a completed fin).")
confirmedOnly = input.bool(true, "Signal only on closed bars (no flicker)", group = grpSig)
// ── Core TDI ────────────────────────────────────────────────────────────
r = ta.rsi(close, rsiPeriod)
mid = ta.sma(r, bandLength) // band basis (same thing as (up + dn) / 2)
offs = bandMult * ta.stdev(r, bandLength)
up = mid + offs
dn = mid - offs
priceLine = ta.sma(r, priceLen) // 2-period: the fast, "RSI" line (black)
signalLine = ta.sma(r, signalLen) // 7-period: the slow signal line (light blue)
// ── Raw conditions ──────────────────────────────────────────────────────
outTop = priceLine > up
outBot = priceLine < dn
crossUp = ta.crossover(priceLine, signalLine)
crossDn = ta.crossunder(priceLine, signalLine)
// ── Sharkfin state machine: one signal per excursion ────────────────────
var bool topArmed = false
var bool botArmed = false
var int topLastOut = na
var int botLastOut = na
// Arm only when a NEW excursion starts, so a fin that already fired can't fire again
if outTop and not outTop[1]
topArmed := true
if outBot and not outBot[1]
botArmed := true
// Track the most recent bar outside the band (window is measured from here)
if outTop
topLastOut := bar_index
if outBot
botLastOut := bar_index
// Expire if no trigger within the window
if topArmed and bar_index - topLastOut > maxBars
topArmed := false
if botArmed and bar_index - botLastOut > maxBars
botArmed := false
bearTrigger = requireReentry ? (priceLine < signalLine and not outTop) : crossDn
bullTrigger = requireReentry ? (priceLine > signalLine and not outBot) : crossUp
barOK = not confirmedOnly or barstate.isconfirmed
sellFin = topArmed and bearTrigger and barOK
buyFin = botArmed and bullTrigger and barOK
if sellFin
topArmed := false
if buyFin
botArmed := false
// ── Plots ───────────────────────────────────────────────────────────────
hline(70, "Overbought", color = color.new(#131722, 28), linestyle = hline.style_dotted, linewidth = 2)
hline(30, "Oversold", color = color.new(#131722, 18), linestyle = hline.style_dotted, linewidth = 2)
hline(50, "Mid Line", color = color.new(#131722, 28), linestyle = hline.style_dotted, linewidth = 2)
plot(up, "Upper Band", color = color.new(#311b92, 49), linewidth = 2)
plot(dn, "Lower Band", color = color.new(#311b92, 49), linewidth = 2)
plot(mid, "Middle of Bands", color = color.new(#4aff85, 28), linewidth = 2)
plot(priceLine, "Price Line (RSI)", color = color.new(#000000, 28), linewidth = 2)
plot(signalLine, "Signal Line", color = color.new(#a4c2f4, 28), linewidth = 2)
// Warning: small marker on every bar the price line is outside the band
plotchar(outTop, title = "Above upper band", char = "∘", location = location.top, color = color.new(#ff5252, 28), size = size.tiny)
plotchar(outBot, title = "Below lower band", char = "∘", location = location.bottom, color = color.new(#00bcd4, 28), size = size.tiny)
// Signal: larger marker, once per fin
plotchar(sellFin, title = "Sharkfin sell", char = "✹", location = location.top, color = color.new(#ff4500, 0), size = size.tiny)
plotchar(buyFin, title = "Sharkfin buy", char = "✹", location = location.bottom, color = color.new(#00ffff, 0), size = size.tiny)
// ── Alerts (set frequency to "Once Per Bar Close") ──────────────────────
alertcondition(outTop and not outTop[1], "TDI warning: above upper band", "TDI-EB {{ticker}} {{interval}}: price line broke above the upper band. Possible bearish sharkfin forming.")
alertcondition(outBot and not outBot[1], "TDI warning: below lower band", "TDI-EB {{ticker}} {{interval}}: price line broke below the lower band. Possible bullish sharkfin forming.")
alertcondition(sellFin, "TDI sharkfin SELL", "TDI-EB {{ticker}} {{interval}}: bearish sharkfin, price line crossed under the signal line.")
alertcondition(buyFin, "TDI sharkfin BUY", "TDI-EB {{ticker}} {{interval}}: bullish sharkfin, price line crossed over the signal line.")
Overview
TDI-EB - Traders Dynamic Index identifies sharkfin setup patterns when the fast price line moves outside the volatility bands and subsequently crosses back across the signal line toward the mean. Inputs allow customizing the RSI period, band multiplier, moving average lengths, maximum signal window bars, and an optional re-entry filter. Visual plot markers flag active band excursions and signal triggers.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
RSI Period
int
21
rsiPeriod
Band Length
int
34
bandLength
Band Multiplier
float
1.6185
bandMult
Price Line (fast MA of RSI)
int
2
priceLen
Signal Line (slow MA of RSI)
int
7
signalLen
Max bars after leaving band
int
10
maxBars
Require price line back inside band
bool
false
requireReentry
Signal only on closed bars (no flicker)
bool
true
confirmedOnly
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.
MACD-V is a volatility-normalized momentum indicator based on research by Alex Spiroglou. It calculates the standard MACD histogram and normalizes it by dividing by the Average True Range (ATR). Plotted in a separate pane as a colored histogram, it includes us
MultiIndicator combines multiple technical indicators into a single separate pane to save chart space. It calculates and displays market regime detection based on ordinary least squares regression, a Holt exponential smoothing crossover, normalized RSI, ADX, a
PPO ATR Bands plots a percentage price oscillator in a separate pane. It compares a Hull average of typical price with a volume-weighted exponential average of Parabolic SAR, then scales three true-range bands around the slow average into matching oscillator l
The 8-Factor Composite Screener evaluates equities across fundamental and technical criteria, including valuation ratios, earnings and revenue growth, 12-month return momentum, proximity to 52-week highs, Stage 2 moving average alignment, benchmark relative st
This indicator plots a relative strength index in a separate pane. It calculates RSI from the average of the previous ten opens rather than the current bar, so that source does not change during the live candle. A moving average of the RSI is plotted and can b
Normalized Volatility Adjusted Relative Strength compares the chart symbol against a benchmark instrument such as SPY while adjusting for price volatility. The indicator calculates individual ATR-normalized price changes for both assets over a specified lookba