switch close > open => isBuyVolume := true close < open => isBuyVolume := false
if isBuyVolume posVol += volume else negVol -= volume
posVol + negVol
// Function to identify support and resistance boxes calcSupportResistance(src, lookbackPeriod) => // Volume Vol = upAndDownVolume() vol_hi = ta.highest(Vol / 2.5, vol_len) vol_lo = ta.lowest(Vol / 2.5, vol_len)
var float supportLevel = na var float supportLevel_1 = na var float resistanceLevel = na var float resistanceLevel_1 = na var box sup = na var box res = na var color res_color = na var color sup_color = na var float multi = na
var bool brekout_res = na var bool brekout_sup = na var bool res_holds = na var bool sup_holds = na
// Change Color of Support to red if it was break, change color of resistance to green if it was break if brekout_sup sup.set_bgcolor(color.new(color.red, 80)) sup.set_border_color(color.red) sup.set_border_style(line.style_dashed)
if sup_holds sup.set_bgcolor(sup_color) sup.set_border_color(color.green) sup.set_border_style(line.style_solid)
if brekout_res res.set_bgcolor(color.new(color.green, 80)) res.set_border_color(color.new(color.green, 0)) res.set_border_style(line.style_dashed)
if res_holds res.set_bgcolor(res_color) res.set_border_color(color.new(color.red, 0)) res.set_border_style(line.style_solid)
// Calculate support and resistance levels and their breakouts [supportLevel, resistanceLevel, brekout_res, res_holds, sup_holds, brekout_sup] = calcSupportResistance(close, lookbackPeriod)
// Check if Resistance becomes Support or Support Becomes Resistance var bool res_is_sup = na var bool sup_is_res = na
// Plot Res and Sup breakouts and holds plotchar(res_holds, "Resistance Holds", "◆", color = #e92929, size = size.tiny, location = location.abovebar, offset = -1) plotchar(sup_holds, "Support Holds", "◆", color = #20ca26, size = size.tiny, location = location.belowbar, offset = -1)
plotchar(brekout_res and res_is_sup[1], "Resistance as Support Holds", "◆", color = #20ca26, size = size.tiny, location = location.belowbar, offset = -1) plotchar(brekout_sup and sup_is_res[1], "Support as Resistance Holds", "◆", color = #e92929, size = size.tiny, location = location.abovebar, offset = -1)
// Break Out Labels if brekout_sup and not sup_is_res[1] label.new( bar_index[1], supportLevel[1], text = "Break Sup", style = label.style_label_down, color = #7e1e1e, textcolor = chart.fg_color, size = size.small )
if brekout_res and not res_is_sup[1] label.new( bar_index[1], resistanceLevel[1], text = "Break Res", style = label.style_label_up, color = #2b6d2d, textcolor = chart.fg_color, size = size.small )
진정한 TradingView 정신에 따라, 이 스크립트의 저자는 트레이더들이 이해하고 검증할 수 있도록 오픈 소스로 공개했습니다. 저자에게 박수를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰에 의해 관리됩니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.