Simple TDI

Nobilitus · study · 52 行 · 点赞 22 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

//@version=6
indicator("Simple TDI", shorttitle="TDI", overlay=false, precision=2)
 
// Base calculations mirror the four user-configured NinjaTrader 8 indicators.
// Select the same contract, chart type, trading session, and 8-minute bars
// on both platforms when comparing them.
 
// 1. Green RSI: NT8 RSI(14, 1) on the closing price.
string rsiGroup = "1. Green RSI"
rsiPeriod = input.int(14, "RSI Period", minval=1, group=rsiGroup)
rsiSmooth = input.int(1, "RSI Smooth", minval=1, group=rsiGroup)
 
// 2. Red signal: SMA of the green RSI, period 7.
string signalGroup = "2. Red Trade Signal"
signalPeriod = input.int(7, "SMA Period", minval=1, group=signalGroup)
 
// 3. Yellow market baseline: SMA of the green RSI, period 30.
string baselineGroup = "3. Yellow Market Base Line"
baselinePeriod = input.int(30, "SMA Period", minval=1, group=baselineGroup)
 
// 4. Blue volatility bands: Bollinger bands on RSI, period 30, 1.618 SD.
string bandGroup = "4. Blue Volatility Bands"
bandPeriod = input.int(30, "Band Period", minval=1, group=bandGroup)
bandDeviations = input.float(1.618, "Standard Deviations", minval=0.001, step=0.001, group=bandGroup)
showMiddle = input.bool(false, "Show Bollinger Middle Band", group=bandGroup)
 
string displayGroup = "Display"
showLevels = input.bool(true, "Show 32 / 50 / 68 Levels", group=displayGroup)
 
// Pine's ta.rsi uses Wilder-style smoothing. A 1-period SMA adds no
// extra smoothing, corresponding to the configured NT8 Smooth = 1.
rsiRaw = ta.rsi(close, rsiPeriod)
rsiGreen = ta.sma(rsiRaw, rsiSmooth)
redSignal = ta.sma(rsiGreen, signalPeriod)
yellowBaseline = ta.sma(rsiGreen, baselinePeriod)
 
bandMiddle = ta.sma(rsiGreen, bandPeriod)
bandStdDev = ta.stdev(rsiGreen, bandPeriod)
upperBand = bandMiddle + bandDeviations * bandStdDev
lowerBand = bandMiddle - bandDeviations * bandStdDev
 
plot(rsiGreen, "Green RSI", color=color.rgb(0, 255, 0), linewidth=3)
plot(redSignal, "Red Trade Signal", color=color.rgb(255, 0, 0), linewidth=3)
plot(yellowBaseline, "Yellow Market Base Line", color=color.rgb(255, 215, 0), linewidth=3)
plot(upperBand, "Upper Blue Volatility Band", color=color.rgb(30, 144, 255), linewidth=3)
plot(lowerBand, "Lower Blue Volatility Band", color=color.rgb(30, 144, 255), linewidth=3)
plot(showMiddle ? bandMiddle : na, "Bollinger Middle (optional)", color=color.new(color.blue, 65), linewidth=1)
 
// TDI reference lines, not additional indicators.
plot(showLevels ? 68.0 : na, "Upper Reference 68", color=color.new(color.gray, 45), linewidth=1, style=plot.style_circles)
plot(showLevels ? 50.0 : na, "Mid Reference 50", color=color.new(color.gray, 35), linewidth=1, style=plot.style_circles)
plot(showLevels ? 32.0 : na, "Lower Reference 32", color=color.new(color.gray, 45), linewidth=1, style=plot.style_circles)

← 返回列表