-
-
-
-
-
-
https://tr.tradingview.com/script/C3...T3-ChartPrime/
RSI-Adaptive T3 [ChartPrime]
PHP Code:
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ChartPrime
//@version=6
indicator('RSI-Adaptive T3 [ChartPrime]', overlay = true)
// --------------------------------------------------------------------------------------------------------------------}
// 📌 𝙐𝙎𝙀𝙍 𝙄𝙉𝙋𝙐𝙏𝙎
// --------------------------------------------------------------------------------------------------------------------{
src = close
rsiLen = input.int(14, 'RSI Length', group = "T3")
minLen = input.int(5, 'Min T3 Length', group = "T3")
maxLen = input.int(50, 'Max T3 Length', group = "T3")
v = input.float(0.7, 'T3 Volume Factor', step = 0.01, maxval = 2, minval = 0.1, group = "T3")
color_up = input.color(#21b8f3)
color_dn = input.color(#fd761b)
grp_vol_b = 'Volatility Bands'
show_bands = input.bool(true, 'Display', group = grp_vol_b, inline = "vol")
vol_col = input.color(#21c9f380, "", group = grp_vol_b, inline = "vol")
volat = input.int(100, 'Volatility', group = grp_vol_b)
// --------------------------------------------------------------------------------------------------------------------}
// 📌 𝙄𝙉𝘿𝙄𝘾𝘼𝙏𝙊𝙍 𝘾𝘼𝙇𝘾𝙐𝙇𝘼𝙏𝙄𝙊𝙉𝙎
// --------------------------------------------------------------------------------------------------------------------{
// Step 1: Adaptive length via RSI
rsi = ta.rsi(src, rsiLen)
rsi_scale = 1 - rsi / 100
len = math.round(minLen + (maxLen - minLen) * rsi_scale)
pine_ema(src, length) =>
alpha = 2 / (length + 1)
sum = 0.0
sum := na(sum[1]) ? src : alpha * src + (1 - alpha) * nz(sum[1])
sum
// Step 2: T3 with adaptive length
e1 = pine_ema(src, len)
e2 = pine_ema(e1, len)
e3 = pine_ema(e2, len)
e4 = pine_ema(e3, len)
e5 = pine_ema(e4, len)
e6 = pine_ema(e5, len)
c1 = -v * v * v
c2 = 3 * v * v + 3 * v * v * v
c3 = -6 * v * v - 3 * v - 3 * v * v * v
c4 = 1 + 3 * v + v * v * v + 3 * v * v
t3 = c1 * e6 + c2 * e5 + c3 * e4 + c4 * e3
t3_col = t3 > t3[2] ? color_up : color_dn
stdv = ta.stdev(t3, volat)
// --------------------------------------------------------------------------------------------------------------------}
// 📌 𝙑𝙄𝙎𝙐𝘼𝙇𝙄𝙕𝘼𝙏𝙄𝙊𝙉
// --------------------------------------------------------------------------------------------------------------------{
pt31 = plot(t3, color = t3_col, linewidth = 1, editable = false)
pt32 = plot(t3[2], color = t3_col, linewidth = 1, editable = false)
fill(pt31, pt32, color.new(t3_col, 90))
pu = plot(t3 + stdv, "Upper Volatility Band", style = plot.style_cross, color = vol_col, display = show_bands ? display.all : display.none)
pl = plot(t3 - stdv, "Lower Volatility Band", style = plot.style_cross, color = vol_col, display = show_bands ? display.all : display.none)
fill(pu, pl, color.new(vol_col, 95), display = show_bands ? display.all : display.none)
plotchar(ta.crossover(t3, t3[2]) or ta.crossunder(t3, t3[2]) ? t3 : na, "", "🞛", location.absolute, t3_col)
if barstate.islast
tbl = table.new(position.middle_right, 10, 10)
tbl.cell(0, 1, '', text_color = chart.fg_color, text_halign = text.align_right)
tbl.cell(1, 1, '▼' + str.tostring(maxLen), text_color = color_up)
tbl.cell(0, 3, '', text_color = chart.fg_color, text_halign = text.align_right)
tbl.cell(1, 3, '▲' + str.tostring(minLen), text_color = color_dn)
tbl.cell(0, 2, 'RSI Adaptive Length:', text_color = chart.fg_color)
tbl.cell(1, 2, str.tostring(len), text_color = color.from_gradient(len, minLen, maxLen, color_dn, color_up))
// --------------------------------------------------------------------------------------------------------------------}
-
https://tr.tradingview.com/script/tH...trength-Index/
Directional Strength Index
PHP Code:
//@ Julien_Eche
//@version=6
indicator("Directional Strength Index", overlay=true, max_labels_count=500)
length = input.int(20, title="SMEMA Length")
table_size = input.string("normal", title="Table Size", options=["small", "normal", "large"])
table_text_size = table_size
show_deviation_lines = input.bool(true, title="Show Deviation Levels")
show_tf_cells = input.bool(true, title="Show All Timeframes")
approach = input.string("Long Term", title="Overall Trend Weighting", options=["Long Term", "Swing Trading", "Short Term"])
color_bull = input.color(#00897B, title="Bull Color", inline="col")
color_bear = input.color(#C0392B, title="Bear Color", inline="col")
color_neutral = input.color(#C49A6C, title="Neutral Color", inline="col")
get_trend_arrow(score) => score >= 0.5 ? "➚" : score <= -0.5 ? "➘" : "➡"
get_trend_strength(score) => str.tostring(math.round(math.abs(score))) + "/10"
trend_col(score) => score > 0.5 ? color_bull : score < -0.5 ? color_bear : color_neutral
get_dynamic_color(score, alpha) => color.new(trend_col(score), alpha)
get_band_color(level, src, score, is_upper, col_bull, col_bear) =>
r = math.abs(src - level) / ta.percentile_linear_interpolation(math.abs(src - level), 400, 100)
c = score > 0 and is_upper ? col_bull : score < 0 and not is_upper ? col_bear : na
result = na(c) ? na : r <= 0.03 ? color.new(c, 96) : r <= 0.06 ? color.new(c, 90) : r <= 0.10 ? color.new(c, 80) : r <= 0.15 ? color.new(c, 68) : r <= 0.20 ? color.new(c, 55) : r <= 0.27 ? color.new(c, 42) : r <= 0.35 ? color.new(c, 30) : color.new(c, 18)
result
get_score_internal() =>
sm = ta.sma(ta.ema(close, length), length)
sm_prev = ta.sma(ta.ema(close[1], length), length)
step = ta.atr(100)
slope = sm - sm_prev
slope_ratio = slope / sm
slope_ratio := slope_ratio > 0.1 ? 0.1 : slope_ratio < -0.1 ? -0.1 : slope_ratio
slope_weight = 1.0 + slope_ratio * 10.0
bull = (close > sm + step ? 1 : 0) + (close > sm + step * 2 ? 1 : 0) + (close > sm + step * 3 ? 1 : 0)
bear = (close < sm - step ? 1 : 0) + (close < sm - step * 2 ? 1 : 0) + (close < sm - step * 3 ? 1 : 0)
raw_score = (bull - bear) * 10.0 / 3.0
adjusted_score = raw_score * slope_weight
adjusted_score := adjusted_score > 10.0 ? 10.0 : adjusted_score < -10.0 ? -10.0 : adjusted_score
adjusted_score
get_score(tf) => request.security(syminfo.tickerid, tf, get_score_internal(), lookahead=barmerge.lookahead_on)
score_1H = get_score("60")
score_4H = get_score("240")
score_1D = get_score("D")
score_3D = get_score("3D")
score_1W = get_score("W")
score_1M = get_score("M")
w_1H = approach == "Short Term" ? 0.35 : approach == "Swing Trading" ? 0.10 : 0.03
w_4H = approach == "Short Term" ? 0.30 : approach == "Swing Trading" ? 0.15 : 0.07
w_1D = approach == "Short Term" ? 0.20 : approach == "Swing Trading" ? 0.25 : 0.20
w_3D = approach == "Short Term" ? 0.10 : approach == "Swing Trading" ? 0.25 : 0.25
w_1W = approach == "Short Term" ? 0.05 : approach == "Swing Trading" ? 0.15 : 0.35
w_1M = approach == "Short Term" ? 0.00 : approach == "Swing Trading" ? 0.10 : 0.10
global_score = score_1H * w_1H + score_4H * w_4H + score_1D * w_1D + score_3D * w_3D + score_1W * w_1W + score_1M * w_1M
label = "Global " + (approach == "Long Term" ? "LT" : approach == "Swing Trading" ? "SW" : "ST")
var table stats_table = table.new(position=position.top_right, columns=3, rows=8, frame_color=color.new(color.gray, 70), frame_width=1, border_width=0)
table.set_bgcolor(stats_table, color.new(color.rgb(26, 26, 26), 0))
if barstate.islast
table.cell(stats_table, 0, 0, "Timeframe", text_color=color.gray, text_size=table_text_size)
table.cell(stats_table, 1, 0, "Trend", text_color=color.gray, text_size=table_text_size)
table.cell(stats_table, 2, 0, "Strength", text_color=color.gray, text_size=table_text_size)
row_idx = 1
if show_tf_cells
for i = 0 to 5
tf = i == 0 ? "1H" : i == 1 ? "4H" : i == 2 ? "1D" : i == 3 ? "3D" : i == 4 ? "1W" : "1M"
sc = i == 0 ? score_1H : i == 1 ? score_4H : i == 2 ? score_1D : i == 3 ? score_3D : i == 4 ? score_1W : score_1M
table.cell(stats_table, 0, row_idx, tf, text_color=color.gray, text_size=table_text_size)
table.cell(stats_table, 1, row_idx, get_trend_arrow(sc), text_color=trend_col(sc), text_size=table_text_size)
table.cell(stats_table, 2, row_idx, get_trend_strength(sc), text_color=trend_col(sc), text_size=table_text_size)
row_idx := row_idx + 1
table.cell(stats_table, 0, row_idx, label, text_color=color.silver, text_size=table_text_size)
table.cell(stats_table, 1, row_idx, get_trend_arrow(global_score), text_color=trend_col(global_score), text_size=table_text_size)
table.cell(stats_table, 2, row_idx, get_trend_strength(global_score), text_color=trend_col(global_score), text_size=table_text_size)
sm = ta.sma(ta.ema(close, length), length)
sm_prev = ta.sma(ta.ema(close[1], length), length)
step = ta.atr(100)
sm_bull = (close > sm + step ? 1 : 0) + (close > sm + step * 2 ? 1 : 0) + (close > sm + step * 3 ? 1 : 0)
sm_bear = (close < sm - step ? 1 : 0) + (close < sm - step * 2 ? 1 : 0) + (close < sm - step * 3 ? 1 : 0)
sm_score = (sm_bull - sm_bear) * 10.0 / 3.0
slope = sm - sm_prev
slope_ratio = slope / step
slope_ratio := slope_ratio > 2.0 ? 2.0 : slope_ratio < -2.0 ? -2.0 : slope_ratio
slope_weight = 1.0 + slope_ratio * 0.25
adjusted_sm_score = sm_score * slope_weight
adjusted_sm_score := adjusted_sm_score > 10.0 ? 10.0 : adjusted_sm_score < -10.0 ? -10.0 : adjusted_sm_score
plot(show_deviation_lines ? sm + step * 3 : na, color=get_band_color(sm + step * 3, close, adjusted_sm_score, true, color_bull, color_bear))
plot(show_deviation_lines ? sm + step * 2 : na, color=get_band_color(sm + step * 2, close, adjusted_sm_score, true, color_bull, color_bear))
plot(show_deviation_lines ? sm + step : na, color=get_band_color(sm + step , close, adjusted_sm_score, true, color_bull, color_bear))
plot(sm, color=get_dynamic_color(adjusted_sm_score, 0), title="SMEMA", linewidth=2)
plot(show_deviation_lines ? sm - step : na, color=get_band_color(sm - step , close, adjusted_sm_score, false, color_bull, color_bear))
plot(show_deviation_lines ? sm - step * 2 : na, color=get_band_color(sm - step * 2, close, adjusted_sm_score, false, color_bull, color_bear))
plot(show_deviation_lines ? sm - step * 3 : na, color=get_band_color(sm - step * 3, close, adjusted_sm_score, false, color_bull, color_bear))
-