Bodya Swings Strategy Precise Entry
Bodya Swings Strategy Precise Entry
//Style
showTop = input(true, 'Swing High' , inline = 'top', group =
'Style')
topCss = input(color.red, '' , inline = 'top', group =
'Style')
topAreaCss = input(color.new(color.red, 50), 'Area', inline = 'top', group =
'Style')
n = bar_index
get_data()=> [high, low, volume]
[h, l, v] = request.security_lower_tf(syminfo.tickerid, intrabarTf, get_data())
ph = ta.pivothigh(length, length)
[ph_count, ph_vol] = get_counts(ph, ph_top, ph_btm)
if ph and showTop
ph_top := high[length]
ph_btm := switch area
'Wick Extremity' => math.max(close[length], open[length])
'Full Range' => low[length]
ph_x1 := n - length
ph_crossed := false
box.set_lefttop(ph_bx, ph_x1, ph_top)
box.set_rightbottom(ph_bx, ph_x1, ph_btm)
alert("Swing High detected", alert.freq_once_per_bar_close)
else
ph_crossed := close > ph_top ? true : ph_crossed
if ph_crossed
box.set_right(ph_bx, ph_x1)
else
box.set_right(ph_bx, n+3)
if showTop
set_zone(ph, ph_x1, ph_top, ph_btm, ph_count, ph_vol, topAreaCss)
set_level(ph, ph_crossed, ph_top, ph_count, ph_vol, topCss)
set_label(ph_count, ph_vol, ph_x1, ph_top, topCss, label.style_label_down)
if not na(ph_top) and high >= ph_top and not na(ph_x1) and bar_index > ph_x1
strategy.entry("LONG", strategy.long)
pl = ta.pivotlow(length, length)
[pl_count, pl_vol] = get_counts(pl, pl_top, pl_btm)
if pl and showBtm
pl_top := switch area
'Wick Extremity' => math.min(close[length], open[length])
'Full Range' => high[length]
pl_btm := low[length]
pl_x1 := n - length
pl_crossed := false
box.set_lefttop(pl_bx, pl_x1, pl_top)
box.set_rightbottom(pl_bx, pl_x1, pl_btm)
alert("Swing Low detected", alert.freq_once_per_bar_close)
else
pl_crossed := close < pl_btm ? true : pl_crossed
if pl_crossed
box.set_right(pl_bx, pl_x1)
else
box.set_right(pl_bx, n+3)
if showBtm
set_zone(pl, pl_x1, pl_top, pl_btm, pl_count, pl_vol, btmAreaCss)
set_level(pl, pl_crossed, pl_btm, pl_count, pl_vol, btmCss)
set_label(pl_count, pl_vol, pl_x1, pl_btm, btmCss, label.style_label_up)
if not na(pl_btm) and low <= pl_btm and not na(pl_x1) and bar_index > pl_x1
strategy.entry("SHORT", strategy.short)