z score ile sade tasarım....
PHP Code:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Steversteves
//@version=5
indicator("Z-Score", overlay=true, max_labels_count = 500)
lengthInput = input.int(50, "Length", minval = 2)
// Calculating High Z Score
a = ta.sma(close, lengthInput)
b = ta.stdev(close, lengthInput)
c = (close - a) / b
// Highest and Lowest
highz = ta.highest(c, lengthInput)
lowz = ta.lowest(c, lengthInput)
// Condition Alerts
var wait = 0
wait := wait + 1
if (c <= lowz) and (wait > 30)
wait := 10
label.new(x=bar_index, y=high, text="sat", size = size.tiny, color=color.rgb(247, 7, 7))
alert("sat tepe "+syminfo.ticker, alert.freq_once_per_bar)
if (c >= highz) and (wait > 30)
wait := 10
label.new(x=bar_index, y=high, text="al", size = size.tiny, color=color.rgb(66, 248, 11))
alert("al ralli "+syminfo.ticker, alert.freq_once_per_bar)
// Colors
color bear = color.new(color.orange, 0)
color bull = color.new(color.lime, 0)
bool overbought = c >= 2
bool oversold = c <= -2
brcolor = overbought ? bear : oversold ? bull : na
//barcolor(brcolor)
//////////////////////////
Length22 = input(50)
stddevs = input(1.69)
src22 = close
basis = ta.ema(src22, Length22)
zscore = (src22-basis)/ta.stdev(src22, Length22)
diff = math.abs(src22 - basis)
absZscore = math.abs(zscore)
bounds = diff / absZscore * stddevs
upper = basis + bounds
lower = basis - bounds
zscoreColor = zscore > 0.0 ? zscore >= zscore[1] ? zscore >= stddevs ? color.blue : color.green : color.new(color.green, 70) : zscore <= zscore[1] ? zscore <= -stddevs ? color.blue : color.red : color.new(color.red, 70)
plot(ta.ema(upper, 5), title="Upper ", linewidth=2)
//plot(ta.ema(basis, 5), title="Median", color=color.new(color.white, 60), linewidth=2)
plot(ta.ema(lower, 5), title="Lower ", linewidth=2)
https://www.tradingview.com/x/Yy4GFVZx/