YingYang Algo
YingYang Algo
// Supertrend calculation
if barstate.isfirst
supertrend := lowerBand
else
if close > supertrend[1]
trend := 1
else if close < supertrend[1]
trend := -1
else
trend := trend[1]
if trend == 1
supertrend := math.max(lowerBand, supertrend[1])
else
supertrend := math.min(upperBand, supertrend[1])
// Plot Supertrend
plot(supertrend, color=color.blue, linewidth=2, title="Supertrend")
if (longSignal)
label.new(bar_index , y1, '▲', color=color.new(#018208,10),
style=label.style_label_up, textcolor=color.white, size=size.normal)
if (shortSignal)
label.new(bar_index , y2, '▼', color=color.new(#d12208,10),
style=label.style_label_down, textcolor=color.white, size=size.normal)
// Bar Coloring
// Trend Follower
smoothrng(x, t, m) =>
wper = t * 2 - 1
avrng = ta.ema(math.abs(x - x[1]), t)
smoothrng = ta.ema(avrng, wper) * m
smoothrng
smrng = smoothrng(close, 22, 6)
rngfilt(x, r) =>
rngfilt = x
rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r
: x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r
rngfilt
filt = rngfilt(close, smrng)
//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
upward = 0.0
upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1])
downward = 0.0
downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 :
nz(downward[1])
trailType = 'modified'
ATRPeriod = 13
ATRFactor = 4
smoothing = 8
// Bar Coloring
//{
// Wilders ma //
Wild_ma(_src, _malength) =>
_wild = 0.0
_wild := nz(_wild[1]) + (_src - nz(_wild[1])) / _malength
_wild
Up = norm_c - loss
Dn = norm_c + loss
TrendUp = Up
TrendDown = Dn
Trend = 1
ex = 0.0
ex := ta.crossover(Trend, 0) ? norm_h : ta.crossunder(Trend, 0) ? norm_l : Trend ==
1 ? math.max(ex[1], norm_h) : Trend == -1 ? math.min(ex[1], norm_l) : ex[1]
//}
barcolorfunction = upward > 0 and state == 'long' ? #05df09 : downward > 0 and
state == 'short' ? #ea0402 : #673ab7
barcolor(barcolorfunction)
//
halvingDay = 124
halvingHour = 06
halvingMinute = 22
f_format(_val) =>
(0 < _val and _val < 10 ? '0' : '') + str.tostring(_val, '##') + (_val == 0 ?
'0' : '')