VP (Maps) + OB + S&R + GGSHOT + HH
VP (Maps) + OB + S&R + GGSHOT + HH
VP (Maps) + OB + S&R + GGSHOT + HH
0 at
https://mozilla.org/MPL/2.0/
// © leandrolopezf1920
//@version=5
indicator("VP(Maps)+OB+S&R+GGSHOT+HH BY LEO", shorttitle="Volume Profile (Maps) +
Orderblocks+ GG SHOT + HH BY LEO" , max_labels_count = 500, max_lines_count = 500,
max_boxes_count = 500, max_bars_back=2000, overlay=true)
//------------------------------------------------------------------------------
// Settings
//-----------------------------------------------------------------------------{
sp1 =' ' , sp2 =
' '
src = input.source( close , 'source'
)
mtV = input.bool ( false , sp2 + 'Volume * currency'
,tooltip= 'Example BTCUSD -> volume in
USD' )
barsBack = input.int ( 5000 , 'Amount of bars'
, maxval=50000 )
maxLines = input.int ( 500 , 'Max lines'
, minval= 100 , maxval= 1000
,tooltip= 'max 1000'
)
iStep = input.string( 'Round' , ''
, group ='Round', options=['Round', 'Step'])
mlt = input.int ( 0 , 'Round'
, group ='Round', minval= -8 , maxval= 4
,tooltip= 'Example: 123456.789 \n 0->123456.789\n 1->123456.79\
n 2->123456.8\n 3->123457\n-1->123460\n-2->123500' )
step = input.float ( 1
, group ='Round' )
offset = input.int ( 200 , 'Offset'
, group ='display Volume Profile', maxval=500 )
width = input.int ( 205 , 'Max width Volume
Profile' , group ='display Volume Profile' )
cReg = input.color(color.rgb(178, 181, 190, 50), sp1
, group ='display Volume Profile', inline='c' )
cH_1 = input.color(color.rgb(255, 0, 0, 25), ''
, group ='display Volume Profile', inline='c' )
cH_2 = input.color(color.rgb(255, 153, 0, 25), ''
, group ='display Volume Profile', inline='c' )
sTab = input.bool ( false , sp1 + ' Show table'
, group ='display Volume Profile' )
//------------------------------------------------------------------------------
// Methods
//-----------------------------------------------------------------------------{
method set (line ln, int x, float y, int o) =>
ln .set_xy1 (math.max(0, bar_index + o ), y)
ln .set_xy2 (math.max(0, bar_index + o - nz(x)), y)
method set (box bx, int x, float y, int o) =>
bx .set_lefttop (math.max(0, bar_index + o ), y)
bx .set_rightbottom(math.max(0, bar_index + o - nz(x)), y)
//------------------------------------------------------------------------------
// Variables
//-----------------------------------------------------------------------------{
var originalMap = map.new <float, float>() //
key: close, value: volume
var lines = array.new < line >() //
array of lines
var boxes = array.new < box >() //
array of boxes
var tab = table.new(position.top_right, 2, 7, chart.bg_color,
chart.bg_color, 1, chart.bg_color, 1)
//------------------------------------------------------------------------------
// Execution
//-----------------------------------------------------------------------------{
n = bar_index
barsBack := math.min (barsBack , last_bar_index) //
minimum of ['Amount of bars' - total available bars]
mxLines2 = math.round(maxLines / 2)
if barstate.isfirst
for i = 0 to math.min(500, maxLines ) //
fill line array till "maxLines" or "500" reached
lines.unshift(line.new(na, na, na, na, width=2))
for i = 0 to math.min(500, math.max(0, maxLines - 500)) //
fill box array till "maxLines" or "500" reached (only after line array is filled)
boxes.unshift(box .new(na, na, na, na, border_width=1))
if last_bar_index - n == barsBack
line.new(n, close, n, close+ syminfo.mintick, extend=extend.both)
if barstate.islast
maxVol = 0.
for ln in lines
ln.set_color(cReg) //
set colour of all lines to default
for bx in boxes
bx.set_border_color(color.new(cReg, 70)) //
set colour of all boxes to default
if originalMap.size() > 1
copyK = originalMap.keys().copy() //
make a copy of the keys -> array
copyK.sort() //
sort (ascending)
idx = copyK.binary_search_leftmost(src) //
look for position of 'current' src in copyK
szL = idx, szR = copyK.size() -1 - idx //
check how many left (lower) and right (higher) of idx (size: left - idx - right)
sml = math.min(szL, szR) //
smallest side
if szR == sml
szL := math.min(maxLines - math.min(mxLines2, szR), szL) //
if R side has 'unused' lines -> give them to L side
szR := math.min(mxLines2, szR)
else
szL := math.min(mxLines2, szL)
szR := math.min(maxLines - math.min(mxLines2, szL), szR) //
if L side has 'unused' lines -> give them to R side
w = width / maxVol //
make sure lines don't exceed 'max width Volume Profile'
aMaxI = array.from(0 , 0 ) //
index of largest and second largest volume
aMaxV = array.from(0., 0.) //
value of largest and second largest volume
for i = 0 to keys.size()-1
clo = keys.get(i)
vol = vals.get(i)
if vol > max //
when largest volume is found -> set index so line can be coloured later
max := vol
aMaxI.inOut( i )
aMaxV.inOut(vol)
else if vol > aMaxV.get(1) //
when second largest volume is found -> set index so line can be coloured later
aMaxI.set(1, i )
aMaxV.set(1,vol)
if i < 500
lines.get(i ).set(math.round(vol * w), clo, offset) //
update 'lines' array
else
boxes.get(i - 500).set(math.round(vol * w), clo, offset) //
update 'boxes' array (line array is full -> box array)
//------------------------------------------------------------------------------
// Table
//-----------------------------------------------------------------------------{
if sTab
tab.cell(0, 0, text='size originalMap' ,
text_font_family=font.family_monospace, text_color=chart.fg_color, height=2)
tab.cell(1, 0, text=str.tostring(originalMap.size()) ,
text_font_family=font.family_monospace, text_color=chart.fg_color, height=2)
tab.cell(0, 1, text= '# higher' ,
text_font_family=font.family_monospace, text_color=chart.fg_color, height=2)
tab.cell(1, 1, text=str.tostring(originalMap.size() - idx),
text_font_family=font.family_monospace, text_color=chart.fg_color, height=2)
tab.cell(0, 2, text= 'index "close"' ,
text_font_family=font.family_monospace, text_color=chart.fg_color, height=2)
tab.cell(1, 2, text=str.tostring( idx ) ,
text_font_family=font.family_monospace, text_color=chart.fg_color, height=2)
tab.cell(0, 3, text= ' ' ,
text_font_family=font.family_monospace, text_color=chart.fg_color, height=2)
tab.cell(0, 4, text= 'size newMap' ,
text_font_family=font.family_monospace, text_color=chart.fg_color, height=2)
tab.cell(1, 4, text=str.tostring( newMap.size() ) ,
text_font_family=font.family_monospace, text_color=chart.fg_color, height=2)
tab.cell(0, 5, text= '# higher' ,
text_font_family=font.family_monospace, text_color=chart.fg_color, height=2)
tab.cell(1, 5, text=str.tostring( szR ) ,
text_font_family=font.family_monospace, text_color=chart.fg_color, height=2)
tab.cell(0, 6, text= '# lower' ,
text_font_family=font.family_monospace, text_color=chart.fg_color, height=2)
tab.cell(1, 6, text=str.tostring( szL ) ,
text_font_family=font.family_monospace, text_color=chart.fg_color, height=2)
//-----------------------------------------------------------------------------}
if barstate.isconfirmed
if pvh
array.pop(pvh1_price)
array.pop(pvh1_time)
array.unshift(pvh1_price, pv1_high)
array.unshift(pvh1_time, pv1_time)
if array.size(pvh1_price) > 2
temp_pv_0 := array.get(pvh1_price, 0)
temp_pv_1 := array.get(pvh1_price, 1)
temp_pv_2 := array.get(pvh1_price, 2)
if temp_pv_0 < temp_pv_1 and temp_pv_1 > temp_pv_2
array.pop(pvh2_price)
array.pop(pvh2_time)
array.unshift(pvh2_price, temp_pv_1)
array.unshift(pvh2_time, array.get(pvh1_time, 1))
new_ph_2nd := true
if temp_pv_1 > array.get(pvh2_price, 1)
for i = 0 to array.size(pvl2_time) - 1 by 1
temp_ltcmrhh_time = array.get(pvl2_time, i)
if temp_ltcmrhh_time < array.get(pvh2_time, 0)
ltcmrhh_price := array.get(pvl2_price, i)
ltcmrhh_time := temp_ltcmrhh_time
break
if temp_pv_0 < ltcmrhh_price
if msb_sv
array.push(bear_bos_lines, line.new(x1=ltcmrhh_time,
y1=ltcmrhh_price, x2=bar_index, y2=ltcmrhh_price, color=color.green, width=2))
box_top := array.get(pvh2_price, 0)
box_bottom := math.max(low[bar_index - array.get(pvh2_time, 0)],
low[bar_index - array.get(pvh2_time, 0) + 1])
array.push(short_boxes, box.new(left=array.get(pvh2_time, 0),
top=box_top, right=bar_index, bottom=box_bottom, bgcolor= box_sv ? u_s : na ,
border_color=na, extend=extend.right))
if msb_a_sv
alert := alert + 'Bearish MSB @ ' + str.tostring(ltcmrhh_price)
+ '\n' + 'New Supply Zone : '+ str.tostring(box_top) + ' - ' +
str.tostring(box_bottom) + '\n'
ltcmrhh_price := na
if pvl
array.pop(pvl1_price)
array.pop(pvl1_time)
array.unshift(pvl1_price, pv1_low)
array.unshift(pvl1_time, pv1_time)
if array.size(pvl1_price) > 2
temp_pv_0 := array.get(pvl1_price, 0)
temp_pv_1 := array.get(pvl1_price, 1)
temp_pv_2 := array.get(pvl1_price, 2)
if temp_pv_0 > temp_pv_1 and temp_pv_1 < temp_pv_2
array.pop(pvl2_price)
array.pop(pvl2_time)
array.unshift(pvl2_price, temp_pv_1)
array.unshift(pvl2_time, array.get(pvl1_time, 1))
new_pl_2nd := true
if temp_pv_1 < array.get(pvl2_price, 1)
for i = 0 to array.size(pvh2_time) - 1 by 1
temp_htcmrll_time = array.get(pvh2_time, i)
if temp_htcmrll_time < array.get(pvl2_time, 0)
htcmrll_price := array.get(pvh2_price, i)
htcmrll_time := temp_htcmrll_time
break
if temp_pv_0 > htcmrll_price
if msb_sv
array.push(bull_bos_lines, line.new(x1=htcmrll_time,
y1=htcmrll_price, x2=bar_index, y2=htcmrll_price, color=color.red, width=2))
box_top := math.min(high[bar_index - array.get(pvl2_time, 0)],
high[bar_index - array.get(pvl2_time, 0) + 1])
box_bottom := array.get(pvl2_price, 0)
array.push(long_boxes, box.new(left=array.get(pvl2_time, 0),
top=box_top, right=bar_index, bottom=box_bottom, bgcolor= box_sv ? u_d : na,
border_color=na, extend=extend.right))
if msb_a_sv
alert := alert + 'Bullish MSB @ ' + str.tostring(htcmrll_price)
+ '\n' + 'New Demand Zone : '+ str.tostring(box_bottom) + ' - ' +
str.tostring(box_top) + '\n'
htcmrll_price := na
if array.size(short_boxes) > 0
for i = array.size(short_boxes) - 1 to 0 by 1
tbox = array.get(short_boxes, i)
top = box.get_top(tbox)
bottom = box.get_bottom(tbox)
ago = box.get_left(tbox)
if array.get(pvh1_price, 0) > bottom
if box_sv
box.set_bgcolor(tbox, t_s)
if ob_a_sv and close < bottom
if array.get(pvh1_time, 0) != h_a_time
h_a_time := array.get(pvh1_time, 0)
alert := alert + 'Supply Zone Test @ ' +
str.tostring(array.get(pvh1_price, 0)) + ' (age = ' + str.tostring(bar_index-ago) +
' bars) \n'
if array.get(pvl1_price, 0) > top
if m_sv
box.set_bgcolor(tbox, u_b)
array.push(m_long_boxes, tbox)
else
box.delete(tbox)
array.remove(short_boxes, i)
if msb_sv
line.delete(array.get(bear_bos_lines, i))
array.remove(bear_bos_lines, i)
if array.size(long_boxes) > 0
for i = array.size(long_boxes) - 1 to 0 by 1
lbox = array.get(long_boxes, i)
top = box.get_top(lbox)
bottom = box.get_bottom(lbox)
ago = box.get_left(lbox)
if array.get(pvl1_price, 0) < top
if box_sv
box.set_bgcolor(lbox, t_d)
if ob_a_sv and close > top
if array.get(pvl1_time, 0) != l_a_time
l_a_time := array.get(pvl1_time, 0)
alert := alert + 'Demand Zone Test @ ' +
str.tostring(array.get(pvl1_price, 0)) + ' (age = ' + str.tostring(bar_index-ago) +
' bars) \n'
if array.get(pvh1_price, 0) < bottom
if m_sv
box.set_bgcolor(lbox, u_b)
array.push(m_short_boxes, lbox)
else
box.delete(lbox)
array.remove(long_boxes, i)
if msb_sv
line.delete(array.get(bull_bos_lines, i))
array.remove(bull_bos_lines, i)
if array.size(m_short_boxes) > 0
for i = array.size(m_short_boxes) - 1 to 0 by 1
tbox = array.get(m_short_boxes, i)
top = box.get_top(tbox)
bottom = box.get_bottom(tbox)
ago = box.get_left(tbox)
if array.get(pvh1_price, 0) > bottom
box.set_bgcolor(tbox, t_b)
if bb_a_sv and close < bottom
if array.get(pvh1_time, 0) != mh_a_time
mh_a_time := array.get(pvh1_time, 0)
alert := alert + 'Breakerblock Test Up @ ' +
str.tostring(array.get(pvh1_price, 0)) + ' (age = ' + str.tostring(bar_index-ago) +
' bars) \n'
if array.get(pvl1_price, 0) > top
box.delete(tbox)
array.remove(m_short_boxes, i)
if array.size(m_long_boxes) > 0
for i = array.size(m_long_boxes) - 1 to 0 by 1
lbox = array.get(m_long_boxes, i)
top = box.get_top(lbox)
bottom = box.get_bottom(lbox)
ago = box.get_left(lbox)
if array.get(pvl1_price, 0) < top
box.set_bgcolor(lbox, t_b)
if bb_a_sv and close > top
if array.get(pvl1_time, 0) != ml_a_time
ml_a_time := array.get(pvl1_time, 0)
alert := alert + 'Breakerblock Test Down @ ' +
str.tostring(array.get(pvl1_price, 0)) + ' (age = ' + str.tostring(bar_index-ago) +
' bars) \n'
if array.get(pvh1_price, 0) < bottom
box.delete(lbox)
array.remove(m_long_boxes, i)
if range_sv and (new_ph_2nd or new_pl_2nd) and (array.get(pvh2_price, 0) <
array.get(pvh2_price, 1) and array.get(pvl2_price, 0) > array.get(pvl2_price, 1)
and array.get(pvh2_price, 0) > array.get(pvl2_price, 1) and array.get(pvl2_price,
0) < array.get(pvh2_price, 1)) and (array.get(pvl2_price, 1) > nz(last_range_h) or
na(last_range_l)? true : (array.get(pvh2_price, 1) < last_range_l))
temp_time := math.min(array.get(pvh2_time, 1), array.get(pvl2_time, 1))
last_range_h := array.get(pvh2_price, 1)
last_range_l := array.get(pvl2_price, 1)
temp_pv_0 := log_sv ? math.exp((math.log(last_range_h) +
math.log(last_range_l))/2) : (last_range_h + last_range_l)/2
temp_pv_1 := log_sv ? math.exp((math.log(last_range_h) +
math.log(temp_pv_0))/2) : (last_range_h + temp_pv_0)/2
temp_pv_2 := log_sv ? math.exp((math.log(last_range_l) +
math.log(temp_pv_0))/2) : (last_range_l + temp_pv_0)/2
array.push(range_h_lines, line.new(x1=temp_time, y1=last_range_h,
x2=bar_index, y2=last_range_h, color=color.gray, width=1, extend=extend.right))
array.push(range_l_lines, line.new(x1=temp_time, y1=last_range_l,
x2=bar_index, y2=last_range_l, color=color.gray, width=1, extend=extend.right))
if range_eq_sv
array.push(range_m_lines, line.new(x1=temp_time, y1=temp_pv_0,
x2=bar_index, y2=temp_pv_0, color=color.gray, width=1, extend=extend.right))
if range_q_sv
array.push(range_25_lines, line.new(x1=temp_time, y1=temp_pv_1,
x2=bar_index, y2=temp_pv_1, style=line.style_dashed, color=color.gray, width=1,
extend=extend.right))
array.push(range_75_lines, line.new(x1=temp_time, y1=temp_pv_2,
x2=bar_index, y2=temp_pv_2, style=line.style_dashed, color=color.gray, width=1,
extend=extend.right))
if r_a_sv
alert := alert + 'New Range : ' + str.tostring(last_range_h) + ' - ' +
str.tostring(last_range_l) + '. Mean = ' + str.tostring(temp_pv_0) + '\n'
if array.size(range_h_lines) > 0
for i = array.size(range_h_lines) - 1 to 0 by 1
range_h = array.get(range_h_lines, i)
top = line.get_y1(range_h)
range_l = array.get(range_l_lines, i)
bottom = line.get_y1(range_l)
temp_time := line.get_x1(range_h)
if array.get(pvh1_price, 0) > top
if rt_a_sv and close < top
if array.get(pvh1_time, 0) != rh_a_time
rh_a_time := array.get(pvh1_time, 0)
alert := alert + 'Range High Test @ ' +
str.tostring(array.get(pvh1_price, 0)) + ' \n'
if array.get(pvl1_price, 0) < bottom
if rt_a_sv and close > bottom
if array.get(pvl1_time, 0) != rl_a_time
rl_a_time := array.get(pvl1_time, 0)
alert := alert + 'Range Low Test @ ' +
str.tostring(array.get(pvl1_price, 0)) + ' \n'
if range_eq_sv
range_m := array.get(range_m_lines, i)
if range_q_sv
range_25 := array.get(range_25_lines, i)
range_75 := array.get(range_75_lines, i)
if array.get(pvh1_price, 0) < bottom or array.get(pvl1_price, 0) > top
line.delete(range_h)
array.remove(range_h_lines, i)
line.delete(range_l)
array.remove(range_l_lines, i)
if range_eq_sv
line.delete(range_m)
array.remove(range_m_lines, i)
if range_q_sv
line.delete(range_25)
array.remove(range_25_lines, i)
line.delete(range_75)
array.remove(range_75_lines, i)
last_range_h := na
last_range_l := na
if pv2_sv
if new_ph_2nd
array.push(la_ph2, label.new(x = array.get(pvh2_time, 0), y =
array.get(pvh2_price, 0), xloc = xloc.bar_index, style = label.style_label_down,
color = #77000000, size = size.tiny))
if new_pl_2nd
array.push(la_pl2, label.new(x = array.get(pvl2_time, 0), y =
array.get(pvl2_price, 0), xloc = xloc.bar_index, style = label.style_label_up,
color = #00770000, size = size.tiny))
// Strategy Settings - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
supportLookBack = input.int(defval=22, title = "Support
Look Back", group="Support & Resistance Settings")
supportLookAhead = input.int(defval=26, title = "Support
Look Ahead", group="Support & Resistance Settings")
resistanceLookBack = input.int(defval=30, title = "Reistance
Look Back", group="Support & Resistance Settings")
resistanceLookAhead = input.int(defval=27, title = "Reistance
Look Ahead", group="Support & Resistance Settings")
timeframe1 = input.timeframe(defval="60",
title="Timeframe 1", group="Support & Resistance 1")
enableSrRanges1 = input.bool(defval=true, title="Enable
Support & Resistance Ranges", group="Support & Resistance 1")
supportRange1 = input.float(defval=.25, title="
Support Range (%) ", inline="support1", group="Support & Resistance 1")
supportRange1Color = input.color(defval=green, title="",
inline="support1", group="Support & Resistance 1")
resistanceRange1 = input.float(defval=.25, title="
Resistance Range (%) ", inline="resistance1", group="Support & Resistance 1")
resistanceRange1Color = input.color(defval=red, title="",
inline="resistance1", group="Support & Resistance 1")
// timeframe2 = input.timeframe(defval="120",
title="Timeframe 2", group="Support & Resistance 2")
// enableSrRanges2 = input.bool(defval=true, title="Enable
Support & Resistance Ranges", group="Support & Resistance 2")
// supportRange2 = input.float(defval=.25, title="
Support Range (%) ", inline="support2", group="Support & Resistance 2")
// supportRange2Color = input.color(defval=green, title="",
inline="support2", group="Support & Resistance 2")
// resistanceRange2 = input.float(defval=.25, title="
Resistance Range (%) ", inline="resistance2", group="Support & Resistance 2")
// resistanceRange2Color = input.color(defval=red, title="",
inline="resistance2", group="Support & Resistance 2")
support
resistance
support1label := label.new(x=bar_index+30,
y=mostRecentSupport1, color=supportRange1Color, textcolor=white,
style=label.style_label_down)
resistance1label := label.new(x=bar_index+30,
y=mostRecentResistance1, color=resistanceRange1Color, textcolor=white,
style=label.style_label_down)
// // Support and Resistance 2
// support2 = request.security(syminfo.ticker,
timeframe2, getSupport(supportLookBack, supportLookAhead))
// resistance2 = request.security(syminfo.ticker,
timeframe2, getResistance(resistanceLookBack, resistanceLookAhead))
// var float mostRecentResistance2 = na
// var float mostRecentSupport2 = na
// mostRecentResistance2 := ta.change(resistance2) ?
resistance2 : mostRecentResistance2
// mostRecentSupport2 := ta.change(support2) ? support2 :
mostRecentSupport2
// var line resistance2Line = na
// var line support2Line = na
// line.delete(resistance2Line)
// line.delete(support2Line)
// resistance2Line := line.new(x1=bar_index[10],
y1=mostRecentResistance2, x2=bar_index, y2=mostRecentResistance2,
color=resistanceRange2Color, width=1, xloc=xloc.bar_index, style=line.style_solid,
extend=extend.both)
// support2Line := line.new(x1=bar_index[10],
y1=mostRecentSupport2, x2=bar_index, y2=mostRecentSupport2,
color=supportRange2Color, width=1, xloc=xloc.bar_index, style=line.style_solid,
extend=extend.both)
// resistance2Price = plot(series=mostRecentResistance2,
title="Resistance Price", color=red, editable=false, display=display.price_scale)
// support2Price = plot(series=mostRecentSupport2,
title="Support Price", color=green, editable=false, display=display.price_scale)
// support2label := label.new(x=bar_index+30,
y=mostRecentSupport2, color=supportRange2Color, textcolor=white,
style=label.style_label_down)
// resistance2label := label.new(x=bar_index+30,
y=mostRecentResistance2, color=resistanceRange2Color, textcolor=white,
style=label.style_label_down)
if enableSrRanges1
support1RangeTop = support1 + (support1 *
(supportRange1/100))
support1RangeBottom = support1 - (support1 *
(supportRange1/100))
resistance1RangeTop = resistance1 + (resistance1 *
(resistanceRange1/100))
resistance1RangeBottom = resistance1 - (resistance1 *
(resistanceRange1/100))
line.delete(support1RangeTopLine)
line.delete(support1RangeBottomLine)
line.delete(resistance1RangeTopLine)
line.delete(resistance1RangeBottomLine)
support1RangeTopLine := line.new(x1=bar_index[10],
y1=support1RangeTop, x2=bar_index, y2=support1RangeTop, color=transparent, width=1,
xloc=xloc.bar_index, style=line.style_solid, extend=extend.both)
support1RangeBottomLine := line.new(x1=bar_index[10],
y1=support1RangeBottom, x2=bar_index, y2=support1RangeBottom, color=transparent,
width=1, xloc=xloc.bar_index, style=line.style_solid, extend=extend.both)
linefill.new(line1=support1RangeTopLine, line2=support1RangeBottomLine,
color=lightGreen)
resistance1RangeTopLine := line.new(x1=bar_index[10],
y1=resistance1RangeTop, x2=bar_index, y2=resistance1RangeTop, color=transparent,
width=1, xloc=xloc.bar_index, style=line.style_solid, extend=extend.both)
resistance1RangeBottomLine := line.new(x1=bar_index[10],
y1=resistance1RangeBottom, x2=bar_index, y2=resistance1RangeBottom,
color=transparent, width=1, xloc=xloc.bar_index, style=line.style_solid,
extend=extend.both)
linefill.new(line1=resistance1RangeTopLine, line2=resistance1RangeBottomLine,
color=lightRed)
// if enableSrRanges2
// support2RangeTop = support2 + (support2 *
(supportRange2/100))
// support2RangeBottom = support2 - (support2 *
(supportRange2/100))
// resistance2RangeTop = resistance2 + (resistance2 *
(resistanceRange2/100))
// resistance2RangeBottom = resistance2 - (resistance2 *
(resistanceRange2/100))
// line.delete(support2RangeTopLine)
// line.delete(support2RangeBottomLine)
// line.delete(resistance2RangeTopLine)
// line.delete(resistance2RangeBottomLine)
// support2RangeTopLine := line.new(x1=bar_index[10],
y1=support2RangeTop, x2=bar_index, y2=support2RangeTop, color=transparent, width=1,
xloc=xloc.bar_index, style=line.style_solid, extend=extend.both)
// support2RangeBottomLine := line.new(x1=bar_index[10],
y1=support2RangeBottom, x2=bar_index, y2=support2RangeBottom, color=transparent,
width=1, xloc=xloc.bar_index, style=line.style_solid, extend=extend.both)
// linefill.new(line1=support2RangeTopLine, line2=support2RangeBottomLine,
color=lightGreen)
// resistance2RangeTopLine := line.new(x1=bar_index[10],
y1=resistance2RangeTop, x2=bar_index, y2=resistance2RangeTop, color=transparent,
width=1, xloc=xloc.bar_index, style=line.style_solid, extend=extend.both)
// resistance2RangeBottomLine := line.new(x1=bar_index[10],
y1=resistance2RangeBottom, x2=bar_index, y2=resistance2RangeBottom,
color=transparent, width=1, xloc=xloc.bar_index, style=line.style_solid,
extend=extend.both)
// linefill.new(line1=resistance2RangeTopLine,
line2=resistance2RangeBottomLine, color=lightRed)
//------------------------------------------------------------------------------
// SGG SHOT MTF with HH harmonics by LEO
//-----------------------------------------------------------------------------
//ichimoku inputs
conversionPeriods = input.int(9, minval=1, title='Conversion Line Periods')
basePeriods = input.int(26, minval=1, title='Base Line Periods')
laggingSpan2Periods = input.int(52, minval=1, title='Lagging Span 2 Periods')
displacement = input.int(26, minval=1, title='Displacement')
//algo
atr = mult * ta.atr(length)
//kumo
donchian(len) =>
math.avg(ta.lowest(len), ta.highest(len))
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = math.avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)
dir = 1
dir := nz(dir[1], dir)
dir := dir == -1 and close > shortStopPrev ? 1 : dir == 1 and close <
longStopPrev ? -1 : dir
longColor = color.blue
shortColor = color.blue
////////////////////////////////////////////////////////////
// Conditions 1
longCond1 = bool(na)
shortCond1 = bool(na)
longCond1 := ta.crossover(close[1], shortStopPrev)
shortCond1 := ta.crossunder(close[1], longStopPrev)
// Conditions 2
longCond2 = bool(na)
shortCond2 = bool(na)
longCond2 := ta.crossover(close[1], shortStopPrev)
shortCond2 := ta.crossunder(close[1], longStopPrev)
// Conditions 3
longCond3 = bool(na)
shortCond3 = bool(na)
longCond3 := ta.crossover(close[1], shortStopPrev)
shortCond3 := ta.crossunder(close[1], longStopPrev)
// Conditions 4
longCond4 = bool(na)
shortCond4 = bool(na)
longCond4 := ta.crossover(close[1], shortStopPrev)
shortCond4 := ta.crossunder(close[1], longStopPrev)
////////////////////////////////////////////////////////////
// Count your long short conditions for more control with Pyramiding 1
sectionLongs1 = 0
sectionLongs1 := nz(sectionLongs1[1])
sectionShorts1 = 0
sectionShorts1 := nz(sectionShorts1[1])
if longCond1
sectionLongs1 += 1
sectionShorts1 := 0
sectionShorts1
if shortCond1
sectionLongs1 := 0
sectionShorts1 += 1
sectionShorts1
// Count your long short conditions for more control with Pyramiding 2
sectionLongs2 = 0
sectionLongs2 := nz(sectionLongs2[1])
sectionShorts2 = 0
sectionShorts2 := nz(sectionShorts2[1])
if longCond2
sectionLongs2 += 1
sectionShorts2 := 0
sectionShorts2
if shortCond2
sectionLongs2 := 0
sectionShorts2 += 1
sectionShorts2
// Count your long short conditions for more control with Pyramiding 3
sectionLongs3 = 0
sectionLongs3 := nz(sectionLongs3[1])
sectionShorts3 = 0
sectionShorts3 := nz(sectionShorts3[1])
if longCond3
sectionLongs3 += 1
sectionShorts3 := 0
sectionShorts3
if shortCond3
sectionLongs3 := 0
sectionShorts3 += 1
sectionShorts3
// Count your long short conditions for more control with Pyramiding 4
sectionLongs4 = 0
sectionLongs4 := nz(sectionLongs4[1])
sectionShorts4 = 0
sectionShorts4 := nz(sectionShorts4[1])
if longCond4
sectionLongs4 += 1
sectionShorts4 := 0
sectionShorts4
if shortCond4
sectionLongs4 := 0
sectionShorts4 += 1
sectionShorts4
////////////////////////////////////////////////////////////
// Pyramiding 1
pyrl = 1
// Pyramiding 2
pyr2 = 1
// Pyramiding 3
pyr3 = 1
// Pyramiding 4
pyr4 = 1
////////////////////////////////////////////////////////////
// These check to see your signal and cross references it against the pyramiding
settings above 1
// These check to see your signal and cross references it against the pyramiding
settings above 2
// These check to see your signal and cross references it against the pyramiding
settings above 3
// These check to see your signal and cross references it against the pyramiding
settings above 4
////////////////////////////////////////////////////////////
// Get the price of the last opened long or short 1
last_open_longCondition1 = float(na)
last_open_shortCondition1 = float(na)
last_open_longCondition1 := longCondition1 ? open : nz(last_open_longCondition1[1])
last_open_shortCondition1 := shortCondition1 ? open :
nz(last_open_shortCondition1[1])
last_open_longCondition2 = float(na)
last_open_shortCondition2 = float(na)
last_open_longCondition2 := longCondition2 ? open : nz(last_open_longCondition2[1])
last_open_shortCondition2 := shortCondition2 ? open :
nz(last_open_shortCondition2[1])
last_open_longCondition3 = float(na)
last_open_shortCondition3 = float(na)
last_open_longCondition3 := longCondition3 ? open : nz(last_open_longCondition3[1])
last_open_shortCondition3 := shortCondition3 ? open :
nz(last_open_shortCondition3[1])
last_open_longCondition4 = float(na)
last_open_shortCondition4 = float(na)
last_open_longCondition4 := longCondition4 ? open : nz(last_open_longCondition4[1])
last_open_shortCondition4 := shortCondition4 ? open :
nz(last_open_shortCondition4[1])
////////////////////////////////////////////////////////////
// Check if your last postion was a long or a short 1
last_longCondition1 = float(na)
last_shortCondition1 = float(na)
last_longCondition1 := longCondition1 ? time : nz(last_longCondition1[1])
last_shortCondition1 := shortCondition1 ? time : nz(last_shortCondition1[1])
last_longCondition2 = float(na)
last_shortCondition2 = float(na)
last_longCondition2 := longCondition2 ? time : nz(last_longCondition2[1])
last_shortCondition2 := shortCondition2 ? time : nz(last_shortCondition2[1])
last_longCondition4 = float(na)
last_shortCondition4 = float(na)
last_longCondition4 := longCondition4 ? time : nz(last_longCondition4[1])
last_shortCondition4 := shortCondition4 ? time : nz(last_shortCondition4[1])
////////////////////////////////////////////////////////////
// Take profit 1
// Take profit 2
// Take profit 3
// Take profit 4
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Create a single close for all the different closing conditions. 1
long_close = long_tp1 ? 1 : 0
short_close = short_tp1 ? 1 : 0
long_close2 = long_tp2 ? 1 : 0
short_close2 = short_tp2 ? 1 : 0
long_close3 = long_tp3 ? 1 : 0
short_close3 = short_tp3 ? 1 : 0
long_close4 = long_tp4 ? 1 : 0
short_close4 = short_tp4 ? 1 : 0
////////////////////////////////////////////////////////////
// Get the time of the last close
last_long_close = float(na)
last_short_close = float(na)
last_long_close := long_close ? time : nz(last_long_close[1])
last_short_close := short_close ? time : nz(last_short_close[1])
last_long_close2 = float(na)
last_short_close2 = float(na)
last_long_close2 := long_close2 ? time : nz(last_long_close2[1])
last_short_close2 := short_close2 ? time : nz(last_short_close2[1])
last_long_close3 = float(na)
last_short_close3 = float(na)
last_long_close3 := long_close3 ? time : nz(last_long_close3[1])
last_short_close3 := short_close3 ? time : nz(last_short_close3[1])
last_long_close4 = float(na)
last_short_close4 = float(na)
last_long_close4 := long_close4 ? time : nz(last_long_close4[1])
last_short_close4 := short_close4 ? time : nz(last_short_close4[1])
////////////////////////////////////////////////////////////
//Signals
bton(b) =>
b ? 1 : 0
//
plotshape(long_tp1 and last_longCondition1 > nz(last_long_close[1]), text='TP1',
title='Take Profit Long', color=color.new(color.green, 0), style=shape.labeldown,
location=location.abovebar, size=size.tiny, textcolor=color.new(color.white,
0)) //plot for sell icon
plotshape(short_tp1 and last_shortCondition1 > nz(last_short_close[1]), text='TP1',
title='Take Profit Short', color=color.new(color.red, 0), style=shape.labelup,
location=location.belowbar, size=size.tiny, textcolor=color.new(color.white,
0)) //plot for buy icon
//
plotshape(long_tp2 and last_longCondition2 > nz(last_long_close2[1]), text='TP2',
title='Take Profit Long 2', color=color.new(color.green, 0), style=shape.labeldown,
location=location.abovebar, size=size.tiny, textcolor=color.new(color.white,
0)) //plot for sell icon
plotshape(short_tp2 and last_shortCondition2 > nz(last_short_close2[1]),
text='TP2', title='Take Profit Short 2', color=color.new(color.red, 0),
style=shape.labelup, location=location.belowbar, size=size.tiny,
textcolor=color.new(color.white, 0)) //plot for buy icon
//
plotshape(long_tp3 and last_longCondition3 > nz(last_long_close3[1]), text='TP3',
title='Take Profit Long 3', color=color.new(color.green, 0), style=shape.labeldown,
location=location.abovebar, size=size.tiny, textcolor=color.new(color.white,
0)) //plot for sell icon
plotshape(short_tp3 and last_shortCondition3 > nz(last_short_close3[1]),
text='TP3', title='Take Profit Short 3', color=color.new(color.red, 0),
style=shape.labelup, location=location.belowbar, size=size.tiny,
textcolor=color.new(color.white, 0)) //plot for buy icon
//
plotshape(long_tp4 and last_longCondition4 > nz(last_long_close4[1]), text='TP4',
title='Take Profit Long 4', color=color.new(color.green, 0), style=shape.labeldown,
location=location.abovebar, size=size.tiny, textcolor=color.new(color.white,
0)) //plot for sell icon
plotshape(short_tp4 and last_shortCondition4 > nz(last_short_close4[1]),
text='TP4', title='Take Profit Short 4', color=color.new(color.red, 0),
style=shape.labelup, location=location.belowbar, size=size.tiny,
textcolor=color.new(color.white, 0)) //plot for buy icon
//
ltp1 = long_tp1 and last_longCondition1 > nz(last_long_close[1]) ? (1 + tp / 100) *
last_open_longCondition1 : na
plot(ltp1, color=color.new(color.green, 100), trackprice=true,
style=plot.style_linebr, linewidth=2 , title = "Take profit - 1")
stp = short_tp1 and last_shortCondition1 > nz(last_short_close[1]) ? (1 - tp / 100)
* last_open_shortCondition1 : na
plot(stp, style=plot.style_linebr, trackprice=true, linewidth=3,
color=color.new(color.white, 0))
//
ltp2 = long_tp2 and last_longCondition2 > nz(last_long_close2[1]) ? (1 + tp2 / 100)
* last_open_longCondition2 : na
plot(ltp2, color=color.new(color.green, 100), trackprice=true,
style=plot.style_linebr, linewidth=2, title = "Take profit - 2")
stp2 = short_tp2 and last_shortCondition2 > nz(last_short_close2[1]) ? (1 - tp2 /
100) * last_open_shortCondition2 : na
plot(stp2, style=plot.style_linebr, trackprice=true, linewidth=3,
color=color.new(color.white, 0))
//
ltp3 = long_tp3 and last_longCondition3 > nz(last_long_close3[1]) ? (1 + tp3 / 100)
* last_open_longCondition3 : na
plot(ltp3, color=color.new(color.green, 100), trackprice=true,
style=plot.style_linebr, linewidth=2, title = "Take profit - 3")
stp3 = short_tp3 and last_shortCondition3 > nz(last_short_close3[1]) ? (1 - tp3 /
100) * last_open_shortCondition3 : na
plot(stp3, style=plot.style_linebr, trackprice=true, linewidth=3,
color=color.new(color.white, 0))
//
ltp4 = long_tp4 and last_longCondition4 > nz(last_long_close4[1]) ? (1 + tp4 / 100)
* last_open_longCondition4 : na
plot(ltp4, color=color.new(color.green, 100), trackprice=true,
style=plot.style_linebr, linewidth=2, title = "Take profit - 4")
stp4 = short_tp4 and last_shortCondition4 > nz(last_short_close4[1]) ? (1 - tp4 /
100) * last_open_shortCondition4 : na
plot(stp4, style=plot.style_linebr, trackprice=true, linewidth=4,
color=color.new(color.white, 0))
//
//kumo plots
plot(conversionLine, color=#0496ff00, title="Conversion Line")
plot(baseLine, color=#99151500, title="Base Line")
plot(close, offset = -displacement, color=#45991500, title="Lagging Span")
K1 = plot(leadLine1, offset=displacement, color=#4caf4f00, title='Lead 1')
K2 = plot(leadLine2, offset=displacement, color=#ff525200, title='Lead 2')
fill(K1, K2, leadLine1 > leadLine2 ? #4caf4f00 : #ff525200)
//---------------------------------------------------------------------------------
--------------------------------------------------------------------------------
//Functions
//---------------------------------------------------------------------------------
--------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
--------------------------------------------------------------------------------
//Inputs
//---------------------------------------------------------------------------------
--------------------------------------------------------------------------------
//Filter Type
f_type = input.string(defval='Type 1', options=['Type 1', 'Type 2'], title='Filter
Type')
//Movement Source
mov_src = input.string(defval='Close', options=['Wicks', 'Close'], title='Movement
Source')
//Range Period
rng_per = input.int(defval=40, minval=1, title='Range Period (for ATR, Average
Change, and Standard Deviation)')
//---------------------------------------------------------------------------------
--------------------------------------------------------------------------------
//Definitions
//---------------------------------------------------------------------------------
--------------------------------------------------------------------------------
//Direction Conditions
var fdir = 0.0
fdir := filt > filt[1] ? 1 : filt < filt[1] ? -1 : fdir
upward = fdir == 1 ? 1 : 0
downward = fdir == -1 ? 1 : 0
//Colors
filt_color = upward ? #05ff9b : downward ? #ff0583 : #cccccc
//---------------------------------------------------------------------------------
--------------------------------------------------------------------------------
//Outputs
//---------------------------------------------------------------------------------
--------------------------------------------------------------------------------
//Filter Plot
filt_plot = plot(filt, color=dir == 1 ? #4caf4f00 : #ff525200, linewidth=1,
title='Trend Line')
//Alerts
//TP3
//alertcondition(bton(long_tp3 and last_longCondition3 > nz(last_long_close3[1])),
title='TP3 LONG')
//alertcondition(bton(short_tp3 and last_shortCondition3 >
nz(last_short_close3[1])), title='TP3 SHORT')
//TP4
//alertcondition(bton(long_tp4 and last_longCondition4 > nz(last_long_close4[1])),
title='TP4 LONG')
//alertcondition(bton(short_tp4 and last_shortCondition4 >
nz(last_short_close4[1])), title='TP4 SHORT')
//ENTRADA
entry = levels ? label.new(time, close, "ENTRY " + str.tostring(lastTrade(close),
"#.#####"), xloc.bar_time, yloc.price, psar_longColor, label.style_label_left,
color.rgb(0, 0, 0), size.normal) : na
label.set_y(entry, lastTrade(close))
label.delete(entry[1])
// HiLo inputs
high_activate = input(title='Track Previous High', defval=true)
high_input = input(title='60', defval=45)
low_activate = input(title='Track Previous Low', defval=true)
low_input = input(title='60', defval=45)
// HH and LL crossovers
HHXO = ta.crossover(close, daily_hh)
LLXO = ta.crossover(daily_ll, close)
// HiLoTouch logic
HiLoTouchUpper = close >= daily_hh
HiLoTouchLower = close <= daily_ll
// alerts
i_HHXO = input(false, 'Alert HH Crossed')
i_LLXO = input(false, 'Alert LL Crossed')
i_HiLoTouch = input(true, 'Alert HiLoTouch')
f_printhh(_texthh) =>
// Create label on the first bar.
var _labelhh = label.new(bar_index, na, _texthh, xloc.bar_index, yloc.price,
color(na), label.style_none, color.gray, size.normal, text.align_left)
// On next bars, update the label's x and y position, and the text it displays.
label.set_xy(_labelhh, bar_index, ta.highest(10)[1])
label.set_text(_labelhh, _texthh)
f_printll(_textll) =>
// Create label on the first bar.
var _labelll = label.new(bar_index, na, _textll, xloc.bar_index, yloc.price,
color(na), label.style_none, color.gray, size.normal, text.align_left)
// On next bars, update the label's x and y position, and the text it displays.
label.set_xy(_labelll, bar_index, ta.lowest(10)[1])
label.set_text(_labelll, _textll)
///////////////////////////////////////////////////////////////////////////////////
//////////////////
ema = close
ema1 = close
ema2 = close
ema := alpha * ema + (1 - alpha) * nz(ema[1], ema)
ema1 := alpha * ema + (1 - alpha) * nz(ema[1], ema)
ema2 := alpha * ema + (1 - alpha) * nz(ema[1], ema)
long = (not above_ema[3] and not above_ema[2] and not above_ema[1] and above_ema)
plotshape(long, style=shape.triangleup, location=location.belowbar, size=size.tiny,
color=color.rgb(0, 92, 230), text='BUY')
// Functions
get(arr, index) =>
index < array.size(arr) ? array.get(arr, index) : na
bounced(bounces) =>
status = array.get(bounces, 0)
array.set(bounces, 0, true)
status
// A. CORE
ceiling = request.security(syminfo.tickerid, higherTF, math.max(high, close[1],
open[1]))
floor = request.security(syminfo.tickerid, higherTF, math.min(low, close[1],
open[1]))
// Pivot setups
soaring = bullishEngulf or breakHigh or whiteSoldiers
tumbling = bearishEngulf or breakLow or blackCrows
reversal = switch
whiteSoldiers => not soaring[1] and not soaring[2]
blackCrows => not tumbling[1] and not tumbling[2]
breakHigh => not soaring[1] and (bearish[1] or bearish[2])
breakLow => not tumbling[1] and (bullish[1] or bullish[2])
continuation = switch
breakHigh => bullish[2] and close > high[2] and not bearish[1]
breakLow => bearish[2] and close < low[2] and not bullish[1]
// B. PIVOT ZONES
var buyzoneHigh = array.new_float(0)
var buyzoneLow = array.new_float(0)
var buyzoneTime = array.new_int(0)
var bounceUp = array.new_bool(0)
dacbar = switch
upturn => whiteSoldiers ? 3 : (breakHigh and selling[2] ? 2 : 1)
downturn => blackCrows ? 3 : (breakLow and buying[2] ? 2 : 1)
pivotbar = switch
upturn => whiteSoldiers ? 2 : (green1[1] ? 1 : 0)
downturn => blackCrows ? 2 : (red1[1] ? 1 : 0)
switch
upturn =>
// Low at wick
pzLow := math.min(low[dacbar], low[pivotbar], low[1], low)
// High at wick or open
pzHigh := switch
close[pivotbar] > high[dacbar] => high[dacbar]
open[pivotbar] > open[dacbar] => open[pivotbar]
=> open[dacbar]
downturn =>
// High at wick
pzHigh := math.max(high[dacbar], high[pivotbar], high[1], high)
// Low at wick or open
pzLow := switch
close[pivotbar] < low[dacbar] => low[dacbar]
open[pivotbar] < open[dacbar] => open[pivotbar]
=> open[dacbar]
replace = switch
overlap and upturn => bounced(bounceUp)
overlap and downturn => bounced(bounceDown)
downturn =>
array.unshift(sellzoneHigh, pzHigh)
array.unshift(sellzoneLow, pzLow)
array.unshift(sellzoneTime, time[dacbar])
array.unshift(bounceDown, false)
newbox(bg) =>
box.new(0, 0, 0, 0, xloc=xloc.bar_time, border_color=na, bgcolor=bg,
extend=extend.right)
for i = 0 to maxbox(na(close[1]))
array.push(buyBox, newbox(demand))
array.push(sellBox, newbox(supply))
// C. ALERTS
if brokenHigh
alert('Breakout', alert.freq_once_per_bar)
if brokenLow
alert('Breakdown', alert.freq_once_per_bar)
if upturn or downturn
setup = switch
whiteSoldiers => 'White Soldiers'
blackCrows => 'Black Crows'
breakHigh => bullishEngulf ? 'Engulf & Break High' : 'Break High'
breakLow => bearishEngulf ? 'Engulf & Break Low' : 'Break Low'
bullishEngulf => 'Bullish Engulf'
bearishEngulf => 'Bearish Engulf'
occurence = replace ? 'Replace' : (overlap ? 'Bounce' : 'Fresh')
message = setup + ' (' + occurence + ')'
alert(message, alert.freq_once_per_bar_close)
//---------------------------------------------------------------------------------
--------------------------------------------------------------------------------
//HH harmonics
//---------------------------------------------------------------------------------
--------------------------------------------------------------------------------
A1 = input.int(111, step=10)
A2 = input.int(111, step=10)
A3 = input.int(111, step=10)
A4 = input.int(111, step=10)
A5 = input.int(111, step=10)
CRAK1 = input.int(13, step=10)
CRAK2 = input.int(17, step=10)
CRAK3 = input.int(110, step=10)
CRAK4 = input.int(109, step=10)
CRAK5 = input.int(103, step=10)
CRAK6 = input.int(1, step=10)
CRAK7 = input.int(1, step=10)
CRAK8 = input.int(9, step=10)
CRAK9 = input.int(11, step=10)
CRAK10 = input.int(120, step=10)
CRAK11 = input.int(200, step=10)
CRAK12 = input.int(200, step=10)
CRAK13 = input.int(110, step=10)
CRAK14 = input.int(11, step=10)
CRAK15 = input.int(12, step=10)
CRAK16 = input.int(2, step=10)
CRAK17 = input.int(1, step=10)
CRAK18 = input.int(2, step=10)
CRAK19 = input.int(1, step=10)
CRAK20 = input.int(2, step=10)
///
DETECT3 = input.int(18, step=10)
PATTERN1 = input(true)
PATTERN10 = input.int(24, step=5, minval=1)
COLORP1 = input(color.rgb(43, 52, 146, 100))
zigzag1Width = 1
zigzag1Style = line.style_dotted
PATTERN2 = input(true)
PATTERN20 = input.int(24, step=5, minval=1)
COLORP2 = input(color.rgb(43, 52, 146, 100))
zigzag2Width = 1
zigzag2Style = line.style_dotted
PATTERN3 = input(true)
PATTERN30 = input.int(35, step=5, minval=1)
COLORP3 = input(color.rgb(43, 52, 146, 100))
zigzag3Width = 1
zigzag3Style = line.style_dotted
PATTERN4 = input(true)
PATTERN40 = input.int(35, step=5, minval=1)
COLORP4 = input(color.rgb(43, 52, 146, 100))
zigzag4Width = 1
zigzag4Style = line.style_dotted
P11 = input(true)
P22 = input(true)
P33 = input(true)
P44 = input(true)
P55 = input(true)
P66 = input(true)
DETECTM = input.int(18, minval=5, step=5, maxval=200)
//
DATAC = input.int(350, step=10)
DATAC2 = input.int(400, step=10)
//
MaxRiskPerReward = input.int(29, title='DETECT/PER', step=10, minval=0)
//
//
E1 = input.int(370, step=10)
E2 = input.int(390, step=10)
showStatTable = false
CANCLE_PATTERNS = input(false)
//
CRAKD90 = input.int(200, step=10)
CRAKFALSE200 = input.int(200, step=10)
CRAKFALSE100 = input.int(300, step=10)
///
BULL_PATTERNS = input(color.rgb(2, 115, 21))
BEAR_PATTERNS = input(color.rgb(199, 23, 3))
pivots(length) =>
float phigh = ta.highestbars(high, length) == 0 ? high : na
float plow = ta.lowestbars(low, length) == 0 ? low : na
dir = 0
iff_1 = plow and na(phigh) ? -1 : dir[1]
dir := phigh and na(plow) ? 1 : iff_1
[dir, phigh, plow]
if phigh or plow
value = dir == 1 ? phigh : plow
bar = bar_index
newDir = dir
if not dirchanged and array.size(zigzagpivots) >= 1
pivot = array.shift(zigzagpivots)
pivotbar = array.shift(zigzagpivotbars)
pivotdir = array.shift(zigzagpivotdirs)
useNewValues = value * pivotdir < pivot * pivotdir
value := useNewValues ? pivot : value
bar := useNewValues ? pivotbar : bar
bar
if array.size(zigzagpivots) >= 2
LastPoint = array.get(zigzagpivots, 1)
newDir := dir * value > dir * LastPoint ? dir * 2 : dir
newDir
array.unshift(zigzagpivots, value=value)
array.unshift(zigzagpivotbars, bar)
array.unshift(zigzagpivotdirs, newDir)
d = array.get(zigzagpivots, start + 0)
dBar = array.get(zigzagpivotbars, start + 0)
dDir = array.get(zigzagpivotdirs, start + 0)
c = array.get(zigzagpivots, start + 1)
cBar = array.get(zigzagpivotbars, start + 1)
cDir = array.get(zigzagpivotdirs, start + 1)
b = array.get(zigzagpivots, start + 2)
bBar = array.get(zigzagpivotbars, start + 2)
bDir = array.get(zigzagpivotdirs, start + 2)
a = array.get(zigzagpivots, start + 3)
aBar = array.get(zigzagpivotbars, start + 3)
aDir = array.get(zigzagpivotdirs, start + 3)
x = array.get(zigzagpivots, start + 4)
xBar = array.get(zigzagpivotbars, start + 4)
xDir = array.get(zigzagpivotdirs, start + 4)
y = array.get(zigzagpivots, start + 5)
yBar = array.get(zigzagpivotbars, start + 5)
yDir = array.get(zigzagpivotdirs, start + 5)
highPoint = math.max(x, a, b, c, d)
lowPoint = math.min(x, a, b, c, d)
dir = c > d ? 1 : -1
risk = math.abs(b - d)
reward = math.abs(c - d)
riskPerReward = risk * 100 / (risk + reward)
if b < highPoint and b > lowPoint
//gartley
if P11 and xabRatio >= 0.588 * err_min and xabRatio <= 0.648 * err_max
and abcRatio >= 0.382 * err_min and abcRatio <= 0.886 * err_max and xadRatio >=
0.866 * err_min and xadRatio <= 0.886 * err_max
wm_pattern := true
array.set(wmLabels, 0, true)
else
array.set(wmLabels, 0, false)
//Crab
if P22 and xabRatio >= 0.382 * err_min and xabRatio <= 0.618 * err_max
and abcRatio >= 0.382 * err_min and abcRatio <= 0.886 * err_max and xadRatio >=
1.802 * err_min and xadRatio <= 1.902 * err_max
wm_pattern := true
array.set(wmLabels, 1, true)
else
array.set(wmLabels, 1, false)
//Deep Crab
if P33 and xabRatio >= 0.886 * err_min and xabRatio <= 0.936 * err_max
and abcRatio >= 0.382 * err_min and abcRatio <= 0.886 * err_max and xadRatio >=
1.802 * err_min and xadRatio <= 1.902 * err_max
wm_pattern := true
array.set(wmLabels, 2, true)
else
array.set(wmLabels, 2, false)
//Bat
if P44 and xabRatio >= 0.382 * err_min and xabRatio <= 0.55 * err_max
and abcRatio >= 0.382 * err_min and abcRatio <= 0.886 * err_max and xadRatio >=
0.886 * err_min and xadRatio <= 0.886 * err_max
wm_pattern := true
array.set(wmLabels, 3, true)
else
array.set(wmLabels, 3, false)
//Butterfly
if P55 and xabRatio >= 0.755 * err_min and xabRatio <= 0.816 * err_max
and abcRatio >= 0.382 * err_min and abcRatio <= 0.886 * err_max and xadRatio >=
1.272 * err_min and xadRatio <= 1.272 * err_max
wm_pattern := true
array.set(wmLabels, 4, true)
else
array.set(wmLabels, 4, false)
//Shark
if P66 and xabRatio >= 0.382 * err_min and xabRatio <= 0.618 * err_max
and abcRatio >= 1.13 * err_min and abcRatio <= 1.618 * err_max and xadRatio >= 1 *
err_min and xadRatio <= 1.13 * err_max
wm_pattern := true
array.set(wmLabels, 5, true)
else
array.set(wmLabels, 5, false)
cancelW = false
cancelA = false
cancelD = false
if wm_pattern[1] and x == x[1] and a == a[1] and b == b[1] and c == c[1]
line.delete(array.get(wmlines, 0))
line.delete(array.get(wmlines, 1))
line.delete(array.get(wmlines, 2))
line.delete(array.get(wmlines, 3))
line.delete(array.get(wmlines, 4))
line.delete(array.get(wmlines, 5))
line.delete(array.get(wmlines, 6))
line.delete(array.get(wmlines, 7))
label.delete(array.get(wmlabel, 0))
cancelW := true
cancelW
if wm_pattern
xa = line.new(y1=x, y2=a, x1=xBar, x2=aBar, color=zigzagColor,
width=zigzagWidth, style=zigzagStyle)
ab = line.new(y1=a, y2=b, x1=aBar, x2=bBar, color=zigzagColor,
width=zigzagWidth, style=zigzagStyle)
bc = line.new(y1=b, y2=c, x1=bBar, x2=cBar, color=zigzagColor,
width=zigzagWidth, style=zigzagStyle)
cd = line.new(y1=c, y2=d, x1=cBar, x2=dBar, color=zigzagColor,
width=zigzagWidth, style=zigzagStyle)
xb = line.new(y1=x, y2=b, x1=xBar, x2=bBar, color=zigzagColor,
width=zigzagWidth, style=zigzagStyle)
bd = line.new(y1=b, y2=d, x1=bBar, x2=dBar, color=zigzagColor,
width=zigzagWidth, style=zigzagStyle)
xd = line.new(y1=x, y2=d, x1=xBar, x2=dBar, color=zigzagColor,
width=zigzagWidth, style=zigzagStyle)
ac = line.new(y1=a, y2=c, x1=aBar, x2=cBar, color=zigzagColor,
width=zigzagWidth, style=zigzagStyle)
array.set(wmlines, 0, xa)
array.set(wmlines, 1, ab)
array.set(wmlines, 2, bc)
array.set(wmlines, 3, cd)
array.set(wmlines, 4, xb)
array.set(wmlines, 5, bd)
array.set(wmlines, 6, xd)
array.set(wmlines, 7, ac)
array.set(wmtype, 0, dir)
linefill.new(xa, xb, color=color.rgb(44, 93, 136, 100))
linefill.new(bc, bd, color=color.rgb(44, 93, 136, 100))
if abcd_pattern and not wm_pattern
ab = line.new(y1=a, y2=b, x1=aBar, x2=bBar, color=zigzagColor,
width=zigzagWidth, style=zigzagStyle)
bc = line.new(y1=b, y2=c, x1=bBar, x2=cBar, color=zigzagColor,
width=zigzagWidth, style=zigzagStyle)
cd = line.new(y1=c, y2=d, x1=cBar, x2=dBar, color=zigzagColor,
width=zigzagWidth, style=zigzagStyle)
array.set(wmlines, 1, ab)
array.set(wmlines, 2, bc)
array.set(wmlines, 3, cd)
array.set(wmtype, 0, dir)
if double_pattern and not wm_pattern
bd = line.new(y1=b, y2=d, x1=bBar, x2=dBar, color=zigzagColor,
width=zigzagWidth, style=zigzagStyle)
array.set(wmlines, 5, bd)
array.set(wmtype, 0, dir)
for i = 0 to array.size(zigzagpivots1) - 1 by 1
bgcolor = array.get(zigzagpivotdirs1, i) == 1 ? color.lime :
color.orange
table.cell(table_id=stats, column=0, row=i + 2,
text=str.tostring(array.get(zigzagpivots1, i)), bgcolor=bgcolor)
table.cell(table_id=stats, column=1, row=i + 2,
text=str.tostring(array.get(zigzagpivotbars2, i)), bgcolor=bgcolor)
if PATTERN2
table.cell(table_id=stats, column=2, row=0, text='Zigzag ' +
str.tostring(PATTERN20), bgcolor=color.black, text_color=color.white)
table.cell(table_id=stats, column=2, row=1, text='Price',
bgcolor=color.black, text_color=color.white)
table.cell(table_id=stats, column=3, row=1, text='BarIndex',
bgcolor=color.black, text_color=color.white)
for i = 0 to array.size(zigzagpivots2) - 1 by 1
bgcolor = array.get(zigzagpivotdirs2, i) == 1 ? color.lime :
color.orange
table.cell(table_id=stats, column=2, row=i + 2,
text=str.tostring(array.get(zigzagpivots2, i)), bgcolor=bgcolor)
table.cell(table_id=stats, column=3, row=i + 2,
text=str.tostring(array.get(zigzagpivotbars2, i)), bgcolor=bgcolor)
if PATTERN3
table.cell(table_id=stats, column=4, row=0, text='Zigzag ' +
str.tostring(PATTERN30), bgcolor=color.black, text_color=color.white)
table.cell(table_id=stats, column=4, row=1, text='Price',
bgcolor=color.black, text_color=color.white)
table.cell(table_id=stats, column=5, row=1, text='BarIndex',
bgcolor=color.black, text_color=color.white)
for i = 0 to array.size(zigzagpivots3) - 1 by 1
bgcolor = array.get(zigzagpivotdirs3, i) == 1 ? color.lime :
color.orange
table.cell(table_id=stats, column=4, row=i + 2,
text=str.tostring(array.get(zigzagpivots3, i)), bgcolor=bgcolor)
table.cell(table_id=stats, column=5, row=i + 2,
text=str.tostring(array.get(zigzagpivotbars3, i)), bgcolor=bgcolor)
if PATTERN4
table.cell(table_id=stats, column=6, row=0, text='Zigzag ' +
str.tostring(PATTERN40), bgcolor=color.black, text_color=color.white)
table.cell(table_id=stats, column=6, row=1, text='Price',
bgcolor=color.black, text_color=color.white)
table.cell(table_id=stats, column=7, row=1, text='BarIndex',
bgcolor=color.black, text_color=color.white)
for i = 0 to array.size(zigzagpivots4) - 1 by 1
bgcolor = array.get(zigzagpivotdirs4, i) == 1 ? color.lime :
color.orange
table.cell(table_id=stats, column=6, row=i + 2,
text=str.tostring(array.get(zigzagpivots4, i)), bgcolor=bgcolor)
table.cell(table_id=stats, column=7, row=i + 2,
text=str.tostring(array.get(zigzagpivotbars4, i)), bgcolor=bgcolor)
/////////
//'
////////////another1
get_color(rsi) =>
clr = color.white
if rsi >= 0 and rsi <= 25
clr := color.from_gradient(rsi, 0 , 25 , color.rgb(69, 13, 85, 40),
color.rgb(64, 70, 137 , 40))
if rsi > 25 and rsi <= 50
clr := color.from_gradient(rsi, 25, 50 , color.rgb(57, 87, 141, 40),
color.rgb(35, 139, 140, 40))
if rsi > 50 and rsi <= 75
clr := color.from_gradient(rsi, 50, 75 , color.rgb(30, 150, 138, 40),
color.rgb(85, 199, 103, 40))
if rsi > 75 and rsi <= 100
clr := color.from_gradient(rsi, 75, 100, color.rgb(115, 208, 85, 40),
color.rgb(253, 230, 36, 40))
clr
interp(l, h, s) => l + (h - l) * s
//PIVOT POINTS
type PivotPoint
float price
int index
if array.size(high_pivots) > 1
if i_drawpivots
for pivot in high_pivots
array.push(labels, label.new(pivot.index, pivot.price, "",
style=label.style_label_down, size=size.tiny, color=color.new(#99d31b, 100)))
tmp = array.new_line()
for i = 0 to array.size(high_pivots) - 1
for j = i to array.size(high_pivots) - 1
if i != j
PivotPoint pp0 = array.get(high_pivots, i)
PivotPoint pp1 = array.get(high_pivots, j)
array.push(tmp, line.new(pp0.index, pp0.price, pp1.index,
pp1.price, color=i_hcolor, width = 1, style = line.style_dashed))
best_ind = int(na)
if i_trend_old_method
min_val = 10000000.0
for i = 0 to array.size(tmp) - 1
lp = line.get_price(array.get(tmp, i), bar_index)
if lp > high
if min_val > math.abs(lp - close)
min_val := math.abs(lp - close)
best_ind := i
else
best_cnt = 0
for i = 0 to array.size(tmp) - 1
trend = array.get(tmp, i)
cnt = 0
if cnt == best_cnt
if line.get_price(array.get(tmp, best_ind), bar_index + 1) >
line.get_price(trend, bar_index + 1) and line.get_price(trend, bar_index + 1) >
i_hsource
best_cnt := cnt
best_ind := i
if not na(best_ind)
line.delete(high_trend)
high_trend := array.get(tmp, best_ind)
array.remove(tmp, best_ind)
if array.size(low_pivots) > 1
if i_drawpivots
for pivot in low_pivots
array.push(labels, label.new(pivot.index, pivot.price, "",
style=label.style_label_up, size=size.tiny, color=color.new(#FA5032, 100)))
tmp = array.new_line()
for i = 0 to array.size(low_pivots) - 1
for j = i to array.size(low_pivots) - 1
if i != j
PivotPoint pp0 = array.get(low_pivots, i)
PivotPoint pp1 = array.get(low_pivots, j)
array.push(tmp, line.new(pp0.index, pp0.price, pp1.index,
pp1.price, color=i_lcolor, width = 1, style = line.style_dashed))
best_ind = int(na)
if i_trend_old_method
min_val = 100000.0
for i = 0 to array.size(tmp) - 1
lp = line.get_price(array.get(tmp, i), bar_index)
if lp < low
if min_val > math.abs(lp - close)
min_val := math.abs(lp - close)
best_ind := i
else
best_cnt = 0
for i = 0 to array.size(tmp) - 1
trend = array.get(tmp, i)
cnt = 0
if cnt == best_cnt
if line.get_price(array.get(tmp, best_ind), bar_index + 1) <
line.get_price(trend, bar_index + 1) and line.get_price(trend, bar_index + 1) <
i_lsource
best_cnt := cnt
best_ind := i
if not na(best_ind)
line.delete(low_trend)
low_trend := array.get(tmp, best_ind)
array.remove(tmp, best_ind)
for l in labels
if label.get_x(l) == line.get_x1(high_trend) or label.get_x(l) ==
line.get_x2(high_trend)
label.set_color(l, color.new(#99d31b, 0))
line.set_y2(high_trend, line.get_price(high_trend, bar_index + i_trend_extlen))
line.set_x2(high_trend, bar_index + i_trend_extlen)
line.set_width(high_trend, i_htrend_width)
line.set_style(high_trend, i_htrend_style)
if line.get_x1(low_trend) > line.get_x1(high_trend)
line.set_y1(low_trend, line.get_price(low_trend, line.get_x1(high_trend)))
line.set_x1(low_trend, line.get_x1(high_trend))
//HEATMAP
var fills = array.new_linefill()
var lines1 = array.new_line()
//FIBONACI
var fibs = array.new_line()
if i_drawfibs_extended
left_val := interp(line.get_price(low_trend, left) ,
line.get_price(high_trend, left) , 2.618)
right_val := interp(line.get_price(low_trend, right),
line.get_price(high_trend, right), 2.618)
array.push(fibs, line.new(left, left_val, right, right_val,
style=i_fibline_styles, width=i_fibline_widths,
color=color.from_gradient(right_val, line.get_price(low_trend, right),
line.get_price(high_trend, right), i_lcolor , i_hcolor)))
left_val := interp(line.get_price(low_trend, left) ,
line.get_price(high_trend, left) , 3.618)
right_val := interp(line.get_price(low_trend, right),
line.get_price(high_trend, right), 3.618)
array.push(fibs, line.new(left, left_val, right, right_val,
style=i_fibline_styles, width=i_fibline_widths,
color=color.from_gradient(right_val, line.get_price(low_trend, right),
line.get_price(high_trend, right), i_lcolor , i_hcolor)))
left_val := interp(line.get_price(low_trend, left) ,
line.get_price(high_trend, left) , 4.236)
right_val := interp(line.get_price(low_trend, right),
line.get_price(high_trend, right), 4.236)
array.push(fibs, line.new(left, left_val, right, right_val,
style=i_fibline_styles, width=i_fibline_widths,
color=color.from_gradient(right_val, line.get_price(low_trend, right),
line.get_price(high_trend, right), i_lcolor , i_hcolor)))
//ALERTS
var line alert_zone_low = line(na)
var line alert_zone_high = line(na)
var linefill alert_zone_low_linefill = linefill(na)
var linefill alert_zone_high_linefill = linefill(na)
var label alert_label = label(na)
label.delete(alert_label)
if i_alerts_draw_alert_zones
line.delete(alert_zone_low)
line.delete(alert_zone_high)
x0 = bar_index
y0 = clp + (chp - clp) * i_alerts_low_trend_trigger_pct
x1 = bar_index + i_trend_extlen
y1 = line.get_price(low_trend, x1) + (line.get_price(high_trend, x1) -
line.get_price(low_trend, x1)) * i_alerts_low_trend_trigger_pct
alert_zone_low := line.new(x0, y0, x1, y1, color=i_lcolor)
if i_alerts_fill_alert_zones
linefill.delete(alert_zone_low_linefill)
alert_zone_low_linefill := linefill.new(low_trend, alert_zone_low,
color.new(i_lcolor, 70))
x0 := bar_index
y0 := clp + (chp - clp) * (1.0 - i_alerts_high_trend_trigger_pct)
x1 := bar_index + i_trend_extlen
y1 := line.get_price(low_trend, x1) + (line.get_price(high_trend, x1) -
line.get_price(low_trend, x1)) * (1.0 - i_alerts_high_trend_trigger_pct)
alert_zone_high := line.new(x0, y0, x1, y1, color=i_hcolor)
if i_alerts_fill_alert_zones
linefill.delete(alert_zone_high_linefill)
alert_zone_high_linefill := linefill.new(high_trend, alert_zone_high,
color.new(i_hcolor, 70))
//---------------------------------------------------------------------------------
--------------------------------------------------------------------------------
//MTF hhLL/with table
//---------------------------------------------------------------------------------
--------------------------------------------------------------------------------
// Input Parameters
start_time = input.time(timestamp("01 Jan 1900"))
type class_visuals
bool plot_line = false
bool plot_label = false
color clr
int width
if(bar_index == 0)
visuals.put('CTF', class_visuals.new(plot_ctf_zigzag, plot_ctf_hhll_labels,
color_ctf, width_ctf))
visuals.put('HTF', class_visuals.new(plot_htf_zigzag, plot_htf_hhll_labels,
color_htf, width_htf))
visuals.put('HTF1', class_visuals.new(plot_htf1_zigzag, plot_htf1_hhll_labels,
color_htf1, width_htf1))
type class_hhll
string group //H or l
string sub_group // HH, LL, LH, HL
int bar_id
int bar_time
float pivot_pp
line ln
label lbl
float rsi
float stoc
float adx
float sma20
float sma50
float sma100
float sma200
float price_move
float price_change
float cum_volume
float swing_volume
string tf
bool is_new = false
type class_ohlc
bool pivot
float pp
int bar_id
int bar_time
float rsi
float stoc
float adx
float sma20
float sma50
float sma100
float sma200
float cum_volume
get_ph_pl(i) =>
ph = class_ohlc.new(pivot = false)
pl = class_ohlc.new(pivot = false)
_ph = ta.pivothigh(high[i], lb, rb)
_pl = ta.pivotlow(low[i], lb, rb)
// __ph = ta.pivothigh(high[i], lb, rb)
// __pl = ta.pivotlow(low[i], lb, rb)
// _ph = __ph != 0 ? true : false
// _pl = __pl != 0 ? true : false
[ph, pl]
hhll.unshift(new_rec)
true
//#region Main
//main code
[ph_ctf, pl_ctf] = get_ph_pl(0)
hhll_ctf.add_ph(ph_ctf, visuals.get('CTF'), ctf)
hhll_ctf.add_pl(pl_ctf, visuals.get('CTF'), ctf)
//HTF code
new_htf = timeframe.change(htf)
[ph_htf, pl_htf] = request.security('', htf, get_ph_pl(htf_offset))
if(na(ph_htf) or not new_htf)
ph_htf := class_ohlc.new(false)
if(na(pl_htf) or not new_htf)
pl_htf := class_ohlc.new(false)
//HTF 1 code
new_htf1 = timeframe.change(htf1)
[ph_htf1, pl_htf1] = request.security('', htf1, get_ph_pl(htf1_offset))
if(na(ph_htf1) or not new_htf1)
ph_htf1 := class_ohlc.new(false)
if(na(pl_htf1) or not new_htf1)
pl_htf1 := class_ohlc.new(false)
//------------------------------------------------------------------------------
// === Range Detector ===
//------------------------------------------------------------------------------
//Style
upCss = input(#089981, 'Broken Upward', group = 'Style')
dnCss = input(#f23645, 'Broken Downward', group = 'Style')
unbrokenCss = input(#2157f3, 'Unbroken', group = 'Style')
//-----------------------------------------------------------------------------}
//Detect and highlight ranges
//-----------------------------------------------------------------------------{
//Ranges drawings
var box bx = na
var line lvl = na
//Extensions
var float max2 = na
var float min2 = na
var os = 0
color detect_css = na
else if count == 0
bx.set_right(n)
lvl.set_x2(n)
//Set color
if close > bx.get_top()
bx.set_bgcolor(color.new(#ff5252, 100))
lvl.set_color(upCss)
os := 1
else if close < bx.get_bottom()
bx.set_bgcolor(color.new(#ff5252, 100))
lvl.set_color(dnCss)
os := -1
//-----------------------------------------------------------------------------}
//Plots
//-----------------------------------------------------------------------------{
//Range detection bgcolor
bgcolor(detect_css)
//-----------------------------------------------------------------------------}
//-----------------------------------------------------------------------------}
//INPUTS
cooldownPeriod = input.int(10,title="Cooldown Period", minval=0, group =
"Settings")
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
bullCond = bullishSFP[3] and (close > pLowVal) and (close[1] > pLowVal[1]) and
(close[2] > pLowVal[2]) and bar_index >= bullSignalIndex + cooldownPeriod
bearCond = bearishSFP[3] and (close < pHighVal) and (close[1] < pHighVal[1]) and
(close[2] < pHighVal[2]) and bar_index >= bearSignalIndex + cooldownPeriod
if bearCond
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(bullCond, text='Sweep', color=bullColor, textcolor=bullColor,
location=location.belowbar, offset = -3)
plotshape(bearCond, 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}}')