// Get components
source = close
smrng1 = smoothrng(source, 27, 1.5)
smrng2 = smoothrng(source, 55, sensitivity)
smrng = (smrng1 + smrng2) / 2
filt = rngfilt(source, smrng)
up = 0.0, up := filt > filt[1] ? nz(up[1]) + 1 : filt < filt[1] ? 0 :
nz(up[1])t1, wt2) and wt2 <= -53line = 'tl_2',group='Trendlines')
show_signals = input.bool(false, 'Show Signals', inline =
'tl_s',group='Trendlines')
broken_color_up_signal = input.color(color.yellow, '', inline =
'tl_s',group='Trendlines')
broken_color_down_signal = input.color(color.yellow, '', inline =
'tl_s',group='Trendlines')
maxLines = input.int(3, 'Max Broken', step = 1, minval = 1, maxval = 50,
inline = 'tl_2_B',group='Trendlines')
Source_tl = input.string('Close', 'Mitigation', options = ['Close',
'High/Low'], inline ='tl_2_B',group='Trendlines')
linestyle_broken_inp = input.string(defval = 'Dashed', title = "Style (Broken)",
options = ['Solid', 'Dotted', 'Dashed'],inline = "tl_2-1",group='Trendlines')
line_width_broken = input.int(1, 'Width', step = 1, minval = 1,maxval =
4,inline = "tl_2-1",group='Trendlines')
lineStyle_curr= linestyle_curr_inp == 'Solid' ? line.style_solid :
linestyle_curr_inp == 'Dotted' ? line.style_dotted : line.style_dashed
lineStyle_broken= linestyle_broken_inp == 'Solid' ? line.style_solid :
linestyle_broken_inp == 'Dotted' ? line.style_dotted : line.style_dashed
s_close = request.security(ticker.standard(syminfo.tickerid), timeframe.period,
close)
s_open = request.security(ticker.standard(syminfo.tickerid), timeframe.period,
open)
s_high = request.security(ticker.standard(syminfo.tickerid), timeframe.period,
high)
s_low = request.security(ticker.standard(syminfo.tickerid), timeframe.period, low)
var line[] pivot_high_array = array.new_line(),var line[] pivot_low_array =
array.new_line()
ph2_M = ta.pivothigh(s_high, pivLen_L, pivLen_R)
pl2_M = ta.pivotlow(s_low, pivLen_L, pivLen_R)
ph2 = ta.pivothigh(s_high, pivLen_L, pivLen_R)
pl2 = ta.pivotlow(s_low, pivLen_L, pivLen_R)
var float prev_close_H = na, var float curr_close_H = na
var float prev_close_L = na, var float curr_close_L = na
var int X_prev_low = na, var float Y_prev_low = na, var int X_curr_low = na, var
float Y_curr_low = na
var int X_curr_high = na, var float Y_curr_high = na, var int X_prev_high = na, var
float Y_prev_high = na
maxLines := hideCrossed ? 0 : maxLines
tl_array_size_up = maxLines/2ine.get_y1(x), line.get_x2(x),
line.get_y2(x), color = broken_color_down, style = lineStyle_broken, width =
line_width_broken,xloc = xloc.bar_index, extend = extendLine_B ? extend.right :
extend.none)
down_trend_line_broken:=true
Down_Trend_Lines.unshift(tl_line)
line.delete(x)
if Down_Trend_Lines.size() > (tl_array_size_up)
line.delete(Down_Trend_Lines.pop())
for x in pivot_high_array
var line [] Up_Trend_Lines = array.new_line(tl_array_size_dn)
var label [] Up_Trend_Labels = array.new_label(tl_array_size_dn)
src = Source_tl == 'Close' ? s_close : s_high
x.set_xy2(bar_index, SlopeOfLine(x))
if x.get_x2() - x.get_x1() > 300
x.delete()
if src > line.get_y2(x)
tl_line = line.new(line.get_x1(x), line.get_y1(x), line.get_x2(x),
line.get_y2(x), color = broken_color_up, style = lineStyle_broken, width =
line_width_broken,xloc = xloc.bar_index, extend = extendLine_B ? extend.right :
extend.none)
up_trend_line_broken:=true
Up_Trend_Lines.unshift(tl_line)
line.delete(x)
if Up_Trend_Lines.size() > (tl_array_size_dn)
line.delete(Up_Trend_Lines.pop())
plotshape(show_signals and up_trend_line_broken? low : na, title='Trendline Broken
Up', style=shape.xcross, textcolor=color.new(color.white, 0), size=size.small,
location=location.belowbar, color=broken_color_up_signal,display= display.all -
display.status_line, editable = false)
plotshape(show_signals and down_trend_line_broken? high : na, title='Trendline
Broken Down', style=shape.xcross, textcolor=color.new(color.white, 0),
size=size.small, location=location.abovebar,
color=broken_color_down_signal,display= display.all - display.status_line,
editable = false)
// MULTI-TIMEFRAME S/R
c_subtitle = color.new(color.black, 30)
s_subtitle = 'normal'
a_subtitle = 'center'
// get data on ticker based on chosen timeframe
src_c = request.security(syminfo.tickerid,timef,close, gaps = barmerge.gaps_off,
lookahead = barmerge.lookahead_off)
src_o = request.security(syminfo.tickerid,timef,open, gaps = barmerge.gaps_off,
lookahead = barmerge.lookahead_off)
f_resInMinutes() =>
_resInMinutes = timeframe.multiplier * (timeframe.isseconds ? 1. / 60 :
timeframe.isminutes ? 1. : timeframe.isdaily ? 60. * 24 : timeframe.isweekly ? 60.
* 24 * 7 : timeframe.ismonthly ? 60. * 24 * 30.4375 : na)
_resInMinutes
f_timefResInMinutes(_res) =>
request.security(syminfo.tickerid, _res, f_resInMinutes())
f_timefIsIntraday(_res) =>
[intraday, daily, weekly, monthly] = request.security(syminfo.tickerid, _res,
float src3 = math.max(close, open)
float src4 = math.min(close, open)
float ph = ta.pivothigh(src1, prd, prd)
float pl = ta.pivotlow(src2, prd, prd)
Lstyle = line.style_solid
timef_res = f_timefIsIntraday(timef)
timef_text = str.tostring(timef)
if str.tostring(timef) == ""
timef_text := na(timeframe.multiplier / 60) ? timeframe.period :
timeframe.multiplier < 60 ? timeframe.period + " M |" :
str.tostring(timeframe.multiplier / 60) + " H |"
else if timef_res == "Intraday"
timef_text := na(str.tonumber(timef) / 60) ? str.tostring(timef) :
str.tonumber(timef) < 60 ? str.tostring(timef) + " M |" :
str.tostring(str.tonumber(timef) / 60) + " H |"
else
timef_text := str.tostring(timef)
//calculate maximum S/R channel zone width
prdhighest = request.security(syminfo.tickerid, timef, ta.highest(300))
prdlowest = request.security(syminfo.tickerid, timef, ta.lowest(300))
cwidth = (prdhighest - prdlowest) * ChannelW / 100
var pivotvals = array.new_float(0)
if ph or pl
array.unshift(pivotvals, ph ? ph : pl)
if array.size(pivotvals) > maxnumpp // limit the array size
array.pop(pivotvals)
get_sr_vals(ind) =>
float lo = array.get(pivotvals, ind)
float hi = lo
int numpp = 0
for y = 0 to array.size(pivotvals) - 1 by 1
float cpp = array.get(pivotvals, y)
float wdth = cpp <= lo ? hi - cpp : cpp - lo
if wdth <= cwidth // fits the max channel width?
lo := cpp <= lo ? cpp : lo
hi := cpp > lo ? cpp : hi
numpp += 1
numpp
[hi, lo, numpp]
var sr_up_level = array.new_float(0)
var sr_dn_level = array.new_float(0)
sr_strength = array.new_float(0)
symVPosition = 'top'
symHPosition = 'left'
find_loc(strength) =>
ret = array.size(sr_strength)
for i = ret > 0 ? array.size(sr_strength) - 1 : na to 0 by 1
if strength <= array.get(sr_strength, i)
break
ret := i
c_bg = color.new(color.blue, 100)
// New Features
// User inputs
rsiOB = 68
rsiOS = 32
rsiOB2 = 70
rsiOS2 = 30
rsiOS3 = 24
// Big candle detector
lastCandleSize = math.abs(high[1] - low[1])
curCandleSize = math.abs(high - low)
bullishCandle = curCandleSize > lastCandleSize * 1.5 and close > open
bearishCandle = curCandleSize > lastCandleSize * 1.5 and close < open
// RSI
rsiValue = ta.rsi(close[1], 14)
// reversalbuysell = input(true, "[AI] Reversals", group="BUY & SELL
SIGNALS")
// reversalsignaltype = input.string("All", "Signal Type", ["All", "Bullish",
"Bearish"], group="BUY & SELL SIGNALS")
// reversalmode = input.string("Swing", "Mode", ["Scalp", "Swing",
"Accumulation"], group="BUY & SELL SIGNALS")
// Plot signal
// Scalp
// Trend Cloud
Curly_Fries = 74
Chicken_Sandwich = 144
ema_150 = ta.ema(close, Curly_Fries)
ema_250 = ta.ema(