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/
// AlgoAlpha
//@version=6
indicator("..", overlay = true, max_lines_count = 500, behind_chart = false)
var tb = table.new(position.bottom_center, 1, 1, bgcolor = #161114)
if barstate.isfirst
table.cell(tb, 0, 0, ' Yatrm tavsiyesi olarak KULLANILAMAZ.', text_size = size.normal, text_color = #f4f2ef)
//////////////////////////////////////////////////
//@version=6
start46 = input(0.01)
increment46 = input(0.1)
maximum46 = input(0.99, "Max Value")
out55 = ta.sar(start46, increment46, maximum46)
plot_color = close > out55 ? color.rgb(5, 182, 64) : close < out55 ? color.rgb(169, 7, 7) : na
show_header = input(false, title="Show header?", group='Table Settings')
dashboard_position = input.string("Top center", title="Position", options=["Top right", "Top center", "Middle right"], group='Table Settings')
text_size = input.string('Normal', title="Size", options=["Tiny", "Small", "Normal", "Large"], group='Table Settings')
text_color = input.color(color.rgb(11, 68, 224), title="Text color", group='Table Settings')
table_color = input.color(color.purple, title="Border color", group='Table Settings')
uptrend_indicator = "🔵"
downtrend_indicator = "🟠"
tf11 = input.timeframe("1", title="Timeframe 1")
tf22 = input.timeframe("3", title="Timeframe 2")
tf33 = input.timeframe("5", title="Timeframe 3")
tf4 = input.timeframe("10", title="Timeframe 4")
tf5 = input.timeframe("15", title="Timeframe 5")
tf6 = input.timeframe("30", title="Timeframe 6")
tf7 = input.timeframe("60", title="Timeframe 7")
tf8 = input.timeframe("120", title="Timeframe 8")
tf9 = input.timeframe("240", title="Timeframe 9")
tf10 = input.timeframe("D", title="Timeframe 10")
var table_position = dashboard_position == 'Top center' ? position.middle_left :
dashboard_position == 'Top center' ? position.middle_right :
dashboard_position == 'Middle right' ? position.middle_right : position.middle_right
var table_text_size = text_size == 'Normal' ? size.normal :
text_size == 'Small' ? size.small : size.normal
var t = table.new(position=table_position, columns=3, rows=20, frame_color=#cdcbcb, frame_width=5, border_color=table_color, border_width=1,bgcolor =color.rgb(21, 21, 21) )
get_trend_status(trend_value) =>
is_uptrend = close > trend_value
candle_now = is_uptrend ? uptrend_indicator : downtrend_indicator
candle_now
//--------------------------------------------------------------------------------------
sar_1 = request.security(syminfo.tickerid, tf11, ta.sar(start46, increment46, maximum46))
sar_2 = request.security(syminfo.tickerid, tf22, ta.sar(start46, increment46, maximum46))
sar_3 = request.security(syminfo.tickerid, tf33, ta.sar(start46, increment46, maximum46))
sar_4 = request.security(syminfo.tickerid, tf4, ta.sar(start46, increment46, maximum46))
sar_5 = request.security(syminfo.tickerid, tf5, ta.sar(start46, increment46, maximum46))
sar_6 = request.security(syminfo.tickerid, tf6, ta.sar(start46, increment46, maximum46))
sar_7 = request.security(syminfo.tickerid, tf7, ta.sar(start46, increment46, maximum46))
sar_8 = request.security(syminfo.tickerid, tf8, ta.sar(start46, increment46, maximum46))
sar_9 = request.security(syminfo.tickerid, tf9, ta.sar(start46, increment46, maximum46))
sar_10 = request.security(syminfo.tickerid, tf10, ta.sar(start46, increment46, maximum46))
trend_indicator_1 = get_trend_status(sar_1)
trend_indicator_2 = get_trend_status(sar_2)
trend_indicator_3 = get_trend_status(sar_3)
trend_indicator_4 = get_trend_status(sar_4)
trend_indicator_5 = get_trend_status(sar_5)
trend_indicator_6 = get_trend_status(sar_6)
trend_indicator_7 = get_trend_status(sar_7)
trend_indicator_8 = get_trend_status(sar_8)
trend_indicator_9 = get_trend_status(sar_9)
trend_indicator_10 = get_trend_status(sar_10)
if tf11 == "60"
tf11 := "1H"
if tf11 == "120"
tf11 := "2H"
if tf11 == "180"
tf11 := "3H"
if tf11 == "240"
tf11 := "4H"
if tf22 == "60"
tf22 := "1H"
if tf22 == "120"
tf22 := "2H"
if tf22 == "180"
tf22 := "3H"
if tf22 == "240"
tf22 := "4H"
if tf33 == "60"
tf33 := "1H"
if tf33 == "120"
tf33 := "2H"
if tf33 == "180"
tf33 := "3H"
if tf33 == "240"
tf33 := "4H"
if tf4 == "60"
tf4 := "1H"
if tf4 == "120"
tf4 := "2H"
if tf4 == "180"
tf4 := "3H"
if tf4 == "240"
tf4 := "4H"
if tf5 == "60"
tf5 := "1H"
if tf5 == "120"
tf5 := "2H"
if tf5 == "180"
tf5 := "3H"
if tf5 == "240"
tf5 := "4H"
if tf6 == "60"
tf6 := "1H"
if tf6 == "120"
tf6 := "2H"
if tf6 == "180"
tf6 := "3H"
if tf6 == "240"
tf6 := "4H"
if tf7 == "60"
tf7 := "1H"
if tf7 == "120"
tf7 := "2H"
if tf7 == "180"
tf7 := "3H"
if tf7 == "240"
tf7 := "4H"
if tf8 == "60"
tf8 := "1H"
if tf8 == "120"
tf8 := "2H"
if tf8 == "180"
tf8 := "3H"
if tf8 == "240"
tf8 := "4H"
if tf9 == "60"
tf9 := "1H"
if tf9 == "120"
tf9 := "2H"
if tf9 == "180"
tf9 := "3H"
if tf9 == "240"
tf9 := "4H"
if tf10 == "60"
tf10 := "1H"
if tf10 == "120"
tf10 := "2H"
if tf10 == "180"
tf10 := "3H"
if tf10 == "240"
tf10 := "4H"
//---------------------------------------------------------------------------------------------
// Update table with trend data
//---------------------------------------------------------------------------------------------
if (barstate.islast)
table.cell(t, 0, 1, tf11, text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 1, text="●", text_color=trend_indicator_1==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 1, str.tostring(sar_1, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 2, tf22, text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 2, text="●", text_color=trend_indicator_2==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 2, str.tostring(sar_2, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 3, tf33, text_color=color.white, text_size=table_text_size,bgcolor= color.rgb(21, 21, 21))
table.cell(t, 1, 3, text="●", text_color=trend_indicator_3==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 3, str.tostring(sar_3, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 4, tf4, text_color=color.white, text_size=table_text_size, bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 4, text="●", text_color=trend_indicator_4==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 4, str.tostring(sar_4, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 5, tf5, text_color=color.white, text_size=table_text_size, bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 5, text="●", text_color=trend_indicator_5==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 5, str.tostring(sar_5, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 6, tf6, text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 6, text="●", text_color=trend_indicator_6==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 6, str.tostring(sar_6, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 7, tf7, text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 7, text="●", text_color=trend_indicator_7==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 7, str.tostring(sar_7, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 8, tf8, text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 8, text="●", text_color=trend_indicator_8==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 8, str.tostring(sar_8, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 9, tf9, text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 9, text="●", text_color=trend_indicator_9==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 9, str.tostring(sar_9, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 10, tf10, text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 10, text="●", text_color=trend_indicator_10==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 10, str.tostring(sar_10, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t,0,0,"Periyot",text_color = color.white,bgcolor = color.rgb(21, 21, 21))
table.cell(t,1,0,"Trend",text_color = color.white,bgcolor = color.rgb(21, 21, 21))
table.cell(t,2,0,"Fiyat",text_color = color.white,bgcolor = color.rgb(21, 21, 21))
lookback = input.int(5, "Line Lookback Period", minval=1)
//////////////////////
//////////////
source = input.source(close, 'Source')
length = input.int(100, 'Period', 1)
displayExt = input.bool(true, "", inline = "ext")
extrapolate = input.int(1, 'Extrapolate', 0, inline = "ext")
degree = input.int(1, 'Degree', 1)
colorUp = input.color(color.rgb(255, 235, 59, 100), "", inline = "col")
colorDn = input.color(color.rgb(223, 64, 251, 100), "", inline = "col")
// --------------------------------------------------------------------------------------------------------------------}
// 📌 𝙄𝙉𝘿𝙄𝘾𝘼𝙏𝙊𝙍 𝘾𝘼𝙇𝘾𝙐𝙇𝘼𝙏𝙄𝙊𝙉𝙎
// --------------------------------------------------------------------------------------------------------------------{
polyreg(source, length, degree, extrapolate) =>
if barstate.islast
total = length + extrapolate
X_all = matrix.new<float>(total, degree + 1, 0.0)
for i = 0 to total - 1
for j = 0 to degree
matrix.set(X_all, i, j, math.pow(i, j))
// y (length 1), oldest→newest over the fit window
y = matrix.new<float>(length, 1, 0.0)
for i = 0 to length - 1
matrix.set(y, i, 0, source[length - 1 - i])
// X_train (first `length` rows of X_all)
X_tr = matrix.new<float>(length, degree + 1, 0.0)
for i = 0 to length - 1
for j = 0 to degree
matrix.set(X_tr, i, j, matrix.get(X_all, i, j))
// OLS via normal equations: (X'X)^(-1)b = X'y ⇒ b = (X'X)^(-1) X'y
Xt = matrix.transpose(X_tr) // X'
XtX = matrix.mult(Xt, X_tr) // (X'X)
Xty = matrix.mult(Xt, y) // X'y
XtX_inv = matrix.inv(XtX) // (X'X)^(-1)
b = matrix.mult(XtX_inv, Xty) // b = (X'X)^(-1) X'y
// Predictions for all rows (fit + extrap)
preds = matrix.mult(X_all, matrix.col(b,0))
preds
dist = ta.highest(ta.sma(high-low, length), length)*2
predictions = polyreg(source, length, degree, extrapolate)
drawLine(offset)=>
var lastPred = float(na)
var color = color(na)
var labels = array.new<label>()
var prevValue = float(na)
if barstate.islast
chartPoints = array.new<chart.point>()
chartPoints1 = array.new<chart.point>()
if labels.size() > 0
for l in labels
l.delete()
for [index, prediction] in predictions
Directioncolor = prediction > prevValue ? colorUp : colorDn
prevValue := prediction
predZone = index >= length
if offset == 0
marker = displayExt ? (predZone ? "" : "⬥") : (predZone ? "" : "⬥")
txtColor = predZone ? chart.fg_color : Directioncolor
labels.push(label.new(chart.point.from_index(index = bar_index + index - length + 1, price = prediction+offset), marker, color = color(na), textcolor = txtColor, style = label.style_label_center))
else if predZone and displayExt
chartPoints.push(value = chart.point.from_index(index = bar_index + index - length + 1, price = prediction+offset))
else if not predZone
chartPoints1.push(value = chart.point.from_index(index = bar_index + index - length + 1, price = prediction+offset))
if index == length+extrapolate-1 and displayExt
lastPred := prediction
if offset < 0
style = Directioncolor == colorUp ? label.style_label_lower_left : label.style_label_upper_left
label.delete(label.new(bar_index+extrapolate, lastPred-offset, str.tostring(lastPred-offset, "##,###,###.###"), style = style, textcolor = chart.fg_color, color = color(na))[1])
label.delete(label.new(bar_index+extrapolate, lastPred, str.tostring(lastPred, "##,###,###.###"), style = style, textcolor = chart.fg_color, color = color(na))[1])
label.delete(label.new(bar_index+extrapolate, lastPred+offset, str.tostring(lastPred+offset, "##,###,###.###"), style = style, textcolor = chart.fg_color, color = color(na))[1])
color := chart.fg_color
//polyline.delete(polyline.new(chartPoints, line_width = 1, line_style = line.style_dashed, line_color = color)[1])
//polyline.delete(polyline.new(chartPoints1, line_width = 1, line_style = line.style_solid, line_color = color)[1])
lastPred
// --------------------------------------------------------------------------------------------------------------------}
// 📌 𝙑𝙄𝙎𝙐𝘼𝙇𝙄𝙕𝘼𝙏𝙄𝙊𝙉
// --------------------------------------------------------------------------------------------------------------------{
drawLine(dist)
drawLine(0)
drawLine(-dist)
//////////////////////
showBreakLabels = input.bool(true, title = 'Show breakouts', group = 'Breakout Labels')
showVolumeBreakLabels = input.bool(true, title = 'Show Breakouts with high volume', group = 'Breakout Labels')
timeframe = input.timeframe('', title = 'Timeframe')
[Open, High, Low, Close, Volume] = request.security(syminfo.tickerid, timeframe, [open, high, low, close, volume])
start44 = input(0., title = 'start', group = 'Parabolic SAR')
increment44 = input(0.1, title = 'Increment', group = 'Parabolic SAR')
maximum44 = input(0.99, 'Max Value', group = 'Parabolic SAR')
out44 = request.security(syminfo.tickerid, timeframe, ta.sar(start44, increment44, maximum44), gaps = barmerge.gaps_off)
sarChange = ta.change(out44 < High)
var prevSar = out44
if sarChange
prevSar := out44[1] + out44[1] / 100 * 0.01
prevSar
crossOverLong = out44 < Close and Close > Open and (ta.crossover(Close, prevSar) or ta.crossover(Close[1], prevSar))
crossOverShort = out44 > Close and Close < Open and ta.crossunder(Close, prevSar)
plot(sarChange ? na : prevSar, style = plot.style_linebr, offset = -1, color = out44 < high ? color.new(#363a45, 100) : color.new(#363a45, 100), title = 'KRL', linewidth = 1)
plot(out44, 'SRZ', style = plot.style_steplinebr, color = color.yellow)
///////////////////////
start88 = input.float(0., 'Starting value')
inc88 = input.float(0.01, 'Increment')
max88 = input.float(0.09, 'Max Value')
width = input.float(5.00, 'Zone width')
atrs = ta.atr(100) * width
sarone = ta.sar(start88, inc88, max88)
sarzone = if close > sarone
sarone + atrs
else if close < sarone
sarone - atrs
sartwo = ta.sar(start88 / 2, inc88 / 2, max88 / 2)
p1 = plot(sarone, 'Kanal', color = close > sarone ? #2962ff00 : #e91e6200, style = plot.style_circles)
p3 = plot(sarzone, 'Kanal', color = close > sarone ? #2962ff00 : #e91e6200, style = plot.style_circles)
fill(p1, p3, color = close > sarone ? color.new(#2962ff, 80) : color.new(#e91e63, 80))
//plot(sartwo, 'Second SAR', color = close > sartwo ? color.new(#2962ff, 50) : color.new(#e91e63, 50), style = plot.style_linebr)
/////////////
// 2. PSAR (Orta Yaknlk)
start2 = 0.01 // steiniz zerine SIFIR
inc2 = input.float(0.1, title = '2. Art (Orta)', step = 0.01, group = '2. Orta PSAR')
max2 = input.float(0.99, title = '2. Limit', step = 0.05, group = '2. Orta PSAR')
// 3. PSAR (Nispeten Daha Uzak ama Standarttan Yakn)
start3 = 0. // steiniz zerine SIFIR
inc3 = input.float(0.1, title = '3. Art (Uzak)', step = 0.01, group = '3. Uzak PSAR')
max3 = input.float(0.99, title = '3. Limit', step = 0.05, group = '3. Uzak PSAR')
psar2 = ta.sar(start2, inc2, max2)
psar3 = ta.sar(start3, inc3, max3)
// Define colors for bullish and bearish conditions
GreenFluorescent = color.rgb(0, 255, 0)
RedFluorescent = color.rgb(255, 0, 0)
plot(psar2,"SRX", style = plot.style_stepline, linewidth = 1, color = close > psar2 ? GreenFluorescent : close < psar2 ? RedFluorescent : na)
plot(psar3,"SRY", style = plot.style_stepline, linewidth = 1, color = close > psar3 ? GreenFluorescent : close < psar3 ? RedFluorescent : na)
///////////////////////////FBO LE SUPERTREND HESAPLAMASIDIR./////
bool trend_on = input.bool(true, "", inline = "trend", group = "Trend")
float trend_ = input.float(5, "Trend", step = 0.01, inline = "trend", group = "Trend")
color col1 = input.color(color.rgb(235, 247, 6), "", inline = "trend", group = "Trend")
color col2 = input.color(#dc05f400, "",inline = "trend", group = "Trend")
int extend = input.int(15, "Extend", group = "Fibonacci", inline = "1"), fill_col = input.color(#2689901c, "", group = "Fibonacci", inline = "1")
float v_236 = input.float(0.236, "1")*100
float v_382 = input.float(0.382, "2")*100
float v_618 = input.float(0.618, "3")*100
float v_786 = input.float(0.786, "4")*100
// UDT
type data
line fib05 = na
line fib0 = na
line fib236 = na
line fib382 = na
line fib618 = na
line fib786 = na
line fib_ = na
line fib_di = na
label H = na
label L = na
label L0 = na
label L236 = na
label L382 = na
label L618 = na
label L786 = na
label L_ = na
var fib_d = data.new()
[supertrend, direction] = ta.supertrend(trend_, 25)
draw_fibb(trend)=>
var h = float(na)
var l = float(na)
var hi = int(na)
var li = int(na)
var val_0 = float(na)
var val_ = float(na)
atr = ta.atr(200)
// delete previous fibb
if trend != trend[1]
line.delete(fib_d.fib_)
line.delete(fib_d.fib0)
line.delete(fib_d.fib05)
line.delete(fib_d.fib_di)
line.delete(fib_d.fib236)
line.delete(fib_d.fib382)
line.delete(fib_d.fib618)
line.delete(fib_d.fib786)
label.delete(fib_d.H)
label.delete(fib_d.L)
label.delete(fib_d.L0)
label.delete(fib_d.L_)
label.delete(fib_d.L236)
label.delete(fib_d.L382)
label.delete(fib_d.L618)
label.delete(fib_d.L786)
// Creat Fib Lines at the bottom and the top
if trend != trend[1] and trend == -1
fib_d.fib_ := line.new(bar_index, low, bar_index, low, color = chart.fg_color, width = 2)
fib_d.fib0 := line.new(bar_index, high+atr*3, bar_index, high+atr*3, color = chart.fg_color, width = 2)
if trend != trend[1] and trend == 1
fib_d.fib_ := line.new(bar_index, high, bar_index, high, color = chart.fg_color, width = 2)
fib_d.fib0 := line.new(bar_index, low-atr*3, bar_index, low-atr*3, color = chart.fg_color, width = 2)
fib_d.fib_di := line.new(li, l, hi, h, style = line.style_dashed, color = chart.fg_color)
// Extend fibb lines during a trend
if trend == trend[1]
// Update High and low of Fibb
if low < fib_d.fib_.get_y1()
fib_d.fib_.set_y1(low)
fib_d.fib_.set_y2(low)
if high > fib_d.fib0.get_y1()
fib_d.fib0.set_y1(high)
fib_d.fib0.set_y2(high)
//
if trend == -1
val_0 := fib_d.fib0.get_y1()
val_ := fib_d.fib_.get_y1()
if trend == 1
val_0 := fib_d.fib_.get_y1()
val_ := fib_d.fib0.get_y1()
///////
// --------------------------------------------------------------------------------------------------------------------}
draw_fibb(direction)
color = trend_on ? (direction == 1 ? col2 : col1) : na
p19 = plot(supertrend, "Fibo-Trend", color = direction != direction[1] ? na : color, style = plot.style_linebr, linewidth = 2)
////////////////////////////////
// --- 1. VISUAL SETTINGS --- RANGE ALANINI BELRLEMEK N KULLANILAN KOD.////
i_boxColor = input.color(color.new(#e7e8ec, 95), 'Range Background', group = 'Visuals')
i_gpBullishColor = input.color(color.new(#03f70c, 50), 'Bullish GP Color', group = 'Visuals')
i_gpBearishColor = input.color(color.new(#fa1504, 50), 'Bearish GP Color', group = 'Visuals')
i_liqColor = input.color(color.new(#da04fb, 50), 'Liquidity Zones Color', group = 'Visuals')
i_lineColor = input.color(color.white, 'Boundary Line Color', group = 'Visuals')
i_whiteText = color.white
// Range Settings
i_autoFit = input.bool(true, 'Auto-Fit Box to last high and low', group = 'Range Settings')
i_lookback = input.int(100, 'Lookback Period', minval = 2, group = 'Range Settings')
i_offsetR = input.int(10, 'Box Offset Right', minval = 0, group = 'Range Settings')
// FVG Settings
//i_showFVG = input.bool(true, 'Show Fair Value Gaps (FVG)', group = 'FVG Settings')
//i_fvgLen = input.int(10, 'FVG Extension (Bars)', minval = 1, group = 'FVG Settings')
//i_bullFVGColor = input.color(color.new(#4caf4f, 100), 'Bullish FVG Color', group = 'FVG Settings')
//i_bearFVGColor = input.color(color.new(#f44336, 100), 'Bearish FVG Color', group = 'FVG Settings')
i_showLabels = input.bool(true, 'Show Price Lines & Labels', group = 'Visuals')
// --- 2. CORE CALCULATIONS ---
int hOff = ta.highestbars(high, i_lookback)
int lOff = ta.lowestbars(low, i_lookback)
float rHigh = high[-hOff]
float rLow = low[-lOff]
float rDiff = rHigh - rLow
// KORREKTUR: anchorBar nutzt nun die korrekten Identifier lOff und hOff
int anchorBar = i_autoFit ? bar_index + math.min(hOff, lOff) : bar_index - i_lookback
float bUp = rLow + rDiff * 0.382
float bLo = rLow + rDiff * 0.35
float sUp = rHigh - rDiff * 0.35
float sLo = rHigh - rDiff * 0.382
// --- 3. FVG LOGIC ---
//if i_showFVG
//if low > high[2]
//box.new(bar_index[1], low, bar_index + i_fvgLen, high[2], bgcolor = i_bullFVGColor, border_color = na)
//if high < low[2]
//box.new(bar_index[1], high, bar_index + i_fvgLen, low[2], bgcolor = i_bearFVGColor, border_color = na)
// --- 4. VISUALS (BOXES) ---
var box b_Range = box.new(na, na, na, na, xloc = xloc.bar_index, bgcolor = i_boxColor, border_color = color.fuchsia)
var box b_Bullish = box.new(na, na, na, na, xloc = xloc.bar_index, bgcolor = i_gpBullishColor, border_color = na, text = '', text_color = color.white, text_size = size.small)
var box b_Bearish = box.new(na, na, na, na, xloc = xloc.bar_index, bgcolor = i_gpBearishColor, border_color = na, text = '', text_color = color.white, text_size = size.small)
var box b_LiqTop = box.new(na, na, na, na, xloc = xloc.bar_index, bgcolor = i_liqColor, border_color = na, text = ' ', text_color = i_whiteText, text_size = size.small)
var box b_LiqBot = box.new(na, na, na, na, xloc = xloc.bar_index, bgcolor = i_liqColor, border_color = na, text = '', text_color = i_whiteText, text_size = size.small)
var array<line> l_levels = array.new_line()
var array<label> lb_prices = array.new_label()
if barstate.isfirst
for i = 0 to 7 by 1
array.push(l_levels, line.new(na, na, na, na, xloc = xloc.bar_index, color = i_lineColor))
array.push(lb_prices, label.new(na, na, '', xloc = xloc.bar_index, color = color.new(color.black, 100), textcolor = i_lineColor, size = size.normal, style = label.style_label_left))
if barstate.islast
int rightBar = bar_index + i_offsetR
box.set_lefttop(b_Range, anchorBar, rHigh)
box.set_rightbottom(b_Range, rightBar, rLow)
box.set_lefttop(b_Bullish, anchorBar, bUp)
box.set_rightbottom(b_Bullish, rightBar, bLo)
box.set_lefttop(b_Bearish, anchorBar, sUp)
box.set_rightbottom(b_Bearish, rightBar, sLo)
box.set_lefttop(b_LiqTop, anchorBar, rHigh)
box.set_rightbottom(b_LiqTop, rightBar, rHigh - rDiff * 0.05)
box.set_lefttop(b_LiqBot, anchorBar, rLow + rDiff * 0.05)
box.set_rightbottom(b_LiqBot, rightBar, rLow)
if i_showLabels
array<float> p_vals = array.from(rHigh, rHigh - rDiff * 0.05, sUp, sLo, bUp, bLo, rLow + rDiff * 0.05, rLow)
for i = 0 to 7 by 1
float v = array.get(p_vals, i)
//line.set_xy1(array.get(l_levels, i), anchorBar, v)
//line.set_xy2(array.get(l_levels, i), rightBar, v)
//label.set_xy(array.get(lb_prices, i), rightBar, v)
//label.set_text(array.get(lb_prices, i), ' ' + str.tostring(v, format.mintick))
// --- 5. SIGNAL LOGIC ---
bool sfpShort = high > rHigh and close < rHigh
bool sfpLong = low < rLow and close > rLow
var bool tBear = false
var bool tBull = false
if high >= sLo and low <= sUp
tBear := true
tBear
if low <= bUp and high >= bLo
tBull := true
tBull
bool pL = close[2] < open[2] and close[1] > open[1] and close > high[1]
bool pS = close[2] > open[2] and close[1] < open[1] and close < low[1]
bool signalLongOnly = tBull and pL
bool signalShortOnly = tBear and pS
if signalShortOnly or tBear and high > rHigh
tBear := false
tBear
if signalLongOnly or tBull and low < rLow
tBull := false
tBull
//BU KODUN SONUDUR./////////////////////
/////////////////KAMA KULLANARAK BAR RENKLENDRMEDR.////////
//////////BEYAZ LONG, KIRMIZI LONG KAPA, TURKUAZ SHORT, SARI SHORT KAPA.////////
// KAMA PARAMETERS
// ============================================================================
kama1_length = input.int(2, 'KAMA 1 Length', minval = 1, group = 'KAMA Settings')
kama1_fast = input.int(1, 'KAMA 1 Fast Length', minval = 1, group = 'KAMA Settings')
kama1_slow = input.int(3, 'KAMA 1 Slow Length', minval = 1, group = 'KAMA Settings')
kama2_length = input.int(3, 'KAMA 2 Length', minval = 1, group = 'KAMA Settings')
kama2_fast = input.int(2, 'KAMA 2 Fast Length', minval = 1, group = 'KAMA Settings')
kama2_slow = input.int(4, 'KAMA 2 Slow Length', minval = 1, group = 'KAMA Settings')
kama3_length = input.int(4, 'KAMA 3 Length', minval = 1, group = 'KAMA Settings')
kama3_fast = input.int(3, 'KAMA 3 Fast Length', minval = 1, group = 'KAMA Settings')
kama3_slow = input.int(5, 'KAMA 3 Slow Length', minval = 1, group = 'KAMA Settings')
kama4_length = input.int(5, 'KAMA 4 Length', minval = 1, group = 'KAMA Settings')
kama4_fast = input.int(4, 'KAMA 4 Fast Length', minval = 1, group = 'KAMA Settings')
kama4_slow = input.int(6, 'KAMA 4 Slow Length', minval = 1, group = 'KAMA Settings')
kama5_length = input.int(6, 'KAMA 5 Length', minval = 1, group = 'KAMA Settings')
kama5_fast = input.int(7, 'KAMA 5 Fast Length', minval = 1, group = 'KAMA Settings')
kama5_slow = input.int(8, 'KAMA 5 Slow Length', minval = 1, group = 'KAMA Settings')
src874 = input.source(close, 'Source', group = 'KAMA Settings')
// ============================================================================
// TREND COLORING PARAMETERS
// ============================================================================
color color_bearish_price_state = input.color(color.rgb(2, 243, 251, 30), 'Bearish Trend', group = 'Colors')
color color_bullish_price_state = input.color(color.rgb(241, 247, 248, 30), 'Bullish Trend', group = 'Colors')
color color_bullish_resistance_state = input.color(color.rgb(243, 3, 3, 30), 'Bullish Resistance', group = 'Colors')
color color_bearish_support_state = input.color(color.rgb(226, 247, 2, 30), 'Bearish Support', group = 'Colors')
float atr_multiplier_gray = input.float(14, 'ATR Multiplier (Gray Zone)', minval = 0.1, group = 'Ribbon Settings')
float atr_multiplier_yellow = input.float(14, 'ATR Multiplier (Yellow Zone)', minval = 0.1, group = 'Ribbon Settings')
// ============================================================================
// KAMA CALCULATION FUNCTION
// ============================================================================
f_kama(float src874, int length, int fastLength, int slowLength) =>
mom = math.abs(ta.change(src874, length))
volatility = math.sum(math.abs(ta.change(src874)), length)
er = volatility != 0 ? mom / volatility : 0
fastAlpha = 2 / (fastLength + 1)
slowAlpha = 2 / (slowLength + 1)
alpha = math.pow(er * (fastAlpha - slowAlpha) + slowAlpha, 2)
var float kama = na
kama := alpha * src874 + (1 - alpha) * nz(kama[1], src874)
kama
// ============================================================================
// CALCULATE ALL KAMAS
// ============================================================================
float kama1 = f_kama(src874, kama1_length, kama1_fast, kama1_slow)
float kama2 = f_kama(src874, kama2_length, kama2_fast, kama2_slow)
float kama3 = f_kama(src874, kama3_length, kama3_fast, kama3_slow)
float kama4 = f_kama(src874, kama4_length, kama4_fast, kama4_slow)
float kama5 = f_kama(src874, kama5_length, kama5_fast, kama5_slow)
// ============================================================================
// KAMA STACK RIBBON LOGIC (Replaces SMA Stack)
// ============================================================================
bool is_bullish_stack = kama1 > kama2 and kama2 > kama3 and kama3 > kama4 and kama4 > kama5
bool is_bearish_stack = kama1 < kama2 and kama2 < kama3 and kama3 < kama4 and kama4 < kama5
float atr_gray = ta.atr(14) * atr_multiplier_gray
float atr_yellow = ta.atr(14) * atr_multiplier_yellow
float kama_spread = math.abs(kama1 - kama5)
bool is_narrowing_gray = not is_bullish_stack and not is_bearish_stack and kama_spread < atr_gray
bool is_narrowing_yellow = not is_bullish_stack and not is_bearish_stack and kama_spread < atr_yellow
var bool was_bullish_stack = false
var bool was_bearish_stack = false
was_bullish_stack := is_bullish_stack ? true : is_bearish_stack ? false : was_bullish_stack
was_bearish_stack := is_bearish_stack ? true : is_bullish_stack ? false : was_bearish_stack
// ============================================================================
color kama_ribbon_color = is_bearish_stack ? color_bearish_price_state : is_narrowing_yellow and not was_bullish_stack ? color_bearish_support_state : is_narrowing_gray and was_bullish_stack ? color_bullish_resistance_state : is_bullish_stack ? color_bullish_price_state : na
// ============================================================================
plotcandle(open, high, low, close, color = kama_ribbon_color, wickcolor = kama_ribbon_color, bordercolor = kama_ribbon_color, title = 'BAR')
////////////////BU KODUN SONUDUR.///////////////
// BAR BOYUNA GRE SNYAL RETMEDR.///////
isClosed = barstate.isconfirmed
// Your raw retracement rules
bullRaw = isClosed and close[1] < open[1] and close < open and close < low[1]
bearRaw = isClosed and close[1] > open[1] and close > open and close > high[1]
// Small wick-based spacing
spaceUp = (high - close) * 0.35
spaceDown = (open - low) * 0.35
// Colors
brightRed = color.rgb(255, 0, 0)
brightGreen = color.rgb(0, 255, 0)
// Wave locks
var bool bullWaveLocked = false
var bool bearWaveLocked = false
// Reset locks when opposite candle prints
if isClosed and close > open
bullWaveLocked := false
bullWaveLocked
if isClosed and close < open
bearWaveLocked := false
bearWaveLocked
// BEARISH WAVE (Red)
if bullRaw and not bullWaveLocked
label.new(bar_index - 1, high[1] + (high[1] - close[1]) * 0.35, 'L', style = label.style_none, textcolor = brightRed, size = size.large)
label.new(bar_index, high + spaceUp, 'o', style = label.style_none, textcolor = brightRed, size = size.large)
bullWaveLocked := true
bullWaveLocked
// BULLISH WAVE (Green)
if bearRaw and not bearWaveLocked
label.new(bar_index - 1, low[1] - (open[1] - low[1]) * 0.35, 'L', style = label.style_none, textcolor = brightGreen, size = size.large)
label.new(bar_index, low - spaceDown, 'o', style = label.style_none, textcolor = brightGreen, size = size.large)
bearWaveLocked := true
bearWaveLocked
/////////////////////BU KODUN SONUDUR.///////////
////////// TREND TAKB N KULLANILAN KOD.////////
var string vanity_group = "Visual Settings"
magic_wand_toggle = input.bool(true, "Show Active CISD Level (Plot)", group=vanity_group)
drama_filter = input.string("Both", "Triggered CISD Display", options=["Both", "Bullish Only", "Bearish Only", "None"], group=vanity_group)
amnesia_mode = input.bool(false, "Limit Displayed Historical Lines", group=vanity_group)
short_term_memory = input.int(10, "Max Lines to Show", minval=1, group=vanity_group)
yell_at_me = input.bool(true, "Show Labels", group=vanity_group)
girth_units = input.int(1, "Line Width", minval=1, group=vanity_group)
scream_volume = input.string(size.normal, "Label Size", options=[size.tiny, size.small, size.normal, size.large], group=vanity_group)
hipster_font_toggle = input.string("Default", "Font Family", options=["Default", "Monospace"], group=vanity_group)
fashion_choice = input.string("Solid", "Triggered Line Style", options=["Solid", "Dashed", "Dotted"], group=vanity_group)
crayon_box = "Colors"
shrek_mode = input.color(color.new(color.lime, 0), "Bullish CISD", group=crayon_box)
blood_bath = input.color(color.new(color.fuchsia, 0), "Bearish CISD", group=crayon_box)
nerd_stats = "Debug"
paranoia_switch = input.bool(false, "Debug: Show Extreme Tracking", group=nerd_stats)
gossip_column = "HTF Trend Panel"
stalker_mode = input.bool(true, "Show Multi-Timeframe Table", group=gossip_column)
feng_shui = input.string("Bottom Right", "Table Position", options=["Top Right", "Middle Right", "Bottom Right", "Bottom Left"], group=gossip_column)
eye_test = input.string("Small", "Table Size", options=["Tiny", "Small", "Normal", "Large"], group=gossip_column)
// ---------------------------------------------------------
var string fancy_typeface = hipster_font_toggle == "Monospace" ? font.family_monospace : font.family_default
decode_fashion_statement(outfit) =>
switch outfit
"Solid" => line.style_solid
"Dashed" => line.style_dashed
=> line.style_dotted
chosen_style = decode_fashion_statement(fashion_choice)
var int vibes = 0
var float bagholder_entry = na
var int time_machine_setting = na
var float pain_threshold = na
var label sticky_note_of_shame = na
var array<line> graveyard_of_hopes = array.new<line>()
var array<label> choir_of_screams = array.new<label>()
consult_the_crystal_ball(int bias) =>
int temporal_shift = 0
float ancient_price = open
for i = 0 to 500
int candle_attitude = close[i] > open[i] ? 1 : close[i] < open[i] ? -1 : 0
if candle_attitude == 0
continue
bool mood_match = candle_attitude == bias
if not mood_match
break
temporal_shift := i
ancient_price := open[i]
[ancient_price, bar_index - temporal_shift]
archaeologist_jones(int bias) =>
int i = 1
bool artifact_found = false
int dig_site_idx = 0
float artifact_value = na
for j = 1 to 500
i := j
int candle_attitude = close[i] > open[i] ? 1 : close[i] < open[i] ? -1 : 0
if candle_attitude == 0
continue
bool is_correct_era = candle_attitude == bias
if not artifact_found
if is_correct_era
artifact_found := true
dig_site_idx := i
artifact_value := open[i]
else
if not is_correct_era
break
dig_site_idx := i
artifact_value := open[i]
[artifact_value, bar_index - dig_site_idx]
if vibes == 0 and bar_index > 10
int first_impression = close > open ? 1 : close < open ? -1 : 0
if first_impression == 0
for k = 1 to 50
first_impression := close[k] > open[k] ? 1 : close[k] < open[k] ? -1 : 0
if first_impression != 0
break
if first_impression != 0
vibes := first_impression
[origin_price, origin_time] = consult_the_crystal_ball(first_impression)
bagholder_entry := origin_price
time_machine_setting := origin_time
pain_threshold := first_impression == 1 ? high : low
int candle_personality = close > open ? 1 : close < open ? -1 : 0
float fresh_hopium = na
int fresh_timestamp = na
if vibes == 1
if high > pain_threshold
pain_threshold := high
if candle_personality == 1
[p_price, p_idx] = consult_the_crystal_ball(1)
fresh_hopium := p_price
fresh_timestamp := p_idx
else
[p_price, p_idx] = archaeologist_jones(1)
fresh_hopium := p_price
fresh_timestamp := p_idx
bagholder_entry := fresh_hopium
time_machine_setting := fresh_timestamp
else if vibes == -1
if low < pain_threshold
pain_threshold := low
if candle_personality == -1
[p_price, p_idx] = consult_the_crystal_ball(-1)
fresh_hopium := p_price
fresh_timestamp := p_idx
else
[p_price, p_idx] = archaeologist_jones(-1)
fresh_hopium := p_price
fresh_timestamp := p_idx
bagholder_entry := fresh_hopium
time_machine_setting := fresh_timestamp
bool shorts_squeezed = vibes == -1 and close > bagholder_entry
bool longs_rekt = vibes == 1 and close < bagholder_entry
if shorts_squeezed or longs_rekt
bool should_i_paint_it = false
if drama_filter == "Both"
should_i_paint_it := true
else if drama_filter == "Bullish Only"
should_i_paint_it := shorts_squeezed
else if drama_filter == "Bearish Only"
should_i_paint_it := longs_rekt
if should_i_paint_it
color mood_ring = shorts_squeezed ? shrek_mode : blood_bath
line tragedy_line = line.new(time_machine_setting, bagholder_entry, bar_index, bagholder_entry, color=mood_ring, width=girth_units, style=chosen_style)
array.push(graveyard_of_hopes, tragedy_line)
label loud_noise = na
//if yell_at_me
//int middle_of_nowhere = math.round((time_machine_setting + bar_index) / 2)
//string gibberish = shorts_squeezed ? "+ALL" : "-SAT"
//color ink_color = shorts_squeezed ? shrek_mode : blood_bath
//loud_noise := label.new(middle_of_nowhere, bagholder_entry, gibberish, style=shorts_squeezed ? label.style_label_down : label.style_label_up, color=color.new(#000000, 100), textcolor=ink_color, size=scream_volume, text_font_family = fancy_typeface)
array.push(choir_of_screams, loud_noise)
int new_emotional_state = shorts_squeezed ? 1 : -1
vibes := new_emotional_state
[reset_price, reset_time] = consult_the_crystal_ball(new_emotional_state)
bagholder_entry := reset_price
time_machine_setting := reset_time
pain_threshold := new_emotional_state == 1 ? high : low
color active_crayon = vibes == 1 ? shrek_mode : blood_bath
plot(magic_wand_toggle ? bagholder_entry : na, "Trend", color=active_crayon, linewidth=girth_units, style=plot.style_stepline)
//////////////////////BU KODUN SONUDUR.///////////////////
Yer mleri