// 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 = ta.crossunder(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(syminfo.tickerid)
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 = input.bool(true, 'Show Trendlines', inline =
'tl_1',group='Trendlines')
upper_trendline_color = input.color(#9598a1, '', inline =
'tl_1',group='Trendlines')
lower_trendline_color = input.color(#9598a1, '', inline =
'tl_1',group='Trendlines')
extendLine = input.bool(true, 'Extend', inline = 'tl_1',group='Trendlines')
linestyle_curr_inp = input.string(defval = 'Solid', title = "Style", options =
['Solid', 'Dotted', 'Dashed'],inline = "tl_3",group='Trendlines')
line_width_curr = input.int(1, 'Width', step = 1, minval = 1,maxval =
4,inline = "tl_3",group='Trendlines')
pivLen_L = input.int(20, 'Lookback', step = 1, minval = 1, inline
='tl_5',group='Trendlines')
pivLen_R = pivLen_L//input.int(20, '/', step = 1, minval = 1, inline
='tl_5',group='Trendlines')
hideCrossed = not(input.bool(false, 'Show Broken', inline =
'tl_2',group='Trendlines'))
broken_color_up = input.color(#9598a1, '', inline =
'tl_2',group='Trendlines')
broken_color_down = input.color(#9598a1, '', inline =
'tl_2',group='Trendlines')
extendLine_B = input.bool(true, 'Extend', inline = '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/2
tl_array_size_dn = maxLines%2==0? maxLines/2 : (maxLines/2)+1
//functions
newTrendLine(ptype, x1, y1, x2, y2)=>
new_trendline = line.new(x1, y1, x2, y2, extend = extendLine ? extend.right :
extend.none, 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
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_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(