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)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Gudanin
//@version=5
//line variables
line1 = ta.ema(close, 14)
line2 = ta.ema(close, 27)
highrsi = ta.rsi(close,14) > 50
lowrsi = ta.rsi(close,14) < 50
line11 = ta.sma(close, 19)
line22 = ta.sma(close, 21)
highrsi1 = ta.rsi(close,14) >= 65
lowrsi1 = ta.rsi(close,14) <= 35
//Reversal logic
BuyP= line11 > line22 and highrsi1 and line1 > line2 and highrsi
var label up = na
var label down = na
var line l = na
var float first_close = na
var bool can_draw = false
var line l1 = na
var float first_close1 = na
var bool can_draw1 = false
//support and resistance line colors
color supportlinecolor = input.color(color.green, "Support line color")
color resistancelinecolor = input.color(color.red, "Resistance line color")
//label colors
color buylabelcolor = input.color(color.green, "Buy label color")
color selllabelcolor = input.color(color.red, "Sell label color")
//text colors
color buylabeltextcolor = input.color(color.white, "Buy label text color")
color selllabeltextcolor = input.color(color.white, "Sell label text color")
if(line11 > line22 and highrsi1 and line1 > line2 and highrsi)
first_close := close // Reset session high
can_draw := true // We are allowed to draw a line
l := line.new(bar_index-1, first_close, bar_index, first_close, color=resistancelinecolor, xloc = xloc.bar_index, extend = extend.both,width=2)
line.delete(l[1])
if(na(up)) //Does not exist, create one
up := label.new(bar_index, close, "fiyat dönüş \n direnç", color=selllabelcolor, yloc=yloc.abovebar, textcolor = selllabeltextcolor)
else
label.set_x(up, bar_index)
if(line11 < line22 and lowrsi and line1 < line2 and lowrsi )
first_close1 := open // Reset session high
can_draw1 := true // We are allowed to draw a line
l1 := line.new(bar_index-1, first_close1, bar_index, first_close1, color=supportlinecolor, xloc = xloc.bar_index, extend = extend.both,width=2)
line.delete(l1[1])
if(na(down)) //Does not exist, create one
down := label.new(bar_index, close, "fiyat dönüş \n destek", color=buylabelcolor, yloc=yloc.belowbar, style = label.style_label_up, textcolor = buylabeltextcolor)
else
label.set_x(down, bar_index)
//////////////////////////////////////////////////
kodun sadeleşmiş hali...
Yer İmleri