PHP Code:
//@version=5
indicator("deneme", overlay = true, max_lines_count = 500, max_labels_count = 500, format=format.price)
////////////////////////////////////////
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © peacefulLizard50262
//@version=5
// Custom cosh function
cosh(float x) =>
(math.exp(x) + math.exp(-x)) / 2
// Custom acosh function
acosh(float x) =>
x < 1 ? na : math.log(x + math.sqrt(x * x - 1))
// Custom sinh function
sinh(float x) =>
(math.exp(x) - math.exp(-x)) / 2
// Custom asinh function
asinh(float x) =>
math.log(x + math.sqrt(x * x + 1))
// Custom inverse tangent function
atan(float x) =>
math.pi / 2 - math.atan(1 / x)
// Chebyshev Type I Moving Average
chebyshevI(float src, float len, float ripple) =>
a = 0.
b = 0.
g = 0.
chebyshev = 0.
a := cosh(1 / len * acosh(1 / (1 - ripple)))
b := sinh(1 / len * asinh(1 / ripple))
g := (a - b) / (a + b)
chebyshev := (1 - g) * src + g * nz(chebyshev[1])
chebyshev
// Chebyshev Type II Moving Average
chebyshevII(float src, float len, float ripple) =>
a = 0.
b = 0.
g = 0.
chebyshev = 0.
a := cosh(1 / len * acosh(1 / ripple))
b := sinh(1 / len * asinh(ripple))
g := (a - b) / (a + b)
chebyshev := (1 - g) * src + g * nz(chebyshev[1], src)
chebyshev
chebyshev(float src, float length, float ripple, bool style) =>
style ?
chebyshevI(src, length, ripple) :
chebyshevII(src, length, ripple)
source44 = input.source(hl2, "Source")
up_color = input.color(color.new(color.green, 20), "Up Color")
down_color = input.color(color.new(color.red, 20), "Down Color")
text_color = input.color(color.black, "Text Color")
mean_length = input.float(24, "Mean Length", 5, 1000, 0.5)
mean_ripple = input.float(0.5, "Mean Ripple", 0.01, 0.99, 0.01)
style44 = input.bool(false, "True Chebyshev I | False : Chebyshev II")
atr_style = input.bool(true, "True: |Open-Close| False: High-Low")
atr_length = input.float(64, "ATR Length", 6, 1000, 0.5)
atr_ripple = input.float(0.05, "Mean Ripple", 0.01, 0.99, 0.01)
multiplier = input.float(1.5, "Multiplier", 0.125, 10, 0.125)
alerts = input.bool(false, "Alerts")
labels = input.bool(true, "Labels")
atr = chebyshev(atr_style ? high - low : math.abs(open - close), atr_length, atr_ripple, style44)
mean = chebyshevI(source44, mean_length, mean_ripple)
var float offset = 0.0
var bool state = na
var float newOffset = 0.0
crossover = ta.crossover(source44, offset)
position = source44 > offset
crossunder = ta.crossunder(source44, offset)
prevOffset = nz(offset[1])
if crossover[2] and position[1] and position or (position and position[1] and position[2])
newOffset := mean - atr * multiplier
offset := newOffset < nz(prevOffset) or close[1] > nz(prevOffset) ? newOffset : nz(prevOffset)
state := true
if crossunder[2] and not position[1] and not position or (not position and not position[1] and not position[2])
newOffset := mean + atr * multiplier
offset := newOffset > nz(prevOffset) or close[1] < nz(prevOffset) ? newOffset : nz(prevOffset)
state := false
cross = ta.cross(close, offset)
down_trend = not state and not state[1]
up_trend = state and state[1]
colour = up_trend ? up_color : down_trend ? down_color : color.new(color.white, 100)
if up_trend and not up_trend[1] and labels
label.new(bar_index, offset, "Up Trend \n" + str.tostring(close), color = up_color, style = label.style_label_up, textcolor = text_color)
alert("Up Trend at " + str.tostring(close))
else
alert("Up Trend at " + str.tostring(close))
if down_trend and not down_trend[1] and labels
label.new(bar_index, offset, "Down Trend \n" + str.tostring(close), color = down_color, style = label.style_label_down, textcolor = text_color)
alert("Down Trend at " + str.tostring(close))
else
alert("Down Trend at " + str.tostring(close))
plot(offset, "Trend", colour, style = plot.style_stepline_diamond)
plotshape(cross, "Trend Is Getting Ready To Change", shape.xcross, location.belowbar, color = close > offset ? up_color : down_color)
////////////////////////////////////////////
/// Creator: Tim Tillson (T3 Moving Average)
// Author: @dg_factor [09.12.2021]
// UYARI :
// Geliştirme amaçlıdır. Risk yönetimi olmaksızın alım-satım stratejisi yerine ikame edilemez.
// AÇIKLAMALAR
// Orijinal hasaplamalara sadık kalınarak farklı derecelerde (1-5) binom açılımları uygulandı.
// EMA dahil, toplamda yedi farklı hareketli ortalama türü üzerinde çalışabilen dinamik bir yapı inşa edildi.
// Derece ve ortalama türü, opsiyonel birer parametre olarak kullanıcı tercihine sunuldu.
// Diğer detaylar en aşağıda.
//@version=5
// Inputs
src = close
length = input(title='Length', defval=20)
factor = input.float(title='Factor', defval=0.7, step=0.1)
degree = input.int(title='Degree', minval=1, maxval=5, defval=3, tooltip='1-5', group="DEGREE & TYPE")
ma_type = input.string(title="Type", defval="EMA", options=["EMA", "RMA", "EVMA", "GAUS", "HULLT", "MCGD", "TSF"], group="DEGREE & TYPE")
// MA Functions
// EVMA [Elastic Volume Weighted Moving Average]
f_evma(data, u1) =>
x = ta.sma(data, u1)
a = math.sum(volume, u1)
r = 0.0
r := na(r[1]) ? x : nz(r[1]) * (a - volume) / a + volume * data / a
//
// GAUS [Ehlers - Gaussian Filter]
f_gaus(data, u1) =>
a = (1 - math.cos(2 * math.pi / u1)) / (math.sqrt(2) - 1)
b = -a + math.sqrt(math.pow(a, 2) + 2 * a)
r = 0.0
r := na(r[1]) ? data : math.pow(b, 2) * data + 2 * (1 - b) * nz(r[1]) - math.pow(1 - b, 2) * nz(r[2])
//
// HULLT [Triple Hull Moving Average]
f_hullt(data, u1) =>
a = u1 < 3 ? 1 : u1 / 2
b = u1 < 3 ? 1 : u1 / 3
r = ta.wma(ta.wma(data, b) * 3 - ta.wma(data, a) - ta.wma(data, u1), u1)
//
// MCGD [McGinley Dynamic Moving Average]
f_mcgd(data, u1) =>
a = ta.ema(data, u1)
r = 0.0
r := na(r[1]) ? a : r[1] + (data - r[1]) / (u1 * math.pow(data / r[1], 4))
//
// TSF [Time Series Function]
f_tsf(data, u1) =>
2 * ta.linreg(data, u1, 0) - ta.linreg(data, u1, 1)
// MA Return
f_ma(data, u1) =>
ma_type == "EMA" ? ta.ema(data, u1) :
ma_type == "EVMA" ? f_evma(data, u1) :
ma_type == "GAUS" ? f_gaus(data, u1) :
ma_type == "HULLT" ? f_hullt(data, u1) :
ma_type == "MCGD" ? f_mcgd(data, u1) :
ma_type == "RMA" ? ta.rma(data, u1) :
ma_type == "TSF" ? f_tsf(data, u1) :
na
//
// Variables
x = factor
y = factor + 1
z = f_ma(src, length)
n = f_ma(z, length)
// Degreed Tillson MA Functions
d1(src, length) =>
a0 = f_ma(n, length)
a1 = f_ma(a0, length)
b0 = -1 * 1 * math.pow(x, 1) * math.pow(y, 0)
b1 = +1 * 1 * math.pow(x, 0) * math.pow(y, 1)
r = b0 * a1 + b1 * a0
//
d2(src, length) =>
a0 = f_ma(n, length)
a1 = f_ma(a0, length)
a2 = f_ma(a1, length)
b0 = +1 * 1 * math.pow(x, 2) * math.pow(y, 0)
b1 = -1 * 2 * math.pow(x, 1) * math.pow(y, 1)
b2 = +1 * 1 * math.pow(x, 0) * math.pow(y, 2)
r = b0 * a2 + b1 * a1 + b2 * a0
//
d3(src, length) =>
a0 = f_ma(n, length)
a1 = f_ma(a0, length)
a2 = f_ma(a1, length)
a3 = f_ma(a2, length)
b0 = -1 * 1 * math.pow(x, 3) * math.pow(y, 0)
b1 = +1 * 3 * math.pow(x, 2) * math.pow(y, 1)
b2 = -1 * 3 * math.pow(x, 1) * math.pow(y, 2)
b3 = +1 * 1 * math.pow(x, 0) * math.pow(y, 3)
r = b0 * a3 + b1 * a2 + b2 * a1 + b3 * a0
//
d4(src, length) =>
a0 = f_ma(n, length)
a1 = f_ma(a0, length)
a2 = f_ma(a1, length)
a3 = f_ma(a2, length)
a4 = f_ma(a3, length)
b0 = +1 * 1 * math.pow(x, 4) * math.pow(y, 0)
b1 = -1 * 4 * math.pow(x, 3) * math.pow(y, 1)
b2 = +1 * 6 * math.pow(x, 2) * math.pow(y, 2)
b3 = -1 * 4 * math.pow(x, 1) * math.pow(y, 3)
b4 = +1 * 1 * math.pow(x, 0) * math.pow(y, 4)
r = b0 * a4 + b1 * a3 + b2 * a2 + b3 * a1 + b4 * a0
//
d5(src, length) =>
a0 = f_ma(n, length)
a1 = f_ma(a0, length)
a2 = f_ma(a1, length)
a3 = f_ma(a2, length)
a4 = f_ma(a3, length)
a5 = f_ma(a4, length)
b0 = -1 * 1 * math.pow(x, 5) * math.pow(y, 0)
b1 = +1 * 5 * math.pow(x, 4) * math.pow(y, 1)
b2 = -1 * 10 * math.pow(x, 3) * math.pow(y, 2)
b3 = +1 * 10 * math.pow(x, 2) * math.pow(y, 3)
b4 = -1 * 5 * math.pow(x, 1) * math.pow(y, 4)
b5 = +1 * 1 * math.pow(x, 0) * math.pow(y, 5)
r = b0 * a5 + b1 * a4 + b2 * a3 + b3 * a2 + b4 * a1 + b5 * a0
//
// Out
out =
degree == 1 ? d1(src, length) :
degree == 2 ? d2(src, length) :
degree == 3 ? d3(src, length) :
degree == 4 ? d4(src, length) :
degree == 5 ? d5(src, length) :
na
//
// Print
plot(out, color=#3082a500, title='Tillson MA')
barcolor(out > out[1] ? #00bb00 : out < out[1] ? #bb0000 : #333333)
// Bitti
//plotshape(barstate.isfirst, title="@ dg_factor", color=#13172200, editable=false)
// DETAYLAR
// T3'teki "3" nedir?
// T3 Moving Average, iç içe kurgulanmış üssel hareketli ortalamaların üçüncü dereceden binom açılımı alınarak hesaplanır.
// T3 şeklinde adlandırılmasının nedeni budur.
// Ufak bir matematiksel müdahale ile farklı dereceler kodlanabilir, netekim bu indikatör yöntem olarak çarpanlara ayırma önermektedir.
// Ömer Hayyam'ın mevzuyla ne ilgisi var?
// Binom açılımı, Pascal Üçgeni olarak bilinen bir tamsayı dizisine dayanır.
// İsmi Pascal'la anılsa da, bu üçgensel sayı dizisinin ilk olarak Ömer Hayyam'ın hesaplamalarında tanımlandığı kabul edilir.
// Pascal üçgeninin kartezyen toplamları kullanılarak Fibonacci dizisini elde etmek de mümkündür.
// Yayılım örüntülerini açıklamadaki gücü bakımından Pascal Üçgeni sıkça kullanılan bir argümandır.
// Özetle finansal algoritmalar Hayyam'a çok şey borçludur.
// Ne işe yarayacak?
// Başıma bir iş gelmeyecekse;
// Trendi genellikle yakalar, ama terste bırakma ihtimali de yüksektir. Risk yönetimi bu yüzden gerekli.
// Farklı dereceler fiyat frekansını üretebilecek yöntemlere katkı sunabilir.
// Hatta ortalamaya ait önceki tepe ve diplerin yeni sinyal yönü için geçerli destek/direnç seviyeleri olarak çalıştığı da oluyor.
// Tabi herhangi bir işe yaramayabilir de :).
////////////////////////////////
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Baby_whale_to_moon
//@version=5
// BACKTEST DATE
Start_Time = input.time(defval=timestamp('01 January 2017 13:30 +0000'), title='Start_Time', group = " ################# BACKTEST DATE ################ " )
End_Time = input.time(defval=timestamp('30 April 2024 19:30 +0000'), title='End_Time', group = " ################# BACKTEST DATE ################ " )
// supertrend
atrPeriod = input(10, 'ATR Length', group = " ################# Supertrend ################ ")
factor77 = input(3, 'Factor', group = " ################# Supertrend ################ ")
time1 = input.string(title='Short Time Period', defval='07 1h', options=['01 1m','02 3m','03 5m', '04 15m', '05 30m', '06 45m', '07 1h', '08 2h', '09 3h', '10 4h', '11 1D', '12 1W' ], group = " ################# Supertrend ################ ",tooltip = "this timeframe is the value of our short-time supertrend indicator")
time2 = input.string(title='Long Time Period', defval='10 4h', options=[ '01 1m','02 3m','03 5m', '04 15m', '05 30m', '06 45m', '07 1h', '08 2h', '09 3h', '10 4h', '11 1D', '12 1W' ], group = " ################# Supertrend ################ ",tooltip = "this timeframe is the value of our long-time supertrend indicator")
res(Resolution) =>
if Resolution == '00 Current'
timeframe.period
else
if Resolution == '01 1m'
'1'
else
if Resolution == '02 3m'
'3'
else
if Resolution == '03 5m'
'5'
else
if Resolution == '04 15m'
'15'
else
if Resolution == '05 30m'
'30'
else
if Resolution == '06 45m'
'45'
else
if Resolution == '07 1h'
'60'
else
if Resolution == '08 2h'
'120'
else
if Resolution == '09 3h'
'180'
else
if Resolution == '10 4h'
'240'
else
if Resolution == '11 1D'
'1D'
else
if Resolution == '12 1W'
'1W'
else
if Resolution == '13 1M'
'1M'
// supertrend Long time period
[supertrend2, direction2] = request.security(syminfo.tickerid, res(time2), ta.supertrend(factor77, atrPeriod))
bodyMiddle4 = plot((open + close) / 2, display=display.none)
upTrend2 = plot(direction2 < 0 ? supertrend2 : na, 'seans up', color=color.new(#4caf4f, 100), style=plot.style_linebr, linewidth=2)
downTrend2 = plot(direction2 < 0 ? na : supertrend2, 'seans Down', color=color.new(#ff5252, 100), style=plot.style_linebr, linewidth=2)
// supertrend short time period
[supertrend1, direction1] = request.security(syminfo.tickerid, res(time1), ta.supertrend(factor77, atrPeriod))
bodyMiddle = plot((open + close) / 2, display=display.none)
upTrend = plot(direction1 < 0 ? supertrend1 : na, 'saat Up ', color=color.new(#ffeb3b, 100), style=plot.style_linebr)
downTrend = plot(direction1 < 0 ? na : supertrend1, 'saat Down ', color=color.new(#ff9900, 100), style=plot.style_linebr)
// Stochastic RSI
low_limit_stoch_rsi = input.float(title = 'Stoch Rsi Low Limit', step=0.5, defval=15, group = " ################# Stoch RSI ################ ", tooltip = "when Stock rsi value crossover Low Limit value we get Long")
up_limit_stoch_rsi = input.float(title = 'Stoch Rsi Up Limit', step=0.5, defval=85, group = " ################# Stoch RSI ################ ", tooltip = "when Stock rsi value crossunder Up Limit value we get Short")
stocrsi_back_length = input.int(20, 'Stoch Rsi retroactive length', minval=1, group = " ################# Stoch RSI ################ ", tooltip = "How many candles are left behind, even if there is a buy or sell signal, it will be valid now")
smoothK = input.int(3, 'Stochastic RSI K', minval=1, group = " ################# Stoch RSI ################ ")
lengthRSI = input.int(14, 'RSI Length', minval=1, group = " ################# Stoch RSI ################ ")
lengthStoch = input.int(14, 'Stochastic Length', minval=1, group = " ################# Stoch RSI ################ ")
src_rsi = input(close, title='RSI Source', group = " ################# Stoch RSI ################ ")
rsi1 = request.security(syminfo.tickerid, '240', ta.rsi(src_rsi, lengthRSI))
k = request.security(syminfo.tickerid, '240', ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK))
////////////////////////////////////////
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MUQWISHI
//@version=5
// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
// | INPUT |
// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
// SuperTrend
supAtr = input.int(10, "ATR Length", 1, group = "Supertrend", inline = "1")
factor88 = input.float(3.0, " Factor", group = "Supertrend", inline = "1")
pltChk = input.bool(true, "Show Supertrend Line?", group = "Supertrend", inline = "2")
upCol = input.color(color.green, " ", group = "Supertrend", inline = "2")
dnCol = input.color(color.red, "", group = "Supertrend", inline = "2")
// Table Style
tablePos = input.string("Top Right", "RunUp Statistics Table Location ",
["Hide", "Top Right" , "Middle Right" , "Bottom Right" ,
"Top Center", "Middle Center" , "Bottom Center",
"Top Left" , "Middle Left" , "Bottom Left" ], inline = "1", group = "Fibonacci Run-Up Historical Statistics Table")
tBgCol = input.color(#696969, "Title", inline = "2", group = "Fibonacci Run-Up Historical Statistics Table")
cBgCol = input.color(#A9A9A9, " Cell", inline = "2", group = "Fibonacci Run-Up Historical Statistics Table")
txtCol = input.color(#ffffff, " Text", inline = "2", group = "Fibonacci Run-Up Historical Statistics Table")
// Line Style
linExt = input.string("None Extend", "Lines ",
["Hide", "Right Extend", "Left Extend", "Both Extend", "None Extend"], group = "Line & Label Style", inline = "line")
linSty = input.string("________", "",
["________", "-----------", "..........."], group = "Line & Label Style", inline = "line")
linSiz = input.int(2, "", 1, tooltip = "Line Extend | Line Style | Line Size", group = "Line & Label Style", inline = "line")
// Label Style
lblPos = input.string("Right", "Labels", ["Hide", "Right"], group = "Line & Label Style", inline = "label")
lblSty = input.string("Percent", "",
["Percent", "Value", "Price", "Percent & Price", "Value & Price"], group = "Line & Label Style", inline = "label")
lblSiz = input.string("Small", "",
["Auto", "Huge", "Large", "Normal", "Small", "Tiny"], group = "Line & Label Style", inline = "label",
tooltip = "Label Position | Label Style | Label Size")
// Fibonacci
lastSet = input.bool(true, "Apply Fibonacci Levels to ONLY Last Supertrend Direction", group = "Fibonacci Levels")
confrim = input.bool(true, "Apply Fibonacci Levels After Confirmed Signal", group = "Fibonacci Levels")
bgTrans = input.int(85, "Background Transparency", 0, 100, group = "Fibonacci Levels")
lnTrans = input.int(50, "Line Transparency ", 0, 100, group = "Fibonacci Levels")
trndChk = input.bool(true, "Show Trend Line", group = "Fibonacci Levels", inline = "0")
trndCol = input.color(color.new(#64b5f6, 50), " ", group = "Fibonacci Levels", inline = "0")
shw01 = input.bool(true, "", group = "Fibonacci Levels", inline = "Level00")
val01 = input.float(0.0, "", group = "Fibonacci Levels", inline = "Level00")
col01 = input.color(#787b86, "", group = "Fibonacci Levels", inline = "Level00")
shw02 = input.bool(true, "", group = "Fibonacci Levels", inline = "Level00")
val02 = input.float(0.236, "", group = "Fibonacci Levels", inline = "Level00")
col02 = input.color(#f44336,"", group = "Fibonacci Levels", inline = "Level00")
shw03 = input.bool(true, "", group = "Fibonacci Levels", inline = "Level01")
val03 = input.float(0.382, "", group = "Fibonacci Levels", inline = "Level01")
col03 = input.color(#81c784, "", group = "Fibonacci Levels", inline = "Level01")
shw04 = input.bool(true, "", group = "Fibonacci Levels", inline = "Level01")
val04 = input.float(0.5, "", group = "Fibonacci Levels", inline = "Level01")
col04 = input.color(#4caf50, "", group = "Fibonacci Levels", inline = "Level01")
shw05 = input.bool(true, "", group = "Fibonacci Levels", inline = "Level02")
val05 = input.float(0.618, "", group = "Fibonacci Levels", inline = "Level02")
col05 = input.color(#009688, "", group = "Fibonacci Levels", inline = "Level02")
shw06 = input.bool(true, "", group = "Fibonacci Levels", inline = "Level02")
val06 = input.float(0.786, "", group = "Fibonacci Levels", inline = "Level02")
col06 = input.color(#009688, "", group = "Fibonacci Levels", inline = "Level02")
shw07 = input.bool(true, "", group = "Fibonacci Levels", inline = "Level03")
val07 = input.float(1.0, "", group = "Fibonacci Levels", inline = "Level03")
col07 = input.color(#64b5f6, "", group = "Fibonacci Levels", inline = "Level03")
shw08 = input.bool(true, "", group = "Fibonacci Levels", inline = "Level03")
val08 = input.float(1.618, "", group = "Fibonacci Levels", inline = "Level03")
col08 = input.color(#da7d31, "", group = "Fibonacci Levels", inline = "Level03")
shw09 = input.bool(true, "", group = "Fibonacci Levels", inline = "Level04")
val09 = input.float(2.1618, "", group = "Fibonacci Levels", inline = "Level04")
col09 = input.color(#81c784, "", group = "Fibonacci Levels", inline = "Level04")
shw10 = input.bool(true, "", group = "Fibonacci Levels", inline = "Level04")
val10 = input.float(3.618, "", group = "Fibonacci Levels", inline = "Level04")
col10 = input.color(#f44336, "", group = "Fibonacci Levels", inline = "Level04")
shw11 = input.bool(true, "", group = "Fibonacci Levels", inline = "Level05")
val11 = input.float(4.236, "", group = "Fibonacci Levels", inline = "Level05")
col11 = input.color(#809ef0, "", group = "Fibonacci Levels", inline = "Level05")
shw12 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level05")
val12 = input.float(1.272, "", group = "Fibonacci Levels", inline = "Level05")
col12 = input.color(#2962ff, "", group = "Fibonacci Levels", inline = "Level05")
shw13 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level06")
val13 = input.float(1.414, "", group = "Fibonacci Levels", inline = "Level06")
col13 = input.color(#e97527, "", group = "Fibonacci Levels", inline = "Level06")
shw14 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level06")
val14 = input.float(2.272, "", group = "Fibonacci Levels", inline = "Level06")
col14 = input.color(#f44336, "", group = "Fibonacci Levels", inline = "Level06")
shw15 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level07")
val15 = input.float(2.414, "", group = "Fibonacci Levels", inline = "Level07")
col15 = input.color(#9c27b0, "", group = "Fibonacci Levels", inline = "Level07")
shw16 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level07")
val16 = input.float(2.0, "", group = "Fibonacci Levels", inline = "Level07")
col16 = input.color(#b54df1, "", group = "Fibonacci Levels", inline = "Level07")
shw17 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level08")
val17 = input.float(3.0, "", group = "Fibonacci Levels", inline = "Level08")
col17 = input.color(#e91e63, "", group = "Fibonacci Levels", inline = "Level08")
shw18 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level08")
val18 = input.float(3.272, "", group = "Fibonacci Levels", inline = "Level08")
col18 = input.color(#81c784, "", group = "Fibonacci Levels", inline = "Level08")
shw19 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level09")
val19 = input.float(3.414, "", group = "Fibonacci Levels", inline = "Level09")
col19 = input.color(#f44336, "", group = "Fibonacci Levels", inline = "Level09")
shw20 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level09")
val20 = input.float(4.0, "", group = "Fibonacci Levels", inline = "Level09")
col20 = input.color(#81c784, "", group = "Fibonacci Levels", inline = "Level09")
shw21 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level10")
val21 = input.float(4.272, "", group = "Fibonacci Levels", inline = "Level10")
col21 = input.color(#009688, "", group = "Fibonacci Levels", inline = "Level10")
shw22 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level10")
val22 = input.float(4.414, "", group = "Fibonacci Levels", inline = "Level10")
col22 = input.color(#436d87, "", group = "Fibonacci Levels", inline = "Level10")
shw23 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level11")
val23 = input.float(4.618, "", group = "Fibonacci Levels", inline = "Level11")
col23 = input.color(#002396, "", group = "Fibonacci Levels", inline = "Level11")
shw24 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level11")
val24 = input.float(4.764, "", group = "Fibonacci Levels", inline = "Level11")
col24 = input.color(#006696, "", group = "Fibonacci Levels", inline = "Level11")
// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
// | CALCULATION |
// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
// ++++++++++++ Supertrend Indicator
[super, dirc] = ta.supertrend(factor88, supAtr)
var intlSupr = float(na), var rangSupr = float(na)
intlSupr := dirc != dirc[1] ? super : intlSupr
rangSupr := dirc != dirc[1] ? math.abs(super - super[1]) : rangSupr
// ++++++++++++ Calculate Fib Levels Function
fibLev(x) => intlSupr + (dirc == -1 ? rangSupr : - rangSupr) * x
levFib(x) => (x - intlSupr)/ (dirc == -1 ? rangSupr : - rangSupr)
// ++++++++++++ Entered Fibonacci Levels
var usVal = array.new<float>(na)
var usCol = array.new<color>(na)
usValFun(val, col, flg) =>
if flg
array.push(usVal, val)
array.push(usCol, col)
if barstate.isfirst
usValFun(val01, col01, shw01), usValFun(val02, col02, shw02), usValFun(val03, col03, shw03),
usValFun(val04, col04, shw04), usValFun(val05, col05, shw05), usValFun(val06, col06, shw06),
usValFun(val07, col07, shw07), usValFun(val08, col08, shw08), usValFun(val09, col09, shw09),
usValFun(val10, col10, shw10), usValFun(val11, col11, shw11), usValFun(val12, col12, shw12),
usValFun(val13, col13, shw13), usValFun(val14, col14, shw14), usValFun(val15, col15, shw15),
usValFun(val16, col16, shw16), usValFun(val17, col17, shw17), usValFun(val18, col18, shw18),
usValFun(val19, col19, shw19), usValFun(val20, col20, shw20), usValFun(val21, col21, shw21),
usValFun(val22, col22, shw22), usValFun(val23, col23, shw23), usValFun(val24, col24, shw24),
inVal = array.new<float>(na)
for i = 0 to array.size(usVal) - 1
array.push(inVal, fibLev(array.get(usVal, i)))
array.sort(inVal, dirc < 1 ? order.ascending : order.descending)
// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
// | DRAWING |
// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
// ++++++++++++ Get Line Style
styLine(s) =>
switch s
"..........." => line.style_dotted
"-----------" => line.style_dashed
"________" => line.style_solid
// ++++++++++++ Get Line Extention
extLine(l) =>
switch l
"Right Extend" => extend.right
"Left Extend" => extend.left
"Both Extend" => extend.both
=> extend.none
// ++++++++++++ Get Text Label
txtLab(x) =>
prt1 = str.contains(lblSty, "Percent") ? str.tostring(levFib(x) * 100, format.percent) + " ":
str.contains(lblSty, "Value" ) ? str.tostring(levFib(x) , "#.###") + " " : ""
prt2 = str.contains(lblSty, "Price") ? "(" + str.tostring(x, format.mintick) + ")" : ""
(dirc > 0 ? " \n" : "") + prt1 + prt2 + (dirc < 0 ? " \n" : "")
// ++++++++++++ Line Function
linFunc(x1, y, x2, col) =>
line.new(x1, y, x2, y, xloc.bar_index, extLine(linExt), color.new(col, lnTrans), styLine(linSty), linSiz)
// ++++++++++++ Label Function
labFun(y, col) =>
label.new(bar_index, y, txtLab(y), color = color.new(col, 100), size = str.lower(lblSiz),
textcolor = col, style = label.style_label_left, textalign = text.align_left)
// ++++++++++++ Drawing Levels
var runUp = array.new<float>(na) // Collect RunUp Fib
var linArr = array.new<line>(na)
var labArr = array.new<label>(na)
line trnd = na
var trndBr = 0
if array.size(inVal) > 0
if dirc != dirc[1]
if confrim ? barstate.isconfirmed : true
if lastSet
line.delete(trnd[trndBr])
while array.size(linArr) > 0
line.delete(array.shift(linArr))
while array.size(labArr) > 0
label.delete(array.shift(labArr))
else
if array.size(linArr) > 0
for i = 0 to array.size(linArr) - 1
line.set_extend(array.get(linArr, i), extend.none)
if array.size(labArr) > 0
for i = 0 to array.size(labArr) - 1
label.set_style(array.get(labArr, i), label.style_label_right)
array.clear(linArr)
array.clear(labArr)
array.unshift(runUp, levFib(close))
trndBr := 0
for i = 0 to array.size(inVal) - 1
if not na(array.get(inVal, i))
linCol = array.get(usCol, array.indexof(usVal, levFib(array.get(inVal, i))))
// Line
if linExt != "Hide"
array.push(linArr, linFunc(bar_index, array.get(inVal, i), bar_index, linCol))
if array.size(linArr) > 1
linefill.new(array.get(linArr, array.size(linArr)-2),
array.get(linArr, array.size(linArr)-1),
color.new(linCol, bgTrans))
if trndChk and trndBr == 0
trnd := line.new(bar_index, fibLev(1), bar_index, super,
xloc.bar_index, extend.none, trndCol, line.style_dashed, 1)
trndBr := 1
// Label
if lblPos != "Hide"
array.push(labArr, labFun(array.get(inVal, i), linCol))
else
if array.size(runUp) > 0
runUpLast = array.get(runUp, 0)
runUpSrc = dirc == -1 ? high : low
array.set(runUp, 0, runUpLast > levFib(runUpSrc) ? runUpLast : levFib(runUpSrc))
if array.size(linArr) > 0
for i = 0 to array.size(linArr) - 1
line.set_x2(array.get(linArr, i), bar_index)
if array.size(labArr) > 0
for i = 0 to array.size(labArr) - 1
label.set_x(array.get(labArr, i), bar_index)
if trndChk
line.set_x2(trnd[trndBr], bar_index)
trndBr += 1
// Supertrend Plots and Signals
//upTrend = plot(pltChk and dirc < 0 ? super : na, "Up Trend", upCol, 3, plot.style_linebr)
//downTrend = plot(pltChk and dirc > 0 ? super : na, "Down Trend", dnCol, 3, plot.style_linebr)
//plotshape(pltChk and dirc < 0 and dirc != dirc[1] ? super : na, "Long", shape.labelup, location.absolute, upCol, 0, "LONG", color.white, display = display.pane, size = size.small)
//plotshape(pltChk and dirc > 0 and dirc != dirc[1] ? super : na, "Short", shape.labeldown, location.absolute, dnCol, 0, "SHORT", color.white, display = display.pane, size = size.small)
// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
// | STATISTICS |
// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[1] Table
// Get Tbale Location & Size
locNsze(x) =>
y = str.split(str.lower(x), " ")
out = ""
for i = 0 to array.size(y) - 1
out := out + array.get(y, i)
if i != array.size(y) - 1
out := out + "_"
out
// Create Table
var tbl = table.new(tablePos != "Hide" ? locNsze(tablePos) : position.top_right, 2, array.size(usVal) + 8,
frame_width = 1, frame_color = color.new(tBgCol, 100), border_width = 1, border_color = color.new(tBgCol, 100))
perFib(x) =>
str.contains(lblSty, "Percent") ? str.tostring(x * 100, format.percent) : str.tostring(x, "#.###")
// Cell Function
cell(col, row, txt, color) =>
table.cell(tbl, col, row, text = txt, text_color = txtCol, bgcolor = color,
text_size = size.small)
// Stats Cells
applyCell(row, des, val) =>
cell(0, row , des, tBgCol), table.merge_cells(tbl, 0, row, 1, row)
cell(0, row +1, val, cBgCol), table.merge_cells(tbl, 0, row +1, 1, row +1)
if barstate.islast and array.size(runUp) > 0 and tablePos != "Hide"
fibVal = array.copy(usVal)
array.sort(fibVal, order.descending)
mtx = matrix.new<float>(array.size(fibVal), 2, 0)
matrix.add_col(mtx, 0, fibVal)
totRunUp = array.size(runUp)
for i = 0 to totRunUp - 1
runup = array.get(runUp, i)
for j = 0 to matrix.rows(mtx) - 1
if not(runup < matrix.get(mtx, j, 0))
matrix.set(mtx, j, 1, matrix.get(mtx, j, 1) + 1)
matrix.set(mtx, j, 2, math.round(matrix.get(mtx, j, 1)/totRunUp * 100, 2))
break
// Table
if array.size(fibVal) > 0
table.clear(tbl, 0, 0, 1, array.size(usVal)+7)
y = 0
cell(0, y, "Historical", tBgCol), table.merge_cells(tbl, 0, 0, 1, 0)
y += 1
cell(0, y, "Fibonacci", tBgCol)
cell(1, y, "RunUP (%)", tBgCol)
y += 1
for i = 0 to matrix.rows(mtx) - 1
fib = matrix.get(mtx, i, 0)
if fib >= 1
Col = array.get(usCol, array.indexof(usVal, fib))
cell(0, y, perFib(fib) , Col)
cell(1, y, str.tostring(matrix.get(mtx, i, 2), format.percent), Col)
y+=1
// Separator
table.cell(tbl, 0, y, height = 2), table.merge_cells(tbl, 0, y, 1, y),
y += 1
applyCell(y, "Number of Trades", str.tostring(array.size(runUp)))
y += 2
applyCell(y, "Median Fib RunUp", perFib(array.median(runUp)))
y += 2
applyCell(y, "Mean Fib RunUp", perFib(array.avg(runUp)))
////////////////////////
Yer İmleri