//@version=4
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © pranjalchaubey
//Structural Pivots
study(title="[CP]Pivot Boss Floor Pivots with ATR Dilation and Dynamic Levels", shorttitle="[CP]Pivot Boss Floor Pivots", overlay=true, max_labels_count=500)
// User Inputs
//==============================================================================
floor_pivot_timeframe = input("D", options=["D", "W", "M", "12M"], title="Floor Pivot Timeframe", group="Floor Pivots")
show_floor_pivots = input(true, type=input.bool, title="Show Floor Pivots", group="Floor Pivots")
show_cpr = input(true, type=input.bool, title="Show CPR", group="Floor Pivots")
show_labels = input(true, type=input.bool, title="Show Pivot Lables", group="Floor Pivots")
show_next_day_pivot = input(false, type=input.bool, title="Show Next Time Period Pivots", group="Floor Pivots")
dynamic_pivot_levels = input(true, type=input.bool, title="Show Floor Pivot Levels Dynamically", group="Dynamic Pivot Levels")
dynamic_pivot_atr_period = input(14, type=input.integer, minval=1, maxval=356, title="Dynamic Pivot ATR Period", group="Dynamic Pivot Levels")
dynamic_pivot_atr_threshold = input(2.0, type=input.float, minval=0.001, maxval=10,title="ATR Threshold for Dynamic Floor Pivots", group="Dynamic Pivot Levels")
atr_dilation = input(true, type=input.bool, title="Use ATR to Dilate Intraday Pivot Levels", group="ATR Pivot Dilation")
atr_multiplier = input(0.05, type=input.float, minval=0.001, maxval=10,title="ATR Dilation Factor", group="ATR Pivot Dilation")
atr_period = input(14, type=input.integer, minval=1, maxval=356, title="ATR Period", group="ATR Pivot Dilation")
vis1 = input(true, title="Enable 1st Moving Average", group="Bonus Indicators")
ma1 = input("SMA", options=["SMA", "EMA", "WMA", "VWMA"], title="Moving Average Type", group="Bonus Indicators")
len1 = input(13, type=input.integer, minval=1, title="Moving Average 1 Length", group="Bonus Indicators")
src1 = input(close, type=input.source, title="Moving Average 1 Source", group="Bonus Indicators")
off1 = input(0, type=input.integer, minval=-500, maxval=500,title="Moving Average 1 Offset", group="Bonus Indicators")
vis2 = input(true, title="Enable 2nd Moving Average", group="Bonus Indicators")
ma2 = input("SMA", options=["SMA", "EMA", "WMA", "VWMA"], title="Moving Average Type", group="Bonus Indicators")
len2 = input(21, type=input.integer, minval=1, title="Moving Average 2 Length", group="Bonus Indicators")
src2 = input(close, type=input.source, title="Moving Average 2 Source", group="Bonus Indicators")
off2 = input(0, type=input.integer, minval=-500, maxval=500,title="Moving Average 2 Offset", group="Bonus Indicators")
vis3 = input(true, title="Enable 3rd Moving Average", group="Bonus Indicators")
ma3 = input("SMA", options=["SMA", "EMA", "WMA", "VWMA"], title="Moving Average Type", group="Bonus Indicators")
len3 = input(55, type=input.integer, minval=1, title="Moving Average 3 Length", group="Bonus Indicators")
src3 = input(close, type=input.source, title="Moving Average 3 Source", group="Bonus Indicators")
off3 = input(0, type=input.integer, minval=-500, maxval=500,title="Moving Average 3 Offset", group="Bonus Indicators")
visbb = input(true, title="Enable Bollinger Band", group="Bonus Indicators")
visbb_basis = input(false, title="Show Bollinger Basis", group="Bonus Indicators")
lenbb = input(20, type=input.integer, minval=1, title="BB Length", group="Bonus Indicators")
srcbb = input(close, type=input.source, title="BB Source", group="Bonus Indicators")
mult = input(2.0, type=input.float, minval=0.001, maxval=50, title="BB StdDev", group="Bonus Indicators")
offbb = input(0, type=input.integer, minval=-500, maxval=500,title="BB Offset", group="Bonus Indicators")
floor_pivots_p_color = input(color.new(color.yellow, 0), type = input.color, title="Central Floor Pivot", group="Color Scheme")
floor_pivots_cpr_color = input(color.new(color.blue, 50), type = input.color, title="CPR Band", group="Color Scheme")
floor_pivots_r_color = input(color.new(color.red, 0), type = input.color, title="Floor Pivots Resistance Levels", group="Color Scheme")
floor_pivots_s_color = input(color.new(color.lime, 0), type = input.color, title="Floor Pivots Support Levels", group="Color Scheme")
ma_1_color = input(color.new(color.red, 0), type = input.color, title="Moving Average 1", group="Color Scheme")
ma_2_color = input(color.new(color.yellow, 0), type = input.color, title="Moving Average 2", group="Color Scheme")
ma_3_color = input(color.new(color.aqua, 0), type = input.color, title="Moving Average 3", group="Color Scheme")
bb_basis_color = input(color.new(color.rgb(255,109,0), 0), type = input.color, title="Bollinger Band Basis", group="Color Scheme")
bb_band_color = input(color.new(color.rgb(41,98,255), 0), type = input.color, title="Bollinger Upper/Lower Band", group="Color Scheme")
bb_bg_color = input(color.new(color.rgb(33, 150, 243), 95), type = input.color, title="Bollinger Background", group="Color Scheme")
// Calculations
//==============================================================================
// Floor Pivots
// Central Pivot
pivot = (high + low + close) / 3.0
// Resistance Levels
r1 = (2 * pivot) - low
r2 = pivot + (high - low)
r3 = r1 + (high - low)
r4 = r3 + (r2 - r1)
// Support Levels
s1 = (2 * pivot) - high
s2 = pivot - (high - low)
s3 = s1 - (high - low)
s4 = s3 - (s1 - s2)
// Central Pivot Range
temp_bc = (high + low) / 2
temp_tc = (pivot - temp_bc) + pivot
tc = temp_tc > temp_bc ? temp_tc : temp_bc
bc = temp_bc < temp_tc ? temp_bc : temp_tc
// Dynamic Floor Pivots
dynamic_pivot_atr = atr(dynamic_pivot_atr_period) * dynamic_pivot_atr_threshold
dynamic_high = high + dynamic_pivot_atr
dynamic_low = low - dynamic_pivot_atr
// Average True Range for Pivot Level Dilation
atr_norm = atr(atr_period) * atr_multiplier
// Timeframe
floor_pivot_resolution = floor_pivot_timeframe
// Bonus Indicators
val_ma1 = if ma1 == "SMA" // Moving Average 1
sma(src1, len1)
else if ma1 == "EMA"
ema(src1, len1)
else if ma1 == "WMA"
wma(src1, len1)
else if ma1 == "VWMA"
vwma(src1, len1)
val_ma2 = if ma2 == "SMA" // Moving Average 2
sma(src2, len2)
else if ma2 == "EMA"
ema(src2, len2)
else if ma2 == "WMA"
wma(src2, len2)
else if ma2 == "VWMA"
vwma(src2, len2)
val_ma3 = if ma3 == "SMA" // Moving Average 3
sma(src3, len3)
else if ma3 == "EMA"
ema(src3, len3)
else if ma3 == "WMA"
wma(src3, len3)
else if ma3 == "VWMA"
vwma(src3, len3)
basis = sma(srcbb, lenbb) // Bollinger Band
dev = mult * stdev(srcbb, lenbb)
upper = basis + dev
lower = basis - dev
// Floor Pivots
//==============================================================================
// Dynamic Floor Pivot Variables
var bool show_daily_pivot = na
var bool show_daily_r1 = na
var bool show_daily_r2 = na
var bool show_daily_r3 = na
var bool show_daily_r4 = na
var bool show_daily_s1 = na
var bool show_daily_s2 = na
var bool show_daily_s3 = na
var bool show_daily_s4 = na
// Daily Average True Range for ATR Dilation
daily_atr_dilation = security(syminfo.tickerid, 'D', atr_norm[1], barmerge.gaps_off, barmerge.lookahead_on)
// Daily Floor Pivots
daily_pivot = security(syminfo.tickerid, floor_pivot_resolution, show_next_day_pivot ? pivot : pivot[1], barmerge.gaps_off, barmerge.lookahead_on)
daily_r1 = security(syminfo.tickerid, floor_pivot_resolution, show_next_day_pivot ? r1 : r1[1], barmerge.gaps_off, barmerge.lookahead_on)
daily_r2 = security(syminfo.tickerid, floor_pivot_resolution, show_next_day_pivot ? r2 : r2[1], barmerge.gaps_off, barmerge.lookahead_on)
daily_r3 = security(syminfo.tickerid, floor_pivot_resolution, show_next_day_pivot ? r3 : r3[1], barmerge.gaps_off, barmerge.lookahead_on)
daily_r4 = security(syminfo.tickerid, floor_pivot_resolution, show_next_day_pivot ? r4 : r4[1], barmerge.gaps_off, barmerge.lookahead_on)
daily_s1 = security(syminfo.tickerid, floor_pivot_resolution, show_next_day_pivot ? s1 : s1[1], barmerge.gaps_off, barmerge.lookahead_on)
daily_s2 = security(syminfo.tickerid, floor_pivot_resolution, show_next_day_pivot ? s2 : s2[1], barmerge.gaps_off, barmerge.lookahead_on)
daily_s3 = security(syminfo.tickerid, floor_pivot_resolution, show_next_day_pivot ? s3 : s3[1], barmerge.gaps_off, barmerge.lookahead_on)
daily_s4 = security(syminfo.tickerid, floor_pivot_resolution, show_next_day_pivot ? s4 : s4[1], barmerge.gaps_off, barmerge.lookahead_on)
daily_tbc = security(syminfo.tickerid, floor_pivot_resolution, show_next_day_pivot ? temp_bc : temp_bc[1], barmerge.gaps_off, barmerge.lookahead_on)
daily_ttc = security(syminfo.tickerid, floor_pivot_resolution, show_next_day_pivot ? temp_tc : temp_tc[1], barmerge.gaps_off, barmerge.lookahead_on)
daily_tc = daily_ttc > daily_tbc ? daily_ttc : daily_tbc
daily_bc = daily_tbc < daily_ttc ? daily_tbc : daily_ttc
// Dynamic Daily Floor Pivot Logic (only for Intraday)
show_daily_pivot := show_daily_pivot[1] == false and dynamic_pivot_levels and timeframe.isintraday and ((daily_pivot >= dynamic_low and daily_pivot <= dynamic_high) or (daily_tc >= dynamic_low and daily_tc <= dynamic_high) or (daily_bc >= dynamic_low and daily_bc <= dynamic_high)) ? 1 : dynamic_pivot_levels == false ? 1 : show_daily_pivot[1] == true and dayofmonth == dayofmonth[1] ? 1 : 0
show_daily_r1 := show_daily_r1[1] == false and dynamic_pivot_levels and timeframe.isintraday and daily_r1 >= dynamic_low and daily_r1 <= dynamic_high ? 1 : dynamic_pivot_levels == false ? 1 : show_daily_r1[1] == true and dayofmonth == dayofmonth[1] ? 1 : 0
show_daily_r2 := show_daily_r2[1] == false and dynamic_pivot_levels and timeframe.isintraday and daily_r2 >= dynamic_low and daily_r2 <= dynamic_high ? 1 : dynamic_pivot_levels == false ? 1 : show_daily_r2[1] == true and dayofmonth == dayofmonth[1] ? 1 : 0
show_daily_r3 := show_daily_r3[1] == false and dynamic_pivot_levels and timeframe.isintraday and daily_r3 >= dynamic_low and daily_r3 <= dynamic_high ? 1 : dynamic_pivot_levels == false ? 1 : show_daily_r3[1] == true and dayofmonth == dayofmonth[1] ? 1 : 0
show_daily_r4 := show_daily_r4[1] == false and dynamic_pivot_levels and timeframe.isintraday and daily_r4 >= dynamic_low and daily_r4 <= dynamic_high ? 1 : dynamic_pivot_levels == false ? 1 : show_daily_r4[1] == true and dayofmonth == dayofmonth[1] ? 1 : 0
show_daily_s1 := show_daily_s1[1] == false and dynamic_pivot_levels and timeframe.isintraday and daily_s1 >= dynamic_low and daily_s1 <= dynamic_high ? 1 : dynamic_pivot_levels == false ? 1 : show_daily_s1[1] == true and dayofmonth == dayofmonth[1] ? 1 : 0
show_daily_s2 := show_daily_s2[1] == false and dynamic_pivot_levels and timeframe.isintraday and daily_s2 >= dynamic_low and daily_s2 <= dynamic_high ? 1 : dynamic_pivot_levels == false ? 1 : show_daily_s2[1] == true and dayofmonth == dayofmonth[1] ? 1 : 0
show_daily_s3 := show_daily_s3[1] == false and dynamic_pivot_levels and timeframe.isintraday and daily_s3 >= dynamic_low and daily_s3 <= dynamic_high ? 1 : dynamic_pivot_levels == false ? 1 : show_daily_s3[1] == true and dayofmonth == dayofmonth[1] ? 1 : 0
show_daily_s4 := show_daily_s4[1] == false and dynamic_pivot_levels and timeframe.isintraday and daily_s4 >= dynamic_low and daily_s4 <= dynamic_high ? 1 : dynamic_pivot_levels == false ? 1 : show_daily_s4[1] == true and dayofmonth == dayofmonth[1] ? 1 : 0
// Plots
//==============================================================================
// Neutral and ATR Dilated Positive plots
p1a = plot(show_floor_pivots and show_daily_pivot and not atr_dilation ? daily_pivot : show_floor_pivots and show_daily_pivot and atr_dilation and timeframe.isintraday ? daily_pivot+daily_atr_dilation : show_floor_pivots and show_daily_pivot and atr_dilation and not timeframe.isintraday ? daily_pivot : na, title = "Pivot", color = color.new(floor_pivots_p_color, atr_dilation and timeframe.isintraday ? 100 : 0), linewidth = 1, style = plot.style_circles)
r1a = plot(show_floor_pivots and show_daily_r1 and not atr_dilation ? daily_r1 : show_floor_pivots and show_daily_r1 and atr_dilation and timeframe.isintraday ? daily_r1+daily_atr_dilation : show_floor_pivots and show_daily_r1 and atr_dilation and not timeframe.isintraday ? daily_r1 : na, title = "R1", color = color.new(floor_pivots_r_color, atr_dilation and timeframe.isintraday ? 100 : 0), linewidth = 1, style = plot.style_circles)
r2a = plot(show_floor_pivots and show_daily_r2 and not atr_dilation ? daily_r2 : show_floor_pivots and show_daily_r2 and atr_dilation and timeframe.isintraday ? daily_r2+daily_atr_dilation : show_floor_pivots and show_daily_r2 and atr_dilation and not timeframe.isintraday ? daily_r2 : na, title = "R2", color = color.new(floor_pivots_r_color, atr_dilation and timeframe.isintraday ? 100 : 0), linewidth = 1, style = plot.style_circles)
r3a = plot(show_floor_pivots and show_daily_r3 and not atr_dilation ? daily_r3 : show_floor_pivots and show_daily_r3 and atr_dilation and timeframe.isintraday ? daily_r3+daily_atr_dilation : show_floor_pivots and show_daily_r3 and atr_dilation and not timeframe.isintraday ? daily_r3 : na, title = "R3", color = color.new(floor_pivots_r_color, atr_dilation and timeframe.isintraday ? 100 : 0), linewidth = 1, style = plot.style_circles)
r4a = plot(show_floor_pivots and show_daily_r4 and not atr_dilation ? daily_r4 : show_floor_pivots and show_daily_r4 and atr_dilation and timeframe.isintraday ? daily_r4+daily_atr_dilation : show_floor_pivots and show_daily_r4 and atr_dilation and not timeframe.isintraday ? daily_r4 : na, title = "R4", color = color.new(floor_pivots_r_color, atr_dilation and timeframe.isintraday ? 100 : 0), linewidth = 1, style = plot.style_circles)
s1a = plot(show_floor_pivots and show_daily_s1 and not atr_dilation ? daily_s1 : show_floor_pivots and show_daily_s1 and atr_dilation and timeframe.isintraday ? daily_s1+daily_atr_dilation : show_floor_pivots and show_daily_s1 and atr_dilation and not timeframe.isintraday ? daily_s1 : na, title = "S1", color = color.new(floor_pivots_s_color, atr_dilation and timeframe.isintraday ? 100 : 0), linewidth = 1, style = plot.style_circles)
s2a = plot(show_floor_pivots and show_daily_s2 and not atr_dilation ? daily_s2 : show_floor_pivots and show_daily_s2 and atr_dilation and timeframe.isintraday ? daily_s2+daily_atr_dilation : show_floor_pivots and show_daily_s2 and atr_dilation and not timeframe.isintraday ? daily_s2 : na, title = "S2", color = color.new(floor_pivots_s_color, atr_dilation and timeframe.isintraday ? 100 : 0), linewidth = 1, style = plot.style_circles)
s3a = plot(show_floor_pivots and show_daily_s3 and not atr_dilation ? daily_s3 : show_floor_pivots and show_daily_s3 and atr_dilation and timeframe.isintraday ? daily_s3+daily_atr_dilation : show_floor_pivots and show_daily_s3 and atr_dilation and not timeframe.isintraday ? daily_s3 : na, title = "S3", color = color.new(floor_pivots_s_color, atr_dilation and timeframe.isintraday ? 100 : 0), linewidth = 1, style = plot.style_circles)
s4a = plot(show_floor_pivots and show_daily_s4 and not atr_dilation ? daily_s4 : show_floor_pivots and show_daily_s4 and atr_dilation and timeframe.isintraday ? daily_s4+daily_atr_dilation : show_floor_pivots and show_daily_s4 and atr_dilation and not timeframe.isintraday ? daily_s4 : na, title = "S4", color = color.new(floor_pivots_s_color, atr_dilation and timeframe.isintraday ? 100 : 0), linewidth = 1, style = plot.style_circles)
// ATR Dilated Negative Plots
p1b = plot(show_floor_pivots and show_daily_pivot and atr_dilation and timeframe.isintraday ? daily_pivot-daily_atr_dilation : na, title = "DPivot", color = color.new(floor_pivots_p_color, atr_dilation and timeframe.isintraday ? 100 : 0), linewidth = 1, style = plot.style_circles)
r1b = plot(show_floor_pivots and show_daily_r1 and atr_dilation and timeframe.isintraday ? daily_r1-daily_atr_dilation : na, title = "DR1", color = color.new(floor_pivots_r_color, atr_dilation and timeframe.isintraday ? 100 : 0), linewidth = 1, style = plot.style_circles)
r2b = plot(show_floor_pivots and show_daily_r2 and atr_dilation and timeframe.isintraday ? daily_r2-daily_atr_dilation : na, title = "DR2", color = color.new(floor_pivots_r_color, atr_dilation and timeframe.isintraday ? 100 : 0), linewidth = 1, style = plot.style_circles)
r3b = plot(show_floor_pivots and show_daily_r3 and atr_dilation and timeframe.isintraday ? daily_r3-daily_atr_dilation : na, title = "DR3", color = color.new(floor_pivots_r_color, atr_dilation and timeframe.isintraday ? 100 : 0), linewidth = 1, style = plot.style_circles)
r4b = plot(show_floor_pivots and show_daily_r4 and atr_dilation and timeframe.isintraday ? daily_r4-daily_atr_dilation : na, title = "DR4", color = color.new(floor_pivots_r_color, atr_dilation and timeframe.isintraday ? 100 : 0), linewidth = 1, style = plot.style_circles)
s1b = plot(show_floor_pivots and show_daily_s1 and atr_dilation and timeframe.isintraday ? daily_s1-daily_atr_dilation : na, title = "DS1", color = color.new(floor_pivots_s_color, atr_dilation and timeframe.isintraday ? 100 : 0), linewidth = 1, style = plot.style_circles)
s2b = plot(show_floor_pivots and show_daily_s2 and atr_dilation and timeframe.isintraday ? daily_s2-daily_atr_dilation : na, title = "DS2", color = color.new(floor_pivots_s_color, atr_dilation and timeframe.isintraday ? 100 : 0), linewidth = 1, style = plot.style_circles)
s3b = plot(show_floor_pivots and show_daily_s3 and atr_dilation and timeframe.isintraday ? daily_s3-daily_atr_dilation : na, title = "DS3", color = color.new(floor_pivots_s_color, atr_dilation and timeframe.isintraday ? 100 : 0), linewidth = 1, style = plot.style_circles)
s4b = plot(show_floor_pivots and show_daily_s4 and atr_dilation and timeframe.isintraday ? daily_s4-daily_atr_dilation : na, title = "DS4", color = color.new(floor_pivots_s_color, atr_dilation and timeframe.isintraday ? 100 : 0), linewidth = 1, style = plot.style_circles)
// CPR Band
tcline = plot(show_cpr and show_daily_pivot and not atr_dilation ? daily_tc : show_cpr and show_daily_pivot and atr_dilation and timeframe.isintraday ? daily_tc+daily_atr_dilation : show_cpr and show_daily_pivot and atr_dilation and not timeframe.isintraday ? daily_tc : na, title = "TC", color = color.new(floor_pivots_cpr_color, atr_dilation and timeframe.isintraday ? 100 : 0), linewidth = 1, style = plot.style_circles)
bcline = plot(show_cpr and show_daily_pivot and not atr_dilation ? daily_bc : show_cpr and show_daily_pivot and atr_dilation and timeframe.isintraday ? daily_bc-daily_atr_dilation : show_cpr and show_daily_pivot and atr_dilation and not timeframe.isintraday ? daily_bc : na, title = "BC", color = color.new(floor_pivots_cpr_color, atr_dilation and timeframe.isintraday ? 100 : 0), linewidth = 1, style = plot.style_circles)
fill(tcline, bcline, color = color.new(floor_pivots_cpr_color, show_cpr and show_daily_pivot ? 75 : 100))
// Fill ATR Dilated bands
fill(p1a, p1b, color.new(floor_pivots_p_color, 75))
fill(r1a, r1b, color.new(floor_pivots_r_color, 75))
fill(r2a, r2b, color.new(floor_pivots_r_color, 75))
fill(r3a, r3b, color.new(floor_pivots_r_color, 75))
fill(r4a, r4b, color.new(floor_pivots_r_color, 75))
fill(s1a, s1b, color.new(floor_pivots_s_color, 75))
fill(s2a, s2b, color.new(floor_pivots_s_color, 75))
fill(s3a, s3b, color.new(floor_pivots_s_color, 75))
fill(s4a, s4b, color.new(floor_pivots_s_color, 75))
// Pivot Lables
if show_labels
chper = time - time[1]
chper := change(chper) > 0 ? chper[1] : chper
var label plabel = na
var label s1label = na, var label s2label = na, var label s3label = na, var label s4label = na
var label r1label = na, var label r2label = na, var label r3label = na, var label r4label = na
label.delete(plabel)
label.delete(s1label), label.delete(s2label), label.delete(s3label), label.delete(s4label)
label.delete(r1label), label.delete(r2label), label.delete(r3label), label.delete(r4label)
if show_floor_pivots and show_daily_pivot
plabel := label.new(x = timeframe.isintraday ? time + chper * 5 : time + chper, y = atr_dilation and timeframe.isintraday ? daily_pivot+daily_atr_dilation : daily_pivot, text = "Pivot", color = floor_pivots_p_color, textcolor=color.black, style=label.style_labeldown, xloc = xloc.bar_time, yloc=yloc.price)
if show_floor_pivots and show_daily_r1
r1label := label.new(x = timeframe.isintraday ? time + chper * 5 : time + chper, y = atr_dilation and timeframe.isintraday ? daily_r1+daily_atr_dilation : daily_r1, text = "R1", color = floor_pivots_r_color, textcolor=color.white, style=label.style_labeldown, xloc = xloc.bar_time, yloc=yloc.price)
if show_floor_pivots and show_daily_r2
r2label := label.new(x = timeframe.isintraday ? time + chper * 5 : time + chper, y = atr_dilation and timeframe.isintraday ? daily_r2+daily_atr_dilation : daily_r2, text = "R2", color = floor_pivots_r_color, textcolor=color.white, style=label.style_labeldown, xloc = xloc.bar_time, yloc=yloc.price)
if show_floor_pivots and show_daily_r3
r3label := label.new(x = timeframe.isintraday ? time + chper * 5 : time + chper, y = atr_dilation and timeframe.isintraday ? daily_r3+daily_atr_dilation : daily_r3, text = "R3", color = floor_pivots_r_color, textcolor=color.white, style=label.style_labeldown, xloc = xloc.bar_time, yloc=yloc.price)
if show_floor_pivots and show_daily_r4
r4label := label.new(x = timeframe.isintraday ? time + chper * 5 : time + chper, y = atr_dilation and timeframe.isintraday ? daily_r4+daily_atr_dilation : daily_r4, text = "R4", color = floor_pivots_r_color, textcolor=color.white, style=label.style_labeldown, xloc = xloc.bar_time, yloc=yloc.price)
if show_floor_pivots and show_daily_s1
s1label := label.new(x = timeframe.isintraday ? time + chper * 5 : time + chper, y = atr_dilation and timeframe.isintraday ? daily_s1+daily_atr_dilation : daily_s1, text = "S1", color = floor_pivots_s_color, textcolor=color.white, style=label.style_labeldown, xloc = xloc.bar_time, yloc=yloc.price)
if show_floor_pivots and show_daily_s2
s2label := label.new(x = timeframe.isintraday ? time + chper * 5 : time + chper, y = atr_dilation and timeframe.isintraday ? daily_s2+daily_atr_dilation : daily_s2, text = "S2", color = floor_pivots_s_color, textcolor=color.white, style=label.style_labeldown, xloc = xloc.bar_time, yloc=yloc.price)
if show_floor_pivots and show_daily_s3
s3label := label.new(x = timeframe.isintraday ? time + chper * 5 : time + chper, y = atr_dilation and timeframe.isintraday ? daily_s3+daily_atr_dilation : daily_s3, text = "S3", color = floor_pivots_s_color, textcolor=color.white, style=label.style_labeldown, xloc = xloc.bar_time, yloc=yloc.price)
if show_floor_pivots and show_daily_s4
s4label := label.new(x = timeframe.isintraday ? time + chper * 5 : time + chper, y = atr_dilation and timeframe.isintraday ? daily_s4+daily_atr_dilation : daily_s4, text = "S4", color = floor_pivots_s_color, textcolor=color.white, style=label.style_labeldown, xloc = xloc.bar_time, yloc=yloc.price)
// Bonus Indicators
// Moving Averages
plot(vis1 ? val_ma1 : na, title="Moving Average 1", color=color.new(ma_1_color, 0), linewidth=1, offset=off1)
plot(vis2 ? val_ma2 : na, title="Moving Average 2", color=color.new(ma_2_color, 0), linewidth=1, offset=off2)
plot(vis3 ? val_ma3 : na, title="Moving Average 3", color=color.new(ma_3_color, 0), linewidth=1, offset=off3)
// Bollinger Band
plot(visbb and visbb_basis? basis : na, title="Bollinger Basis", color=bb_basis_color, offset = offbb)
p1 = plot(visbb ? upper : na, title="Bollinger Upper", color=bb_band_color, offset = offbb)
p2 = plot(visbb ? lower : na, title="Bollinger Lower", color=bb_band_color, offset = offbb)
fill(p1, p2, title="Bollinger Background", color=color.new(bb_bg_color, visbb ? 95 : 100))