Message
Message
Message
// Alerts
alert02 = bull
alert03 = wtDivBull
alert04 = wtDivBear
alert05 = bull or bear
alert06 = ta.crossover(wt1, 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)
//inputs
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
//functions
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
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)
// Liquidity Sweeps
//INPUTS
cooldownPeriod = input.int(10,title="Cooldown Period", minval=0, group= "🧊 Swing
Detaction")
lbLeft = 20
lbRight = 20
//FUNCTIONS
lineStyle(s) =>
if s == 'Solid'
line.style_solid
else if s == 'Dotted'
line.style_dotted
else
line.style_dashed
//VARS
var int bullSignalIndex = 0
var int bearSignalIndex = 0
//CALCULATIONS
pLow = ta.pivotlow(low, lbLeft, lbRight)
pHigh = ta.pivothigh(high, lbLeft, lbRight)
lp = ta.lowest(low, lbLeft)
hp = ta.highest(high, lbLeft)
bullishSFP = low < pLowVal and close > pLowVal and open > pLowVal and low == lp and
lowestClose >= pLowVal
bearishSFP = high > pHighVal and close < pHighVal and open < pHighVal and high ==
hp and highestClose <= pHighVal
bullcond1 = bullishSFP[3] and (close > pLowVal) and (close[1] > pLowVal[1]) and
(close[2] > pLowVal[2]) and bar_index >= bullSignalIndex + cooldownPeriod
bearCond1 = bearishSFP[3] and (close < pHighVal) and (close[1] < pHighVal[1]) and
(close[2] < pHighVal[2]) and bar_index >= bearSignalIndex + cooldownPeriod
if bearCond1
bearSignalIndex := bar_index
bearLine := line.new(prevHighIndex, pHighVal, bar_index-3, pHighVal,
color=bearColor, width=bearWidth, style=lineStyle(bearStyle))
if array.size(swingHighArr) >= 3
label.delete(array.shift(swingHighArr))
label.delete(array.shift(swingHighTextArr))
if array.size(swingLowArr) >= 3
label.delete(array.shift(swingLowArr))
label.delete(array.shift(swingLowTextArr))
//PLOTS
plotshape(bullcond1, text='Sweep', color=bullColor, textcolor=bullColor,
location=location.belowbar, offset = -3)
plotshape(bearCond1, text='Sweep', color=bearColor, textcolor=bearColor,
location=location.abovebar, offset = -3)
//ALERTS
alertcondition(bullishSFP, title='Bullish Sweep', message='{{ticker}} Bullish
Sweep, Price:{{close}}')
alertcondition(bearishSFP, title='Bearish Sweep', message='{{ticker}} Bearish
Sweep, Price:{{close}}')
Range_MA(period)=>
// Calculate weighted ma
weight = BarRange / math.sum(BarRange, period)
TotalSum = math.sum(close * weight, period)
TotalW= math.sum(weight, period)
rwma = TotalSum / TotalW
LongData = prediction_data(hlc3,LongPriod)
ShortData = prediction_data(hlc3,ShortPriod)
longcon = LongData < max
shorton = ShortData > max2
int Class = shorton ? -1 : longcon ? 1 : 0
_color =
LLong ? color.new(color.from_gradient(prediction,0,55,Bull,Bull1),30) :
SShort ? color.new(color.from_gradient(-prediction,-55,-1,bear11,Bear1),30) :
na