本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=4
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //
//# * ══════════════════════════════════════════════════════════════════════════════════════════════
//# *
//# * Study : Fibonacci Extention / Retracment / Pivot Points
//# * - Volume and Volatility AddOns
//# * Author : © dgtrd
//# *
//# * Revision History
//# * Release : Apr 19, 2021
//# *
//# * ══════════════════════════════════════════════════════════════════════════════════════════════
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //
study("Fibonacci Extention / Retracment / Pivot Points by DGT", "FIBs ʙʏ DGT ☼☾", true)
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //
//
// Fibonacci Retracement / Extention / Pivot Points and Zig Zag
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //
// ---------------------------------------------------------------------------------------------- //
// -Inputs -------------------------------------------------------------------------------------- //
tooltip_threshold = "Deviation is a multiplier that affects how much the price should deviate from the previous pivot in order for the bar to become a new pivot" +
"\n\nDepth affects the minimum number of bars that will be taken into account when building"
tooltip_pivot_point = "A pivot point is a technical analysis indicator used to determine the overall trend of the market over different time frames"
tooltip_zigzag = "The Zig Zag indicator is used to identify price trends then connected by straight lines that help the trader visual the price action" +
"This indicator works to eliminate confusion over small price changes or fluctuations and aims to project trend changes overtime"
group_fib_tool = "Fibonacci Tool Settings"
i_isFib = input(true , "Pick a Fibonacci Tool" , inline = "FIB" , group = group_fib_tool)
i_fibTool = input("Pivot Points" , " ",
options = ["Retracements", "Extentions", "Pivot Points"], inline = "FIB" , group = group_fib_tool)
i_dev_thresh = atr(10) / close * 100 * input(3, "Deviation", type = input.float, minval = 0 , inline = "Pivots", group = group_fib_tool, tooltip=tooltip_threshold)
i_depth = input(11 , " Depth", type = input.integer, minval = 1 , inline = "Pivots", group = group_fib_tool)
i_htf_mode = input('Auto' , "Pivot Points TF", options=['Auto', 'User Defined'] , inline = "HTF" , group = group_fib_tool, tooltip=tooltip_pivot_point)
i_htf_user = input('W' , "auto ", type=input.resolution , inline = "HTF" , group = group_fib_tool)
i_prevPivot = input(false , "Historical Extention/Retracment Levels" , inline = "hPVT" , group = group_fib_tool)
i_histPivot = input(1 , "", minval = 1 , inline = "hPVT" , group = group_fib_tool)
i_reverse = input(false , "Reverse Levels " , inline = "fLines", group = group_fib_tool)
i_levels = input(true , "Level Labels " , inline = "fLines", group = group_fib_tool)
i_extend = input(false , "Extend Lines" , inline = "fLines", group = group_fib_tool)
i_zigZag = input(false , "Zig Zag " , inline = "ZZ" , group = group_fib_tool, tooltip = tooltip_zigzag)
i_zzColor = input(#c77a08 , "" , inline = "ZZ" , group = group_fib_tool)
i_zzStyle = input("Solid" , "", options = ["Dashed", "Dotted", "Solid"] , inline = "ZZ" , group = group_fib_tool)
i_zzWidth = input(1 , "", minval = 1 , inline = "ZZ" , group = group_fib_tool)
// ---------------------------------------------------------------------------------------------- //
// -Calculations -------------------------------------------------------------------------------- //
var line lineLast = na
var int iLast = 0
var int iPrev = 0
var float pLast = 0
var isHighLast = false // otherwise the last pivot is a low pivot
var iPrevPivot = 0
var pPrevPivot = 0.
var iLastPivot = 0
var pLastPivot = 0.
pivots(src, length, isHigh) =>
l2 = length * 2
c = nz(src[length])
ok = true
for i = 0 to l2
if isHigh and src[i] > c
ok := false
if not isHigh and src[i] < c
ok := false
if ok
[bar_index[length], c]
else
[int(na), float(na)]
[iH, pH] = pivots(high, i_depth / 2, true )
[iL, pL] = pivots(low , i_depth / 2, false)
calc_dev(base_price, price) => 100 * (price - base_price) / price
pivotFound(dev, isHigh, index, price) =>
if isHighLast == isHigh and not na(lineLast)
// same direction
if isHighLast ? price > pLast : price < pLast
line.set_xy2(lineLast, index, price)
[lineLast, isHighLast]
else
[line(na), bool(na)]
else // reverse the direction (or create the very first line)
if abs(dev) > i_dev_thresh
// price move is significant
// ---------------------------------------------------------------------------------------- //
[zzCol, zzWid, zzSty] = if not i_zigZag
[na, 1, line.style_dashed]
else
[i_zzColor, i_zzWidth, i_zzStyle == "Solid" ? line.style_solid : i_zzStyle == "Dotted" ? line.style_dotted : line.style_dashed]
// ---------------------------------------------------------------------------------------- //
id = line.new(iLast, pLast, index, price, color=zzCol, width=zzWid, style=zzSty)
[id, isHigh]
else
[line(na), bool(na)]
if not na(iH)
dev = calc_dev(pLast, pH)
[id, isHigh] = pivotFound(dev, true, iH, pH)
if not na(id)
if id != lineLast
// ---------------------------------------------------------------------------------------- //
iPrevPivot := line.get_x1(lineLast)
pPrevPivot := line.get_y1(lineLast)
iLastPivot := line.get_x2(lineLast)
pLastPivot := line.get_y2(lineLast)
if not i_zigZag
// ---------------------------------------------------------------------------------------- //
line.delete(lineLast)
lineLast := id
isHighLast := isHigh
iPrev := iLast
iLast := iH
pLast := pH
else
if not na(iL)
dev = calc_dev(pLast, pL)
[id, isHigh] = pivotFound(dev, false, iL, pL)
if not na(id)
if id != lineLast
// ---------------------------------------------------------------------------------------- //
iPrevPivot := line.get_x1(lineLast)
pPrevPivot := line.get_y1(lineLast)
iLastPivot := line.get_x2(lineLast)
pLastPivot := line.get_y2(lineLast)
if not i_zigZag
// ---------------------------------------------------------------------------------------- //
line.delete(lineLast)
lineLast := id
isHighLast := isHigh
iPrev := iLast
iLast := iL
pLast := pL
iStartBase = i_prevPivot ? valuewhen(change(iPrevPivot), iPrevPivot, i_histPivot ) : valuewhen(change(iPrevPivot), iPrevPivot, 0)
pStartBase = i_prevPivot ? valuewhen(change(pPrevPivot), pPrevPivot, i_histPivot ) : valuewhen(change(pPrevPivot), pPrevPivot, 0)
iEndBase = i_prevPivot ? valuewhen(change(iLastPivot), iLastPivot, i_histPivot - 1) : line.get_x2(lineLast)
pEndBase = i_prevPivot ? valuewhen(change(pLastPivot), pLastPivot, i_histPivot - 1) : line.get_y2(lineLast)
iMidPivot = i_prevPivot ? valuewhen(change(iPrevPivot), iPrevPivot, i_histPivot - 1) : line.get_x1(lineLast)
pMidPivot = i_prevPivot ? valuewhen(change(pPrevPivot), pPrevPivot, i_histPivot - 1) : line.get_y1(lineLast)
//------------------------------------------------------------------------------
// auto higher time frame code snippet from pine wizard LonesomeTheBlue
htf_auto = timeframe.period == '1' ? '240' :
timeframe.period == '3' ? '240' :
timeframe.period == '5' ? '240' :
timeframe.period == '15' ? 'D' :
timeframe.period == '30' ? 'D' :
timeframe.period == '45' ? 'D' :
timeframe.period == '60' ? 'W' :
timeframe.period == '120' ? 'W' :
timeframe.period == '180' ? 'W' :
timeframe.period == '240' ? 'W' :
timeframe.period == 'D' ? 'M' :
timeframe.period == 'W' ? '3M' :
'12M'
htf = i_htf_mode == 'Auto' ? htf_auto : i_htf_user
//------------------------------------------------------------------------------
// security function free price calculations
f_htf_ohlc(_htf) =>
var htf_o = 0. // higher time frame open
var htf_h = 0. // higher time frame high
var htf_l = 0. // higher time frame low
htf_c = close // higher time frame close
var htf_ox = 0. // previous higher time frame open
var htf_hx = 0. // previous higher time frame high
var htf_lx = 0. // previous higher time frame low
var htf_cx = 0. // previous higher time frame close
if change(time(_htf))
htf_ox := htf_o
htf_o := open
htf_hx := htf_h
htf_h := high
htf_lx := htf_l
htf_l := low
htf_cx := htf_c[1]
else
htf_h := high > htf_h ? high : htf_h
htf_l := low < htf_l ? low : htf_l
[htf_ox, htf_hx, htf_lx, htf_cx, htf_o, htf_h, htf_l, htf_c]
[_, htf_h1, htf_l1, htf_c1, _, _, _, _] = f_htf_ohlc(htf)
// ---------------------------------------------------------------------------------------------- //
// -Plotting ------------------------------------------------------------------------------------ //
time_x10 = valuewhen(change(time(htf)), time, 1)
time_x11 = valuewhen(change(time(htf)), time, 0)
time_x21 = 2 * time_x11 - time_x10
f_drawLineX(_x1, _y1, _x2, _y2, _xloc, _extend, _color, _style, _width) =>
var id = line.new(_x1, _y1, _x2, _y2, _xloc, _extend, _color, _style, _width)
line.set_xy1(id, _x1, _y1)
line.set_xy2(id, _x2, _y2)
f_drawLabelX(_x, _y, _text, _xloc, _yloc, _color, _style, _textcolor, _size, _textalign, _tooltip) =>
var id = label.new(_x, _y, _text, _xloc, _yloc, _color, _style, _textcolor, _size, _textalign, _tooltip)
label.set_xy (id, _x, _y)
label.set_text (id, i_extend ? _text + '\n\n' : _text)
label.set_tooltip(id, tostring(round(_y / syminfo.mintick) * syminfo.mintick))
f_crossingLevel(_curret, _level) =>
(_level > _curret and _level < _curret[1]) or (_level < _curret and _level > _curret[1])
f_processLevelX(_show, _level, _color) =>
if i_isFib
pPivotDiff = abs(pMidPivot - pEndBase)
price = 0.
if i_fibTool == "Extentions"
f_drawLineX(iStartBase, pStartBase, iMidPivot, pMidPivot, xloc.bar_index, extend.none, color.gray, line.style_dashed, 1)
f_drawLineX(iMidPivot , pMidPivot , iEndBase , pEndBase , xloc.bar_index, extend.none, color.gray, line.style_dashed, 1)
offset = abs(pMidPivot - pStartBase)
price := pEndBase < pMidPivot ? pMidPivot - pPivotDiff + (i_reverse ? -1 : 1) * offset * _level : pMidPivot + pPivotDiff - (i_reverse ? -1 : 1) * offset * _level
else if i_fibTool == "Retracements"
f_drawLineX(iMidPivot , pMidPivot , iEndBase , pEndBase , xloc.bar_index, extend.none, color.gray, line.style_dashed, 1)
price := pEndBase < pMidPivot ? (i_reverse ? pEndBase : pMidPivot) - (i_reverse ? -1 : 1) * pPivotDiff * _level : (i_reverse ? pEndBase : pMidPivot) + (i_reverse ? -1 : 1) * pPivotDiff * _level
else
pivot = avg(htf_h1, htf_l1, htf_c1)
range = htf_h1 - htf_l1
f_drawLineX(time_x10, pivot, time_x21, pivot, xloc.bar_time, extend.none, color.gray, line.style_dashed, 1)
if _show
pvtPoints = _level == 0 or _level == 0.382 or _level == 0.618 or _level == 1
f_drawLineX(time_x11, pivot - range * _level, time_x21, pivot - range * _level, xloc.bar_time, i_extend ? extend.both : extend.none, _color, pvtPoints ? line.style_solid : line.style_dashed, pvtPoints ? 2 : 1)
f_drawLineX(time_x11, pivot + range * _level, time_x21, pivot + range * _level, xloc.bar_time, i_extend ? extend.both : extend.none, _color, pvtPoints ? line.style_solid : line.style_dashed, pvtPoints ? 2 : 1)
if i_levels
if pvtPoints
if _level == 0
f_drawLabelX(time_x21, pivot, "PP", xloc.bar_time, yloc.price, #00000000, label.style_label_left, _color, size.small, text.align_left, tostring(round(pivot / syminfo.mintick) * syminfo.mintick))
else
f_drawLabelX(time_x21, pivot - range * _level, (_level == 0.382 ? "S1 PP " : _level == 0.618 ? "S2 PP " : "S3 PP ") + tostring(_level), xloc.bar_time, yloc.price, #00000000, label.style_label_left, _color, size.small, text.align_left, tostring(pivot - range * _level))
f_drawLabelX(time_x21, pivot + range * _level, (_level == 0.382 ? "R1 PP " : _level == 0.618 ? "R2 PP " : "R3 PP ") + tostring(_level), xloc.bar_time, yloc.price, #00000000, label.style_label_left, _color, size.small, text.align_left, tostring(pivot + range * _level))
else if _level > 0
f_drawLabelX(time_x21, pivot - range * _level, " PP " + tostring(_level), xloc.bar_time, yloc.price, #00000000, label.style_label_left, _color, size.small, text.align_left, tostring(pivot - range * _level))
f_drawLabelX(time_x21, pivot + range * _level, " PP " + tostring(_level), xloc.bar_time, yloc.price, #00000000, label.style_label_left, _color, size.small, text.align_left, tostring(pivot + range * _level))
if f_crossingLevel(close, pivot - range * _level)
alert("FibPivotPoints : " + syminfo.ticker + " crossing support level " + tostring(_level))
if f_crossingLevel(close, pivot + range * _level)
alert("FibPivotPoints : " + syminfo.ticker + " crossing resistance level " + tostring(_level))
price
if _show and i_fibTool != "Pivot Points"
f_drawLineX(iMidPivot, price, bar_index, price, xloc.bar_index, i_extend ? extend.both : extend.right, _color, line.style_solid, 1)
if i_levels
f_drawLabelX(iMidPivot, price, (i_fibTool == "Extentions" ? "EXT " : "RET ") + tostring(_level), xloc.bar_index, yloc.price, #00000000, label.style_label_right, _color, size.small, text.align_left, tostring(price))
if f_crossingLevel(close, price)
alert("AutoFib " + (i_fibTool == "Extentions" ? "Extention : " : "Retracment : ") + syminfo.ticker + " crossing level " + tostring(_level))
group_fib_levels = "Fibonacci Levels"
show_0 = input(true , "", inline = "Level0" , group = group_fib_levels)
value_0 = input(0. , "", inline = "Level0" , group = group_fib_levels)
color_0 = input(#787b86, "", inline = "Level0" , group = group_fib_levels)
f_processLevelX(show_0, value_0, color_0)
show_0_236 = input(true , "", inline = "Level0" , group = group_fib_levels)
value_0_236 = input(0.236 , "", inline = "Level0" , group = group_fib_levels)
color_0_236 = input(#f44336, "", inline = "Level0" , group = group_fib_levels)
f_processLevelX(show_0_236, value_0_236, color_0_236)
show_0_382 = input(true , "", inline = "Level1" , group = group_fib_levels)
value_0_382 = input(0.382 , "", inline = "Level1" , group = group_fib_levels)
color_0_382 = input(#81c784, "", inline = "Level1" , group = group_fib_levels)
f_processLevelX(show_0_382, value_0_382, color_0_382)
show_0_5 = input(true , "", inline = "Level1" , group = group_fib_levels)
value_0_5 = input(0.5 , "", inline = "Level1" , group = group_fib_levels)
color_0_5 = input(#4caf50, "", inline = "Level1" , group = group_fib_levels)
f_processLevelX(show_0_5, value_0_5, color_0_5)
show_0_618 = input(true , "", inline = "Level2" , group = group_fib_levels)
value_0_618 = input(0.618 , "", inline = "Level2" , group = group_fib_levels)
color_0_618 = input(#009688, "", inline = "Level2" , group = group_fib_levels)
f_processLevelX(show_0_618, value_0_618, color_0_618)
show_0_65 = input(false , "", inline = "Level2" , group = group_fib_levels)
value_0_65 = input(0.65 , "", inline = "Level2" , group = group_fib_levels)
color_0_65 = input(#009688, "", inline = "Level2" , group = group_fib_levels)
f_processLevelX(show_0_65, value_0_65, color_0_65)
show_0_786 = input(true , "", inline = "Level3" , group = group_fib_levels)
value_0_786 = input(0.786 , "", inline = "Level3" , group = group_fib_levels)
color_0_786 = input(#64b5f6, "", inline = "Level3" , group = group_fib_levels)
f_processLevelX(show_0_786, value_0_786, color_0_786)
show_1 = input(true , "", inline = "Level3" , group = group_fib_levels)
value_1 = input(1. , "", inline = "Level3" , group = group_fib_levels)
color_1 = input(#787b86, "", inline = "Level3" , group = group_fib_levels)
f_processLevelX(show_1, value_1, color_1)
show_1_272 = input(false , "", inline = "Level4" , group = group_fib_levels)
value_1_272 = input(1.272 , "", inline = "Level4" , group = group_fib_levels)
color_1_272 = input(#81c784, "", inline = "Level4" , group = group_fib_levels)
f_processLevelX(show_1_272, value_1_272, color_1_272)
show_1_414 = input(false , "", inline = "Level4" , group = group_fib_levels)
value_1_414 = input(1.414 , "", inline = "Level4" , group = group_fib_levels)
color_1_414 = input(#f44336, "", inline = "Level4" , group = group_fib_levels)
f_processLevelX(show_1_414, value_1_414, color_1_414)
show_1_618 = input(true , "", inline = "Level5" , group = group_fib_levels)
value_1_618 = input(1.618 , "", inline = "Level5" , group = group_fib_levels)
color_1_618 = input(#2196f3, "", inline = "Level5" , group = group_fib_levels)
f_processLevelX(show_1_618, value_1_618, color_1_618)
show_1_65 = input(false , "", inline = "Level5" , group = group_fib_levels)
value_1_65 = input(1.65 , "", inline = "Level5" , group = group_fib_levels)
color_1_65 = input(#2196f3, "", inline = "Level5" , group = group_fib_levels)
f_processLevelX(show_1_65, value_1_65, color_1_65)
show_2_618 = input(false , "", inline = "Level6" , group = group_fib_levels)
value_2_618 = input(2.618 , "", inline = "Level6" , group = group_fib_levels)
color_2_618 = input(#f44336, "", inline = "Level6" , group = group_fib_levels)
f_processLevelX(show_2_618, value_2_618, color_2_618)
show_2_65 = input(false , "", inline = "Level6" , group = group_fib_levels)
value_2_65 = input(2.65 , "", inline = "Level6" , group = group_fib_levels)
color_2_65 = input(#f44336, "", inline = "Level6" , group = group_fib_levels)
f_processLevelX(show_2_65, value_2_65, color_2_65)
show_3_618 = input(false , "", inline = "Level7" , group = group_fib_levels)
value_3_618 = input(3.618 , "", inline = "Level7" , group = group_fib_levels)
color_3_618 = input(#9c27b0, "", inline = "Level7" , group = group_fib_levels)
f_processLevelX(show_3_618, value_3_618, color_3_618)
show_3_65 = input(false , "", inline = "Level7" , group = group_fib_levels)
value_3_65 = input(3.65 , "", inline = "Level7" , group = group_fib_levels)
color_3_65 = input(#9c27b0, "", inline = "Level7" , group = group_fib_levels)
f_processLevelX(show_3_65, value_3_65, color_3_65)
show_4_236 = input(false , "", inline = "Level8" , group = group_fib_levels)
value_4_236 = input(4.236 , "", inline = "Level8" , group = group_fib_levels)
color_4_236 = input(#e91e63, "", inline = "Level8" , group = group_fib_levels)
f_processLevelX(show_4_236, value_4_236, color_4_236)
show_4_618 = input(false , "", inline = "Level8" , group = group_fib_levels)
value_4_618 = input(4.618 , "", inline = "Level8" , group = group_fib_levels)
color_4_618 = input(#81c784, "", inline = "Level8" , group = group_fib_levels)
f_processLevelX(show_4_618, value_4_618, color_4_618)
show_neg_0_236 = input(false , "", inline = "Level9" , group = group_fib_levels)
value_neg_0_236 = input(-0.236 , "", inline = "Level9" , group = group_fib_levels)
color_neg_0_236 = input(#f44336, "", inline = "Level9" , group = group_fib_levels)
f_processLevelX(show_neg_0_236, value_neg_0_236, color_neg_0_236)
show_neg_0_382 = input(false , "", inline = "Level9" , group = group_fib_levels)
value_neg_0_382 = input(-0.382 , "", inline = "Level9" , group = group_fib_levels)
color_neg_0_382 = input(#81c784, "", inline = "Level9" , group = group_fib_levels)
f_processLevelX(show_neg_0_382, value_neg_0_382, color_neg_0_382)
show_neg_0_618 = input(true , "", inline = "Level10", group = group_fib_levels)
value_neg_0_618 = input(-0.618 , "", inline = "Level10", group = group_fib_levels)
color_neg_0_618 = input(#009688, "", inline = "Level10", group = group_fib_levels)
f_processLevelX(show_neg_0_618, value_neg_0_618, color_neg_0_618)
show_neg_0_65 = input(false , "", inline = "Level10", group = group_fib_levels)
value_neg_0_65 = input(-0.65 , "", inline = "Level10", group = group_fib_levels)
color_neg_0_65 = input(#009688, "", inline = "Level10", group = group_fib_levels)
f_processLevelX(show_neg_0_65, value_neg_0_65, color_neg_0_65)
// Fibonacci Retracement / Extention / Pivot Points and Zig Zag
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //
//
// Volume / Volatility AddOns
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //
// ---------------------------------------------------------------------------------------------- //
// -Inputs -------------------------------------------------------------------------------------- //
group_vol_vol = "Volume / Volatility AddOns"
tooltip_volume_spike_sign_of_exhaustion = "Moments where\n" +
"huge volume detected : current volume is grater than the product of the theshold value and volume moving average"
tooltip_high_volatility = "Moments where\n" +
"price range of the current bar is grater than the product of the theshold value and average true range value of defined period"
tooltip_volume_weighted_colored_bars = "Volume Weighted Colored Bars\nColors bars based on the bar's volume relative to volume moving average"
// ---------------------------------------------------------------------------------------------- //
// High Volatility ------------------------------------------------------------------------------ //
i_hATRLb = input(true , "⚡" , inline = "ATR" , group = group_vol_vol, tooltip = tooltip_high_volatility)
i_weightedATR = atr(input(13 , "ATR : Length" , inline = "ATR" , group = group_vol_vol)) *
input(2.718 , "Mult", minval = .1, step = .1 , inline = "ATR" , group = group_vol_vol)
// ---------------------------------------------------------------------------------------------- //
// Volume Moving Average : Base ----------------------------------------------------------------- //
i_vSMA = sma(nz(volume), input(89, "Volume Moving Average Length", group = group_vol_vol))
// ---------------------------------------------------------------------------------------------- //
// Volume Spike - Sign of Exhaustion ------------------------------------------------------------ //
i_vSpikeLb = input(true , "🚦" , inline = "SRS1", group = group_vol_vol, tooltip = tooltip_volume_spike_sign_of_exhaustion)
i_vSpikeThresh = input(4.669 , "Volume Spike Theshold ", minval = .1, step = .1 , inline = "SRS1", group = group_vol_vol)
// ---------------------------------------------------------------------------------------------- //
// Volume Weighted Colored Bars ----------------------------------------------------------------- //
i_vwcb = input(true , "" , inline = "VWC", group = group_vol_vol, tooltip = tooltip_volume_weighted_colored_bars)
i_vwcbHighThresh = input(1.618 , "VWCB : High ", minval = 1., step = .1 , inline = "VWC", group = group_vol_vol)
i_vwcbLowThresh = input(0.618 , " Low" , minval = .1, step = .1 , inline = "VWC", group = group_vol_vol)
// ---------------------------------------------------------------------------------------------- //
// -Calculations and Plotting ------------------------------------------------------------------- //
nzVolume = nz(volume)
bullCandle = close > open
bearCandle = close < open
range = abs(high - low)
// ---------------------------------------------------------------------------------------------- //
// Volume Spike - Sign of Exhaustion ------------------------------------------------------------ //
exhaustVol = nzVolume > i_vSpikeThresh * i_vSMA
plotchar(i_vSpikeLb and nzVolume ? exhaustVol : na, "Exhaustion Bar", "🚦", location.abovebar, size=size.tiny)
alertcondition(crossover(nzVolume, i_vSMA * i_vSpikeThresh), "Volume Spikes", "sign of exhaustion, huge volume increase detected\n{{exchange}}:{{ticker}}->\nOpen = {{open}}, Current = {{close}},\nTime = {{time}}")
// ---------------------------------------------------------------------------------------------- //
// High Volatility ------------------------------------------------------------------------------ //
highVolatility = range > i_weightedATR
plotchar(i_hATRLb ? highVolatility : na, "High Volatile Bar", "⚡", location.belowbar, size=size.tiny)
alertcondition(crossover(range, i_weightedATR), "High Volatility", "high volatility detected\n{{exchange}}:{{ticker}}->\nOpen = {{open}}, Current = {{close}},\nTime = {{time}}")
// ---------------------------------------------------------------------------------------------- //
// Volume Weighted Colored Bars by Kıvanç Özbilgiç ---------------------------------------------- //
vwcbCol = nzVolume > i_vSMA * i_vwcbHighThresh ?
bullCandle ? #006400 : #910000 :
nzVolume < i_vSMA * i_vwcbLowThresh ?
bearCandle ? #FF9800 : #7FFFD4 :
na
barcolor(i_vwcb and nzVolume ? vwcbCol : na, title = "Volume Weighted Colored Bars")
// Voloume / Volatility AddOns
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //