Indicator · Pine Script v4 · On the chart

[CP]Pivot Boss Floor Pivots

by pranjalchaubey

This indicator draws floor pivots and the central pivot range on the price chart.

View on GitHub

GitHub stars5on the repository
Pine versionv4older, still runs
Lines of code233
Settings40inputs
LicenceNone statedfile: MPL-2.0
Last update3 years ago8 Dec 2022

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

233 lines of Pine Script v4 from Pine Script/Pivot Boss Pivots.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

Pivot Boss Pivots.pine
//@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=["1H", "2H", "4H", "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 == "1H" ? '60' : floor_pivot_timeframe == "2H" ? '120' : floor_pivot_timeframe == "4H" ? '240' : 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))

Overview

A timeframe input sets the pivot period from one hour through twelve months, and toggles control labels and next-period levels. When dynamic levels are on, an ATR threshold decides which floor pivots appear. An optional ATR factor dilates intraday pivot levels. Three moving averages and a Bollinger Band can be shown as extra overlays. The script does not define entries, exits, or a stop loss.

Details

Published by

pranjalchaubey on GitHub

Type

Indicator, Pine Script v4

Draws

On the price chart

Category

Support & resistance, Moving averages, Volatility & bands

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Floor Pivot TimeframestringDfloor_pivot_timeframe
Show Floor Pivotsbooltrueshow_floor_pivots
Show CPRbooltrueshow_cpr
Show Pivot Lablesbooltrueshow_labels
Show Next Time Period Pivotsboolfalseshow_next_day_pivot
Show Floor Pivot Levels Dynamicallybooltruedynamic_pivot_levels
Dynamic Pivot ATR Periodint14dynamic_pivot_atr_period
ATR Threshold for Dynamic Floor Pivotsfloat2.0dynamic_pivot_atr_threshold
Use ATR to Dilate Intraday Pivot Levelsbooltrueatr_dilation
ATR Dilation Factorfloat0.05atr_multiplier
ATR Periodint14atr_period
Enable 1st Moving Averagebooltruevis1
Show all 40 settings
SettingTypeDefaultVariable
Moving Average TypestringSMAma1
Moving Average 1 Lengthint13len1
Moving Average 1 Sourcesourceclosesrc1
Moving Average 1 Offsetint0off1
Enable 2nd Moving Averagebooltruevis2
Moving Average TypestringSMAma2
Moving Average 2 Lengthint21len2
Moving Average 2 Sourcesourceclosesrc2
Moving Average 2 Offsetint0off2
Enable 3rd Moving Averagebooltruevis3
Moving Average TypestringSMAma3
Moving Average 3 Lengthint55len3
Moving Average 3 Sourcesourceclosesrc3
Moving Average 3 Offsetint0off3
Enable Bollinger Bandbooltruevisbb
Show Bollinger Basisboolfalsevisbb_basis
BB Lengthint20lenbb
BB Sourcesourceclosesrcbb
BB StdDevfloat2.0mult
BB Offsetint0offbb
Central Floor Pivotcolorcolor.new(color.yellow, 0)floor_pivots_p_color
CPR Bandcolorcolor.new(color.blue, 50)floor_pivots_cpr_color
Floor Pivots Resistance Levelscolorcolor.new(color.red, 0)floor_pivots_r_color
Floor Pivots Support Levelscolorcolor.new(color.lime, 0)floor_pivots_s_color
Moving Average 1colorcolor.new(color.red, 0)ma_1_color
Moving Average 2colorcolor.new(color.yellow, 0)ma_2_color
Moving Average 3colorcolor.new(color.aqua, 0)ma_3_color
Bollinger Band Basiscolorcolor.new(color.rgb(255,109,0), 0)bb_basis_color
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

Snag - VWAP

by dearvn
257 stars

This indicator plots a custom Anchored Volume-Weighted Average Price (VWAP) directly on the price chart along with optional standard deviation bands. Users can anchor the VWAP to standard time periods like sessions, weeks, or months, or to corporate events suc

Indicator v5 Moving averagesVolatility & bands Repaints
Updated 6 weeks ago · None stated GitHub repository of Snag - VWAP

MA Envelope (MAE)

by mihakralj
99 stars

The MA Envelope indicator calculates upper and lower channel bands shifted by a user-defined percentage around a baseline moving average. It supports Simple Moving Average, Exponential Moving Average, and Weighted Moving Average calculation types. The script p

Indicator v6 Moving averagesSupport & resistance
Updated 4 weeks ago · Apache-2.0 GitHub repository of MA Envelope (MAE)

Moon Dev GEX Walls & Trap

by moondevonyt
92 stars

This indicator estimates gamma exposure levels and intraday context for index instruments like SPY and ES. It calculates VWAP with standard deviation bands as a gamma flip proxy, highlighting market regimes through background colors. It plots prior day high, l

Indicator v5 Support & resistanceSessions & time
Updated 8 weeks ago · Custom licence GitHub repository of Moon Dev GEX Walls & Trap

Median

by TWODS-CAPITAL
37 stars

The Median indicator calculates the median of a selected source series such as the high-low average over a user-defined length and plots it as a red line on the price chart. It draws an EMA of the median as a blue line and fills the space between them, changin

Indicator v5 Moving averagesVolatility & bands
Updated 3 years ago · MIT GitHub repository of Median
20 stars

This indicator calculates a base moving average (EMA, SMA, WMA, or HMA) and projects multiple symmetrical envelope bands around it directly on the price chart. Users can adjust the length, source, moving average type, and initial envelope multiplier. Additiona

Indicator v5 Moving averagesVolatility & bands
Updated 1 year ago · None stated GitHub repository of Multiple Moving Average Envelope

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers