CPR SSL
CPR SSL
new_bar(res) =>
ta.change(time(res)) != 0
new_period(condition, src) =>
result = 0.0
result := condition ? src : result[1]
result
one_day = 1000 * 60 * 60 * 24
new_day = daily_cpr > 0 and timenow - time < one_day * daily_cpr and new_bar('D')
dpp_ = new_period(new_day, dpp)
dtc_ = new_period(new_day, dtc)
dbc_ = new_period(new_day, dbc)
dR1_ = new_period(new_day, dR1)
dS1_ = new_period(new_day, dS1)
dR2_ = new_period(new_day, dR2)
dS2_ = new_period(new_day, dS2)
dR3_ = new_period(new_day, dR3)
dS3_ = new_period(new_day, dS3)
dPH_ = new_period(new_day, dPH)
dPL_ = new_period(new_day, dPL)
// ZigZag options:
bool show_real_pivots = input(defval=true, title='Show real zigzag pivots:')
// ||-------------------------------------------------------------------------||
// ||
// ||-------------------------------------------------------------------------||
// |{
f_zz(_percent) =>
if na(_is_direction_up)
_is_direction_up := true
_is_direction_up
if _is_direction_up
_ltrack := na
_ltime := time
if na(_htrack)
if high > high[1]
_htrack := high
_htime := time
_htime
else
_htrack := high[1]
_htime := time[1]
_htime
else
if high > _htrack
_htrack := high
_htime := time
_htime
if not _is_direction_up
_htrack := na
_htime := na
if na(_ltrack)
if low < low[1]
_ltrack := low
_ltime := time
_ltime
else
_ltrack := low[1]
_ltime := time[1]
_ltime
else
if low < _ltrack
_ltrack := low
_ltime := time
_ltime
// || |}---------------------------------------------------------------------<•
// |{
[price_a, is_up, reverse, _rl_time] = f_zz(percent)
alt_time = show_real_pivots and showAutoBS ? _rl_time : time
//𝗦𝗦𝗟 𝗛𝗬𝗕𝗥𝗜𝗗
//
tema(src, len) =>
ema1 = ta.ema(src, len)
ema2 = ta.ema(ema1, len)
ema3 = ta.ema(ema2, len)
3 * ema1 - 3 * ema2 + ema3
kidiv = input.int(defval=1, maxval=4, title='Kijun MOD Divider')
//----
//EDSMA
get2PoleSSF(src, length) =>
PI = 2 * math.asin(1)
arg = math.sqrt(2) * PI / length
a1 = math.exp(-arg)
b1 = 2 * a1 * math.cos(arg)
c2 = b1
c3 = -math.pow(a1, 2)
c1 = 1 - c2 - c3
ssf = 0.0
ssf := c1 * src + c2 * nz(ssf[1]) + c3 * nz(ssf[2])
ssf
arg = PI / length
a1 = math.exp(-arg)
b1 = 2 * a1 * math.cos(1.738 * arg)
c1 = math.pow(a1, 2)
coef2 = b1 + c1
coef3 = -(c1 + b1 * c1)
coef4 = math.pow(c1, 2)
coef1 = 1 - coef2 - coef3 - coef4
ssf = 0.0
ssf := coef1 * src + coef2 * nz(ssf[1]) + coef3 * nz(ssf[2]) + coef4 *
nz(ssf[3])
ssf
edsma = 0.0
edsma := alpha * src + (1 - alpha) * nz(edsma[1])
result := edsma
result
result
///SSL 1 and SX
emaHigh = ma(maType, high, len)
emaLow = ma(maType, low, len)
///EXIT
ExitHigh = ma(SSL3Type, high, len3)
ExitLow = ma(SSL3Type, low, len3)
//SZ VALUES
Hlv = int(na)
Hlv := close > emaHigh ? 1 : close < emaLow ? -1 : Hlv[1]
sslDown = Hlv < 0 ? emaHigh : emaLow
//SX VALUES
Hlv2 = int(na)
Hlv2 := close > maHigh ? 1 : close < maLow ? -1 : Hlv2[1]
sslDown2 = Hlv2 < 0 ? maHigh : maLow
//EXIT VALUES
Hlv3 = int(na)
Hlv3 := close > ExitHigh ? 1 : close < ExitLow ? -1 : Hlv3[1]
sslExit = Hlv3 < 0 ? ExitHigh : ExitLow
base_cross_Long = ta.crossover(close, sslExit)
base_cross_Short = ta.crossover(sslExit, close)
codiff = base_cross_Long ? 1 : base_cross_Short ? -1 : na
//COLORS
show_color_bar = input(title='Color Bars', defval=true)
color_bar = close > upperk ? #00E113 : close < lowerk ? #E16024 : color.gray
color_SZ = close > sslDown ? #00E113 : close < sslDown ? #E16024 : na
//PLOTS
plotarrow(showRainbow ? codiff : na, colorup=color.new(#00E113, 20),
colordown=color.new(#E16024, 20), title='Exit Arrows', maxheight=20, offset=0)
p1 = plot(showRainbow and show_Baseline ? BBMC : na, color=color_bar, linewidth=4,
title='MA Baseline', transp=0)
DownPlot = plot(showRainbow and show_SZ ? sslDown : na, title='SZ', linewidth=3,
color=color_SZ, transp=10)
barcolor(showRainbow and show_color_bar ? color_bar : na)
up_channel = plot(showRainbow and show_Baseline ? upperk : na, color=color_bar,
title='Baseline Upper Channel')
low_channel = plot(showRainbow and show_Baseline ? lowerk : na, color=color_bar,
title='Basiline Lower Channel')
fill(up_channel, low_channel, color=color_bar, transp=90)
//ALERTS
alertcondition(ta.crossover(close, sslDown), title='SSL Cross Alert', message='SZ
has crossed.')
alertcondition(ta.crossover(close, sslDown2), title='SX Cross Alert', message='SX
has crossed.')
alertcondition(sell_atr, title='Sell Continuation', message='Sell Continuation.')
alertcondition(buy_atr, title='Buy Continuation', message='Buy Continuation.')
alertcondition(ta.crossover(close, sslExit), title='Exit Sell', message='Exit Sell
Alert.')
alertcondition(ta.crossover(sslExit, close), title='Exit Buy', message='Exit Buy
Alert.')
alertcondition(ta.crossover(close, upperk), title='Baseline Buy Entry',
message='Base Buy Alert.')
alertcondition(ta.crossover(lowerk, close), title='Baseline Sell Entry',
message='Base Sell Alert.')