PHP Code:
// 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
indicator("My script", overlay = true)
import lastguru/DominantCycle/2 as d
ema(float source = close, float length = 9)=>
alpha = 2 / (length + 1)
var float smoothed = na
smoothed := alpha * source + (1 - alpha) * nz(smoothed[1])
source = input.source(close, "Source")
harmonic = input.int(1, "Length", 1)
length(source, harmonic)=>
cycle = math.round(d.mamaPeriod(source, 1, 2048))
var cycles = array.new<float>(1)
var count_cycles = array.new<int>(1)
if not array.includes(cycles, cycle)
array.push(cycles, cycle)
array.push(count_cycles, 1)
else
index = array.indexof(cycles, cycle)
array.set(count_cycles, index, array.get(count_cycles, index) + 1)
max_index = array.indexof(count_cycles, array.max(count_cycles))
max_cycle = array.get(cycles, max_index) * harmonic
length = length(source, harmonic)
aema = ema(source, length)
plot(aema, "1", color.white)
//////////////////////////
// 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
source22 = input.source(close, "Source")
alpha = input.float(0.01, "Alpha", 0.001, 1, 0.001)
style = input.string("TBES", "Style", ["BES","DBES","TBES"])
bes(source, alpha)=>
var float smoothed = na
smoothed := na(smoothed) ? source22 : alpha * source22 + (1 - alpha) * nz(smoothed[1])
tbes() =>
e1 = bes(source22, alpha)
e2 = bes(e1, alpha)
e3 = bes(e2, alpha)
tema = 3 * (e1 - e2) + e3
dbes()=>
e1 = bes(source22, alpha)
e2 = bes(e1, alpha)
dema = 2 * e1 - e2
ma()=>
switch style
"BES" => bes(source22, alpha)
"DBES" => dbes()
"TBES" => tbes()
plot(ma(), "2", color.orange)
/////////////////////////////////////////
// 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
// Define the triple exponential moving average function
tema(src, len) =>
// Compute the weights for each value in the moving average
weights = (len + 1) / 2 - math.abs(len - src)
// Calculate the triple exponential moving average
tema = 3 * ta.ema(src, len) - 3 * ta.ema(ta.ema(src, len), len) + ta.ema(ta.ema(ta.ema(src, len), len), len)
// Define the weighted moving average function
wma(src, weights, int len) =>
// Compute the weighted sum of the source data
weightedSum = math.sum(src * weights, len)
// Compute the sum of the weights
sumWeights = math.sum(weights, len)
// Divide the weighted sum by the sum of the weights to calculate the weighted average
weightedSum / sumWeights
cweema(src, len) =>
// Compute the weights for each value in the moving average
weights = (len + 1) / 2 - math.abs(len - src)
// Calculate the weighted moving average
wma(tema(src, len), weights, len)
source33 = input.source(close, 'Source')
length33 = input.int(100, "Length", 1)
plot(cweema(source33, length33))
////////////////////////////////////////
// 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(64, "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(false, "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)
////////////////////////////////////////////
denemek isteyenlere birleştirilmiş halinin kodu.....
Yer İmleri