PHP Code:
//@version=6
indicator(title = 'Master Trend BUY&SELL', shorttitle = '.', overlay = true, max_lines_count = 500, max_labels_count=500)
/////////////////////
src88 = input.source(close,"RSI Source",group = "Connors RSI")
lenrsi = input(24, "RSI Length",group = "Connors RSI")
lenupdown = input(20, "UpDown Length",group = "Connors RSI")
lenroc = input(75, "ROC Length",group = "Connors RSI")
z_score_length = input(14, "Z-Score Lookback",group = "Filtering")
threshold = input.float(1.5, "Z-Score Threshold", step=0.025,group = "Filtering")
trendingLongThreshold = input.float(65, "Trending Long Threshold" ,group = "Filtering")
trendingShortThreshold = input.float(35, "Trending Short Threshold",group = "Filtering")
revertingLongThreshold = input.float(70, title="Reverting Long Threshold",group = "Filtering")
revertingShortThreshold = input.float(30, title="Reverting Short Threshold",group = "Filtering")
// ─── CONNORS RSI ──────────────────────────────────────────────────────────
updown(s) =>
isEqual = s == s[1]
isGrowing = s > s[1]
ud = 0.0
ud := isEqual ? 0 : isGrowing ? (nz(ud[1]) <= 0 ? 1 : nz(ud[1])+1) : (nz(ud[1]) >= 0 ? -1 : nz(ud[1])-1)
ud
rsi88 = ta.rsi(src88, lenrsi)
updownrsi = ta.rsi(updown(src88), lenupdown)
percentrank = ta.percentrank(ta.roc(src88, 1), lenroc)
crsi = math.avg(rsi88, updownrsi, percentrank)
// ─── Z-SCORING ──────────────────────────────────────────────────────────
mean = ta.sma(crsi, z_score_length)
stdDev = ta.stdev(crsi, z_score_length)
zScore88 = (crsi - mean) / stdDev
isTrending = math.abs(zScore88) > threshold
// ─── Signal Generation ────────────────────────────────────────────────
var int signal = 0
if barstate.isconfirmed
if isTrending
signal := crsi > trendingLongThreshold ? 1 : crsi < trendingShortThreshold ? -1 : signal[1]
else
signal := crsi > revertingLongThreshold ? 1 : crsi < revertingShortThreshold ? -1 : signal[1]
trendColor = signal == 1 ? #17dfad : signal == -1 ? #dd326b : color.gray
//decor = plot(crsi,"Decor",style = plot.style_columns,histbase = 50,color=trendColor,linewidth = 2)
bgcolor(color.new(trendColor,90))
//plotcandle(open,high,low,close,"Candles",color=trendColor,wickcolor = trendColor,bordercolor = trendColor,force_overlay = true)
/////////////
src77 = close
rsiLen77 = input.int(1, 'RSI Length', group = "T3")
minLen = input.int(3, 'Min T3 Length', group = "T3")
maxLen = input.int(5, 'Max T3 Length', group = "T3")
v = input.float(0.34, '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
rsi77 = ta.rsi(src77, rsiLen77)
rsi_scale = 1 - rsi77 / 100
len = math.round(minLen + (maxLen - minLen) * rsi_scale)
pine_ema(src77, length) =>
alpha = 2 / (length + 1)
sum = 0.0
sum := na(sum[1]) ? src77 : alpha * src77 + (1 - alpha) * nz(sum[1])
sum
// Step 2: T3 with adaptive length
e1 = pine_ema(src77, 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)
plotchar(ta.crossover(t3, t3[2]) or ta.crossunder(t3, t3[2]) ? t3 : na, "", "🞛", location.absolute, t3_col)
//@version=6
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("Swing Trading", title="Overall Trend Weighting", options=["Long Term", "Swing Trading", "Short Term"])
color_bull = input.color(#ecf405, title="Bull Color", inline="col")
color_bear = input.color(color.rgb(5, 29, 247), title="Bear Color", inline="col")
color_neutral = input.color(color.rgb(205, 2, 246), 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
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))
/////////////////
kombine edilmiş bir kod örneğidir.....
Yer İmleri