// 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 <= -53
alert07 = [Link](wt1, wt2) and wt2 >= 53
alert09 = rsiOb or rsiOs
alert10 = bear
alerts(sym) =>
if alert02 or alert03 or alert04 or alert06 or alert07 or alert10
alert_text = alert02 ? "Buy Signal PunkAlgo" : alert03 ? "Strong Buy Signal
PunkAlgo" : alert04 ? "Strong Sell Signal PunkAlgo" : alert06 ? "Mild Buy Signal
PunkAlgo" : alert07 ? "Mild Sell Signal PunkAlgo" : "Sell Signal PunkAlgo"
alert(alert_text, alert.freq_once_per_bar_close)
alerts([Link])
alertcondition(alert02, "Buy Signal", "Buy Signal EzAlgo")
alertcondition(alert03, "Divergence Buy Alert", "Strong Buy Signal EzAlgo,
TimeFrame={{interval}}")
alertcondition(alert04, "Divergence Sell Alert", "Strong Sell Signal EzAlgo,
TimeFrame={{interval}}")
alertcondition(alert05, "Either Buy or Sell Signal", "EzAlgo Signal")
alertcondition(alert06, "Mild Buy Alert", "Mild Buy Signal EzAlgo,
TimeFrame={{interval}}")
alertcondition(alert07, "Mild Sell Alert", "Mild Sell Signal EzAlgo,
TimeFrame={{interval}}")
alertcondition(alert09, "Reversal Signal", "Reversal Signal")
alertcondition(alert10, "Sell Signal", "Sell Signal EzAlgo")
// Trend Cloud Module
// Trendlines Modules
//inputs
show_trendlines = [Link](true, 'Show Trendlines', inline =
'tl_1',group='Trendlines')
upper_trendline_color = [Link](#9598a1, '', inline =
'tl_1',group='Trendlines')
lower_trendline_color = [Link](#9598a1, '', inline =
'tl_1',group='Trendlines')
extendLine = [Link](true, 'Extend', inline = 'tl_1',group='Trendlines')
linestyle_curr_inp = [Link](defval = 'Solid', title = "Style", options =
['Solid', 'Dotted', 'Dashed'],inline = "tl_3",group='Trendlines')
line_width_curr = [Link](1, 'Width', step = 1, minval = 1,maxval =
4,inline = "tl_3",group='Trendlines')
pivLen_L = [Link](20, 'Lookback', step = 1, minval = 1, inline
='tl_5',group='Trendlines')
pivLen_R = pivLen_L//[Link](20, '/', step = 1, minval = 1, inline
='tl_5',group='Trendlines')
hideCrossed = not([Link](false, 'Show Broken', inline =
'tl_2',group='Trendlines'))
broken_color_up = [Link](#9598a1, '', inline =
'tl_2',group='Trendlines')
broken_color_down = [Link](#9598a1, '', inline =
'tl_2',group='Trendlines')
extendLine_B = [Link](true, 'Extend', inline = 'tl_2',group='Trendlines')
show_signals = [Link](false, 'Show Signals', inline =
'tl_s',group='Trendlines')
broken_color_up_signal = [Link]([Link], '', inline =
'tl_s',group='Trendlines')
broken_color_down_signal = [Link]([Link], '', inline =
'tl_s',group='Trendlines')
maxLines = [Link](3, 'Max Broken', step = 1, minval = 1, maxval = 50,
inline = 'tl_2_B',group='Trendlines')
Source_tl = [Link]('Close', 'Mitigation', options = ['Close',
'High/Low'], inline ='tl_2_B',group='Trendlines')
linestyle_broken_inp = [Link](defval = 'Dashed', title = "Style (Broken)",
options = ['Solid', 'Dotted', 'Dashed'],inline = "tl_2-1",group='Trendlines')
line_width_broken = [Link](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 = [Link]([Link]([Link]), [Link],
close)
s_open = [Link]([Link]([Link]), [Link],
open)
s_high = [Link]([Link]([Link]), [Link],
high)
s_low = [Link]([Link]([Link]), [Link], low)
var line[] pivot_high_array = array.new_line(),var line[] pivot_low_array =
array.new_line()
ph2_M = [Link](s_high, pivLen_L, pivLen_R)
pl2_M = [Link](s_low, pivLen_L, pivLen_R)
ph2 = [Link](s_high, pivLen_L, pivLen_R)
pl2 = [Link](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/2
tl_array_size_dn = maxLines%2==0? maxLines/2 : (maxLines/2)+1
//functions
newTrendLine(ptype, x1, y1, x2, y2)=>
new_trendline = [Link](x1, y1, x2, y2, extend = extendLine ? [Link] :
[Link], color = ptype == 'ph2' ? upper_trendline_color :
lower_trendline_color, width = line_width_curr,style = lineStyle_curr,xloc =
xloc.bar_index)
if ptype == 'ph2'
pivot_high_array.unshift(new_trendline)
else
pivot_low_array.unshift(new_trendline)
SlopeOfLine(line)=>
slopeph2 = (line.get_y2(line) - line.get_y1(line))/(line.get_x2(line) -
line.get_x1(line))
extendedph2 = line.get_y2(line) - slopeph2 * (line.get_x2(line) - bar_index)
extendedph2
up_trend_line_formed= false
down_trend_line_formed = false
if pl2
X_prev_low := X_curr_low, Y_prev_low := Y_curr_low, prev_close_L :=
curr_close_L
X_curr_low := bar_index[pivLen_R], Y_curr_low := s_low[pivLen_R],
curr_close_L:= s_close[pivLen_R]
if Y_prev_low < Y_curr_low and show_trendlines and Y_curr_low > prev_close_L
newTrendLine('pl2', X_prev_low, Y_prev_low, X_curr_low, Y_curr_low)
down_trend_line_formed:=true
if ph2
X_prev_high := X_curr_high, Y_prev_high := Y_curr_high, prev_close_H :=
curr_close_H
X_curr_high := bar_index[pivLen_R], Y_curr_high := s_high[pivLen_R],
curr_close_H:= s_close[pivLen_R]
if Y_prev_high > Y_curr_high and show_trendlines and prev_close_H > Y_curr_high
newTrendLine('ph2', X_prev_high, Y_prev_high, X_curr_high, Y_curr_high)
up_trend_line_formed := true
if close > Y_prev_high
Y_prev_high:=0.000000
if close < Y_prev_low
Y_prev_low:= 9999999999.9999
// alertcondition(up_trend_line_formed,'Up TrendLine Formed','Up TrendLine Formed')
// alertcondition(down_trend_line_formed,'Down TrendLine Formed','Down TrendLine
Formed')
alertcondition(down_trend_line_formed or up_trend_line_formed,'Trendline
Formed','Trendline Formed')
up_trend_line_broken = false
down_trend_line_broken = false
for x in pivot_low_array
var line [] Down_Trend_Lines = array.new_line(tl_array_size_up)
var label [] Down_Trend_Labels = array.new_label(tl_array_size_up)
src = Source_tl == 'Close' ? s_close : s_low
x.set_xy2(bar_index, SlopeOfLine(x))
if x.get_x2() - x.get_x1() > 300
[Link]()
if src < line.get_y2(x)
tl_line = [Link](line.get_x1(x), line.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 ? [Link] :
[Link])
down_trend_line_broken:=true
Down_Trend_Lines.unshift(tl_line)
[Link](x)
if Down_Trend_Lines.size() > (tl_array_size_up)
[Link](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
[Link]()
if src > line.get_y2(x)
tl_line = [Link](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 ? [Link] :
[Link])
up_trend_line_broken:=true
Up_Trend_Lines.unshift(tl_line)
[Link](x)
if Up_Trend_Lines.size() > (tl_array_size_dn)
[Link](Up_Trend_Lines.pop())
plotshape(show_signals and up_trend_line_broken? low : na, title='Trendline Broken
Up', style=[Link], textcolor=[Link]([Link], 0), size=[Link],
location=[Link], color=broken_color_up_signal,display= [Link] -
display.status_line, editable = false)
plotshape(show_signals and down_trend_line_broken? high : na, title='Trendline
Broken Down', style=[Link], textcolor=[Link]([Link], 0),
size=[Link], location=[Link],
color=broken_color_down_signal,display= [Link] - display.status_line,
editable = false)
// MULTI-TIMEFRAME S/R
c_subtitle = [Link]([Link], 30)
s_subtitle = 'normal'
a_subtitle = 'center'
// get data on ticker based on chosen timeframe
src_c = [Link]([Link],timef,close, gaps = barmerge.gaps_off,
lookahead = barmerge.lookahead_off)
src_o = [Link]([Link],timef,open, gaps = barmerge.gaps_off,
lookahead = barmerge.lookahead_off)
f_resInMinutes() =>
_resInMinutes = [Link] * ([Link] ? 1. / 60 :
[Link] ? 1. : [Link] ? 60. * 24 : [Link] ? 60.
* 24 * 7 : [Link] ? 60. * 24 * 30.4375 : na)
_resInMinutes
f_timefResInMinutes(_res) =>
[Link]([Link], _res, f_resInMinutes())
f_timefIsIntraday(_res) =>
[intraday, daily, weekly, monthly] = [Link]([Link], _res,
float src3 = [Link](close, open)
float src4 = [Link](close, open)
float ph = [Link](src1, prd, prd)
float pl = [Link](src2, prd, prd)
Lstyle = line.style_solid
timef_res = f_timefIsIntraday(timef)
timef_text = [Link](timef)
if [Link](timef) == ""
timef_text := na([Link] / 60) ? [Link] :
[Link] < 60 ? [Link] + " M |" :
[Link]([Link] / 60) + " H |"
else if timef_res == "Intraday"
timef_text := na([Link](timef) / 60) ? [Link](timef) :
[Link](timef) < 60 ? [Link](timef) + " M |" :
[Link]([Link](timef) / 60) + " H |"
else
timef_text := [Link](timef)
//calculate maximum S/R channel zone width
prdhighest = [Link]([Link], timef, [Link](300))
prdlowest = [Link]([Link], timef, [Link](300))
cwidth = (prdhighest - prdlowest) * ChannelW / 100
var pivotvals = array.new_float(0)
if ph or pl
[Link](pivotvals, ph ? ph : pl)
if [Link](pivotvals) > maxnumpp // limit the array size
[Link](pivotvals)
get_sr_vals(ind) =>
float lo = [Link](pivotvals, ind)
float hi = lo
int numpp = 0
for y = 0 to [Link](pivotvals) - 1 by 1
float cpp = [Link](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 = [Link](sr_strength)
for i = ret > 0 ? [Link](sr_strength) - 1 : na to 0 by 1
if strength <= [Link](sr_strength, i)
break
ret := i
c_bg = [Link]([Link], 100)
// New Features
// User inputs
rsiOB = 68
rsiOS = 32
rsiOB2 = 70
rsiOS2 = 30
rsiOS3 = 24
// Big candle detector
lastCandleSize = [Link](high[1] - low[1])
curCandleSize = [Link](high - low)
bullishCandle = curCandleSize > lastCandleSize * 1.5 and close > open
bearishCandle = curCandleSize > lastCandleSize * 1.5 and close < open
// RSI
rsiValue = [Link](close[1], 14)
// reversalbuysell = input(true, "[AI] Reversals", group="BUY & SELL
SIGNALS")
// reversalsignaltype = [Link]("All", "Signal Type", ["All", "Bullish",
"Bearish"], group="BUY & SELL SIGNALS")
// reversalmode = [Link]("Swing", "Mode", ["Scalp", "Swing",
"Accumulation"], group="BUY & SELL SIGNALS")
// Plot signal
// Scalp
// Trend Cloud
Curly_Fries = 74
Chicken_Sandwich = 144
ema_150 = [Link](close, Curly_Fries)
ema_250 = [Link](