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, ' Yatırım 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)
///////////////////////////////////
// 2. PSAR (Orta Yakınlık)
start2 = 0.01 // İsteğiniz ü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 Yakın)
start3 = 0. // İsteğiniz ü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)
///////////////////////////FİBO İLE SUPERTREND HESAPLAMASIDIR./////
/////////////////KAMA KULLANARAK BAR RENKLENDİRMEDİR.////////
//////////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.///////////////
Yer İmleri