Pivot Boss Tools v3 (With Future Pivots)
Pivot Boss Tools v3 (With Future Pivots)
AUTO = "Auto"
DAILY = "Daily"
WEEKLY = "Weekly"
MONTHLY = "Monthly"
QUARTERLY = "Quarterly"
YEARLY = "Yearly"
BIYEARLY = "Biyearly"
TRIYEARLY = "Triyearly"
QUINQUENNIALLY = "Quinquennially"
DECENNIALLY = "Decennially"
TRADITIONAL = "Traditional"
FIBONACCI = "Fibonacci"
WOODIE = "Woodie"
CLASSIC = "Classic"
DEMARK = "DM"
CAMARILLA = "Camarilla"
if future
show_labels := false
show_prices := false
get_pivot_resolution() =>
resolution = "M"
if pivot_time_frame == AUTO
if timeframe.isintraday
resolution := "12M"
resolution := "D"
resolution := "W"
resolution := "M"
resolution := "3M"
resolution := "12M"
resolution
resolution = get_pivot_resolution()
var p = array.new_float()
var bc = array.new_float()
var tc = array.new_float()
var r1 = array.new_float()
var s1 = array.new_float()
var r2 = array.new_float()
var s2 = array.new_float()
//r1_color = input.color(DEF_COLOR, "†††††††â€R2",
inline="R", group="SUPPORT AND RESISTANCE")
var r3 = array.new_float()
var s3 = array.new_float()
//r1_color = input.color(DEF_COLOR, "†††††††â€R3",
inline="R", group="SUPPORT AND RESISTANCE")
var r4 = array.new_float()
var s4 = array.new_float()
//r1_color = input.color(DEF_COLOR, "†††††††â€R4",
inline="S4/R4", group="SUPPORT AND RESISTANCE")
var h1 = array.new_float()
var l1 = array.new_float()
var h2 = array.new_float()
var l2 = array.new_float()
var h3 = array.new_float()
var l3 = array.new_float()
var h4 = array.new_float()
var l4 = array.new_float()
var h5 = array.new_float()
var l5 = array.new_float()
var ph = array.new_float()
var pl = array.new_float()
// ||-- Inputs:
session_timeframe = resolution
percent_of_tpo = 0.70
tf_high = high
tf_low = low
tf_close = close
session_high = tf_high
session_low = tf_low
if session_bar_counter == 0
session_high := tf_high
session_low := tf_low
session_range
session_high := tf_high
session_range
session_low := tf_low
session_range
tpo_section_range = session_range / 21
_frequency = 0
for _i = 0 to _adjusted_length - 1 by 1
_frequency += 1
_frequency
_return
f_get_tpo_count_1(_value) =>
_return = 0.0
if _value == 0
_return := tpo_00
_return
if _value == 1
_return := tpo_01
_return
if _value == 2
_return := tpo_02
_return
if _value == 3
_return := tpo_03
_return
if _value == 4
_return := tpo_04
_return
if _value == 5
_return := tpo_05
_return
if _value == 6
_return := tpo_06
_return
if _value == 7
_return := tpo_07
_return
if _value == 8
_return := tpo_08
_return
if _value == 9
_return := tpo_09
_return
if _value == 10
_return := tpo_10
_return
if _value == 11
_return := tpo_11
_return
if _value == 12
_return := tpo_12
_return
if _value == 13
_return := tpo_13
_return
if _value == 14
_return := tpo_14
_return
if _value == 15
_return := tpo_15
_return
if _value == 16
_return := tpo_16
_return
if _value == 17
_return := tpo_17
_return
if _value == 18
_return := tpo_18
_return
if _value == 19
_return := tpo_19
_return
if _value == 20
_return := tpo_20
_return
_return
f_get_tpo_count_2(_value) =>
_return = 0.0
if _value == 0
_return := tpo_00
_return
if _value == 1
_return := tpo_01
_return
if _value == 2
_return := tpo_02
_return
if _value == 3
_return := tpo_03
_return
if _value == 4
_return := tpo_04
_return
if _value == 5
_return := tpo_05
_return
if _value == 6
_return := tpo_06
_return
if _value == 7
_return := tpo_07
_return
if _value == 8
_return := tpo_08
_return
if _value == 9
_return := tpo_09
_return
if _value == 10
_return := tpo_10
_return
if _value == 11
_return := tpo_11
_return
if _value == 12
_return := tpo_12
_return
if _value == 13
_return := tpo_13
_return
if _value == 14
_return := tpo_14
_return
if _value == 15
_return := tpo_15
_return
if _value == 16
_return := tpo_16
_return
if _value == 17
_return := tpo_17
_return
if _value == 18
_return := tpo_18
_return
if _value == 19
_return := tpo_19
_return
if _value == 20
_return := tpo_20
_return
_return
tpo_sum = 0.0
current_poc_position = 0.0
current_poc_value = 0.0
for _i = 0 to 20 by 1
_get_tpo_value = f_get_tpo_count_1(_i)
tpo_sum += _get_tpo_value
current_poc_position := _i
current_poc_value := _get_tpo_value
current_poc_value
vah_position = current_poc_position
val_position = current_poc_position
current_sum = current_poc_value
for _i = 0 to 20 by 1
current_sum += f_get_tpo_count_2(math.round(vah_position))
current_sum
current_sum += f_get_tpo_count_2(math.round(val_position))
current_sum
pivotX_open = float(na)
pivotX_high = float(na)
pivotX_low = float(na)
pivotX_prev_open = float(na)
pivotX_prev_open := nz(pivotX_prev_open[1])
pivotX_prev_high = float(na)
pivotX_prev_high := nz(pivotX_prev_high[1])
pivotX_prev_low = float(na)
pivotX_prev_low := nz(pivotX_prev_low[1])
pivotX_prev_close = float(na)
pivotX_prev_close := nz(pivotX_prev_close[1])
if array.size(arr_time) > 1
traditional() =>
dayrange = pivotX_prev_high-pivotX_prev_low
R2 = math.round_to_mintick(pivotX_Median + dayrange)
R1 = math.round_to_mintick((pivotX_Median * 2) - pivotX_prev_low)
R4 = math.round_to_mintick(R3 + (R2-R1))
S1 = math.round_to_mintick((pivotX_Median * 2) - pivotX_prev_high)
S2 = math.round_to_mintick(pivotX_Median - dayrange)
S4 = math.round_to_mintick(S3 - (S1-S2))
array.push(p, pivotX_Median)
array.push(bc, cpr_bc)
array.push(tc, cpr_tc)
array.push(r1, R1)
array.push(s1, S1)
array.push(r2, R2)
array.push(s2, S2)
array.push(r3, R3)
array.push(s3, S3)
array.push(r4, R4)
array.push(s4, S4)
H5 = math.round_to_mintick(((pivotX_prev_high/pivotX_prev_low) * pivotX_prev_close))
L5 = math.round_to_mintick((pivotX_prev_close - (H5-pivotX_prev_close)))
array.push(h1, H1)
array.push(h2, H2)
array.push(h3, H3)
array.push(h4, H4)
array.push(h5, H5)
array.push(l1, L1)
array.push(l2, L2)
array.push(l3, L3)
array.push(l4, L4)
array.push(l5, L5)
PH = math.round_to_mintick(pivotX_prev_high)
PL = math.round_to_mintick(pivotX_prev_low)
array.push(pl, PL)
array.push(ph, PH)
array.push(mzh, vah)
array.push(mzl, val)
array.push(poch, poc_u)
array.push(pocl, poc_l)
calc_pivot() =>
if kind == TRADITIONAL
traditional()
SIMPLE_DIVISOR = -1
BIYEARLY => 2
TRIYEARLY => 3
QUINQUENNIALLY => 5
DECENNIALLY => 10
=> SIMPLE_DIVISOR
if na(prev) or na(curr)
else
math.max(prev, curr)
math.min(prev, curr)
else
calc_OHLC_for_pivot(custom_years_divisor) =>
if custom_years_divisor == SIMPLE_DIVISOR
[open, high, low, close, open[1], high[1], low[1], close[1], time[1], time_close]
else
if year(time_close) % custom_years_divisor == 0
curr_sec_open := open
curr_sec_high := high
curr_sec_low := low
curr_sec_close := close
prev_sec_high := high[1]
prev_sec_low := low[1]
prev_sec_close := close[1]
prev_sec_time := time[1]
for i = 2 to custom_years_divisor
if is_time_change
change_time := time
if is_last_premarket
was_last_premarket := true
start_calculate_in_premarket := true
if session.ismarket
was_last_premarket := false
pivotX_prev_open := prev_sec_open[1]
pivotX_prev_high := prev_sec_high[1]
pivotX_prev_low := prev_sec_low[1]
pivotX_prev_close := prev_sec_close[1]
pivotX_open := sec_open[1]
pivotX_high := sec_high[1]
pivotX_low := sec_low[1]
array.push(arr_time, start_time)
calc_pivot()
if is_daily_based
if is_last_premarket
pivotX_prev_open := sec_open
pivotX_prev_high := sec_high
pivotX_prev_low := sec_low
pivotX_prev_close := sec_close
pivotX_open := open
pivotX_high := high
pivotX_low := low
else
pivotX_prev_open := prev_sec_open
pivotX_prev_high := prev_sec_high
pivotX_prev_low := prev_sec_low
pivotX_prev_close := prev_sec_close
pivotX_open := sec_open
pivotX_high := sec_high
pivotX_low := sec_low
else
pivotX_prev_high := pivotX_high
pivotX_prev_low := pivotX_low
pivotX_prev_open := pivotX_open
pivotX_prev_close := close[1]
pivotX_open := open
pivotX_high := high
pivotX_low := low
else if without_time_change
array.push(arr_time, start_time)
else
calc_pivot()
if array.size(arr_time) > 0
array.shift(arr_time)
array.shift(p)
array.shift(tc)
array.shift(bc)
array.shift(r1)
array.shift(s1)
array.shift(r2)
array.shift(s2)
array.shift(r3)
array.shift(s3)
array.shift(r4)
array.shift(s4)
array.shift(h1)
array.shift(l1)
array.shift(h2)
array.shift(l2)
array.shift(h3)
array.shift(l3)
array.shift(h4)
array.shift(l4)
array.shift(h5)
array.shift(l5)
array.shift(ph)
array.shift(pl)
array.shift(poch)
array.shift(pocl)
array.shift(mzh)
array.shift(mzl)
is_change := true
runtime.error("Not enough intraday data to calculate Pivot Points. Lower the Pivots
Timeframe or turn on the 'Use Daily-based Values' option in the indicator settings.")
is_change := false
if custom_years_divisor > 0
array.push(arr_time, estimate_pivot_time)
else
array.push(arr_time, time_close(resolution))
for i = 0 to array.size(lines) - 1
if array.size(lines) > 0
line.delete(array.shift(lines))
if array.size(labels) > 0
label.delete(array.shift(labels))
for i = 0 to array.size(arr_time) - 2
draw_line(i, p, p_color)
na
xATR = ta.atr(nATRPeriod)
xATRTrailingStop = 0.0
O = open
C = close
H = high
L = low
Wlongsignal = bodylow - low >= (bodyhigh - bodylow) * wick_multiplier and (high - close)
<= (high - low) * body_percentage and (high - low) > ta.sma(high - low, Barsback)
mybodysize = math.abs(C - O)
mycandlesize = H - L
Elongsignal = O[1] - C[1] >= bodysize * (H[1] - L[1]) and H[1] - L[1] > AverageCandle *
bodymultiplier and O[1] - C[1] > AverageBody and C > O
Eshortsignal = C[1] - O[1] >= bodysize * (H[1] - L[1]) and H[1] - L[1] > AverageCandle *
bodymultiplier and C[1] - O[1] > AverageBody and O > C
Olongsignal = L < L[1] and C > H[1] and H - L >= AverageCandle1 * BarMultiplier
Oshortsignal = H > H[1] and C < L[1] and H - L >= AverageCandle1 * BarMultiplier
Dshortsignal = frangeco <= frangehl * percentage and C < L[1] and L[1] > sma10 and C < O
or C < L[2] and C[1] >= L[2] and frangeco <= frangeco * percentage and C < O and L[2] >
sma10
Dlongsignal = frangeco <= frangehl * percentage and C > H[1] and H[1] < sma10 and C > O or
C > H[2] and C[1] <= H[2] and frangeco <= frangeco * percentage and C > O and H[2] < sma10
longsignal = l01 and Wlongsignal or l02 and Elongsignal or l03 and Olongsignal or l04 and
Dlongsignal
shortsignal = l01 and Wshortsignal or l02 and Eshortsignal or l03 and Oshortsignal or l04
and Dshortsignal
plot(his and mz_show ? vah: na, title='VAH', color=val == val[1] ? mz_color : na,
linewidth=line_width, style=plot.style_linebr, transp=0, editable = false, linewidth =
line_width)
plot(his and mz_show ? val : na, title='VAL', color = val == val[1] ? mz_color : na,
linewidth=line_width, style=plot.style_linebr, transp=0, editable = false, linewidth =
line_width)
plot(his and poc_show ? poc_u : na, title='POC Upper', color=poc_u == poc_u[1] ? poc_color
: na, linewidth=line_width, style=plot.style_linebr, transp=0, editable = false, linewidth
= line_width)
plot(his and poc_show ? poc_l : na, title='POC Lower', color=poc_l == poc_l[1] ? poc_color
: na, linewidth=line_width, style=plot.style_linebr, transp=0, editable = false, linewidth
= line_width)
plot(his and p_show ? his_tc : na, title="TC", color=his_tc == his_tc[1] ? p_color : na,
transp=0, style = plot.style_linebr, editable = false, linewidth = line_width)
plot(his and p_show ? his_bc : na, title="BC", color=his_bc == his_bc[1] ? p_color : na,
transp=0, style = plot.style_linebr, editable = false, linewidth = line_width)
plot(his and h5_show and showcam ? his_h5 : na, title="H5", color=his_h5 == his_h5[1] ?
h5_color : na, transp=0, style = plot.style_linebr, editable = false, linewidth =
line_width)
plot(his and h4_show and showcam ? his_h4 : na, title="H4", color=his_h4 == his_h4[1] ?
h1_color : na, transp=0, style = plot.style_linebr, editable = false, linewidth =
line_width)
plot(his and h3_show and showcam ? his_h3 : na, title="H3", color=his_h3 == his_h3[1] ?
h1_color : na, transp=0, style = plot.style_linebr, editable = false, linewidth =
line_width)
plot(his and l3_show and showcam ? his_l3 : na, title="L3", color=his_l3 == his_l3[1] ?
l1_color : na, transp=0, style = plot.style_linebr, editable = false, linewidth =
line_width)
plot(his and l4_show and showcam ? his_l4 : na, title="L4", color=his_l4 == his_l4[1] ?
l1_color : na, transp=0, style = plot.style_linebr, editable = false, linewidth =
line_width)
plot(his and l5_show and showcam ? his_l5 : na, title="L5", color=his_l5 == his_l5[1] ?
h5_color : na, transp=0, style = plot.style_linebr, editable = false, linewidth =
line_width)
plot(his and h2_show and showcam ? his_h2 : na, title="H2", color=his_h2 == his_h2[1] ?
h1_color : na, transp=0, style = plot.style_linebr, editable = false, linewidth =
line_width)
plot(his and h1_show and showcam ? his_h1 : na, title="H1", color=his_h1 == his_h1[1] ?
h1_color : na, transp=0, style = plot.style_linebr, editable = false, linewidth =
line_width)
plot(his and l1_show and showcam ? his_l1 : na, title="L1", color=his_l1 == his_l1[1] ?
l1_color : na, transp=0, style = plot.style_linebr, editable = false, linewidth =
line_width)
plot(his and l2_show and showcam ? his_l2 : na, title="L2", color=his_l3 == his_l3[1] ?
l1_color : na, transp=0, style = plot.style_linebr, editable = false, linewidth =
line_width)
plot(his and showfp and s1_show ? his_s1 : na, title="S1", color=his_s1 == his_s1[1] ?
s1_color : na, transp=0, style = plot.style_linebr, editable = false, linewidth =
line_width)
plot(his and showfp and r1_show ? his_r1 : na, title="R1", color=his_r1 == his_r1[1] ?
r1_color : na, transp=0, style = plot.style_linebr, editable = false, linewidth =
line_width)
plot(his and showfp and s2_show ? his_s2 : na, title="S2", color=his_s2 == his_s2[1] ?
s1_color : na, transp=0, style = plot.style_linebr, editable = false, linewidth =
line_width)
plot(his and showfp and r2_show ? his_r2 : na, title="R2", color=his_r2 == his_r2[1] ?
r1_color : na, transp=0, style = plot.style_linebr, editable = false, linewidth =
line_width)
plot(his and showfp and s3_show ? his_s3 : na, title="S3", color = his_s3 == his_s3[1] ?
s1_color : na, transp=0, style = plot.style_linebr, editable = false, linewidth =
line_width)
plot(his and showfp and r3_show ? his_r3 : na, title="R3", color = his_r3 == his_r3[1] ?
r1_color : na, transp=0, style = plot.style_linebr, editable = false, linewidth =
line_width)
plot(his and showfp and s4_show ? his_s4 : na, title="S4", color = his_s4 == his_s4[1] ?
s1_color : na, transp=0, style = plot.style_linebr, editable = false, linewidth =
line_width)
plot(his and showfp and s4_show ? his_r4 : na, title="R4", color = his_r4 == his_r4[1] ?
r1_color : na, transp=0, style = plot.style_linebr, editable = false, linewidth =
line_width)
////////////////////////////////////////////
////////////////////////////////////////////
time_y = year(time)
time_m = month(time)
time_d = dayofmonth(time)
time_3m = month(time)
time_3m2 = year(time)
if time_m == 12
time_y += 1
time_m := 1
time_m
else
time_m += 1
time_m
time_3m := 4
time_3m := 7
time_3m := 10
time_3m := 1
time_3m2 := time_y + 1
var tom_start = 0
var tom_end = 0
if resolution == 'M'
tom_start := next_month
tom_end
if resolution == '3M'
tom_start := next_quarter
tom_end := next_quarter2
tom_end
if resolution == 'W'
tom_end
if resolution == 'D'
tom_end
//Label func()
if str.length(str.tostring(math.round(y_))) >= 2
factor = math.pow(10, 2)
else
/////////////////////////////////////////
/////////////////////////////////////////
// Pivot Range
tP = (tH + tL + tC) / 3
tTC = tP - tBC + tP
// Resistance Levels
tR2 = tP + tH - tL
tR1 = tP * 2 - tL
// Support Levels
tS1 = tP * 2 - tH
tH5 = tH / tL * tC
line.delete(_t_r4[1])
line.delete(_t_r3[1])
line.delete(_t_r2[1])
line.delete(_t_r1[1])
line.delete(_t_tc[1])
line.delete(_t_p[1])
line.delete(_t_bc[1])
line.delete(_t_s1[1])
line.delete(_t_s2[1])
line.delete(_t_s3[1])
line.delete(_t_s4[1])
line.delete(_t_h4[1])
line.delete(_t_h5[1])
line.delete(_t_h3[1])
line.delete(_t_h2[1])
line.delete(_t_h1[1])
line.delete(_t_l1[1])
line.delete(_t_l2[1])
line.delete(_t_l3[1])
line.delete(_t_l4[1])
line.delete(_t_l5[1])
line.delete(_pdh[1])
line.delete(_pdl[1])
//Labelsif sLabels
label.delete(l_t_r4[1])
label.delete(l_t_r3[1])
label.delete(l_t_r2[1])
label.delete(l_t_r1[1])
label.delete(l_t_tc[1])
label.delete(l_t_p[1])
label.delete(l_t_bc[1])
label.delete(l_t_s1[1])
label.delete(l_t_s2[1])
label.delete(l_t_s3[1])
label.delete(l_t_s4[1])
label.delete(l_pdh[1])
label.delete(l_pdl[1])
label.delete(l_t_h4[1])
label.delete(l_t_h3[1])
label.delete(l_t_h2[1])
label.delete(l_t_h1[1])
label.delete(l_t_h5[1])
label.delete(l_t_l4[1])
label.delete(l_t_l3[1])
label.delete(l_t_l2[1])
label.delete(l_t_l1[1])
label.delete(l_t_l5[1])
label.delete(l_mzh[1])
label.delete(l_mzl[1])
label.delete(l_poch[1])
label.delete(l_pocl[1])
line.delete(_mzh[1])
line.delete(_mzl[1])
line.delete(_poch[1])
line.delete(_pocl[1])