Price Pivots for NASDQ 100 Stocks
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Arun_K_Bhaskar

//@version=5

// Updated on 7 August 2022
// Included Equities: NASDQ 100 listed stocks as per the updated date.

// Formula Reference: Intrangle - Straddle / Strangle By Saravanan_Ragavan
// Source Link: https://in.tradingview.com/script/BWsF0S4k-Intrangle-Straddle-Strangle/

indicator(title="Price Pivots for NASDQ 100 Stocks", shorttitle="Price Pivots NASDQ 100", overlay=true)

////////////////////////////////////////////////////////// F&O Index & Equity Symbols

// Symbols of Strike Price Difference 0.25
sym_001_spd_0_25 = "GOOG"
sym_002_spd_0_25 = "GOOGL"
// Symbols of Strike Price Difference 0.5
sym_003_spd_0_5 = "CMCSA"
sym_004_spd_0_5 = "CSCO"
sym_005_spd_0_5 = "CSX"
sym_006_spd_0_5 = "INTC"
sym_007_spd_0_5 = "KHC"
sym_008_spd_0_5 = "LCID"
sym_009_spd_0_5 = "SIRI"
sym_010_spd_0_5 = "WBA"
// Symbols of Strike Price Difference 1
sym_011_spd_1 = "ABNB"
sym_012_spd_1 = "AMAT"
sym_013_spd_1 = "AMD"
sym_014_spd_1 = "AMZN"
sym_015_spd_1 = "ATVI"
sym_016_spd_1 = "AZN"
sym_017_spd_1 = "BIDU"
sym_018_spd_1 = "DDOG"
sym_019_spd_1 = "DOCU"
sym_020_spd_1 = "EA"
sym_021_spd_1 = "EBAY"
sym_022_spd_1 = "EXC"
sym_023_spd_1 = "FISV"
sym_024_spd_1 = "FTNT"
sym_025_spd_1 = "GILD"
sym_026_spd_1 = "JD"
sym_027_spd_1 = "KDP"
sym_028_spd_1 = "MCHP"
sym_029_spd_1 = "MDLZ"
sym_030_spd_1 = "MNST"
sym_031_spd_1 = "MRVL"
sym_032_spd_1 = "MTCH"
sym_033_spd_1 = "MU"
sym_034_spd_1 = "NTES"
sym_035_spd_1 = "OKTA"
sym_036_spd_1 = "PDD"
sym_037_spd_1 = "PYPL"
sym_038_spd_1 = "ROST"
sym_039_spd_1 = "SBUX"
sym_040_spd_1 = "SPLK"
sym_041_spd_1 = "SWKS"
sym_042_spd_1 = "TMUS"
sym_043_spd_1 = "ZM"
// Symbols of Strike Price Difference 2.5
sym_044_spd_2_5 = "AAPL"
sym_045_spd_2_5 = "ADBE"
sym_046_spd_2_5 = "ADI"
sym_047_spd_2_5 = "ADP"
sym_048_spd_2_5 = "ADSK"
sym_049_spd_2_5 = "AEP"
sym_050_spd_2_5 = "ALGN"
sym_051_spd_2_5 = "AMGN"
sym_052_spd_2_5 = "AVGO"
sym_053_spd_2_5 = "BIIB"
sym_054_spd_2_5 = "COST"
sym_055_spd_2_5 = "CRWD"
sym_056_spd_2_5 = "CTSH"
sym_057_spd_2_5 = "DLTR"
sym_058_spd_2_5 = "FAST"
sym_059_spd_2_5 = "HON"
sym_060_spd_2_5 = "ISRG"
sym_061_spd_2_5 = "MAR"
sym_062_spd_2_5 = "META"
sym_063_spd_2_5 = "MRNA"
sym_064_spd_2_5 = "MSFT"
sym_065_spd_2_5 = "NFLX"
sym_066_spd_2_5 = "NVDA"
sym_067_spd_2_5 = "NXPI"
sym_068_spd_2_5 = "PCAR"
sym_069_spd_2_5 = "PEP"
sym_070_spd_2_5 = "QCOM"
sym_071_spd_2_5 = "TEAM"
sym_072_spd_2_5 = "TXN"
sym_073_spd_2_5 = "VRTX"
sym_074_spd_2_5 = "WDAY"
sym_075_spd_2_5 = "ZS"
// Symbols of Strike Price Difference 5
sym_076_spd_5 = "ASML"
sym_077_spd_5 = "BKNG"
sym_078_spd_5 = "CDNS"
sym_079_spd_5 = "CEG"
sym_080_spd_5 = "CHTR"
sym_081_spd_5 = "CPRT"
sym_082_spd_5 = "DXCM"
sym_083_spd_5 = "ILMN"
sym_084_spd_5 = "INTU"
sym_085_spd_5 = "KLAC"
sym_086_spd_5 = "LRCX"
sym_087_spd_5 = "LULU"
sym_088_spd_5 = "MELI"
sym_089_spd_5 = "PANW"
sym_090_spd_5 = "PAYX"
sym_091_spd_5 = "REGN"
sym_092_spd_5 = "SGEN"
sym_093_spd_5 = "TSLA"
sym_094_spd_5 = "VRSK"
sym_095_spd_5 = "VRSN"
sym_096_spd_5 = "XEL"
// Symbols of Strike Price Difference 10
sym_097_spd_10 = "ANSS"
sym_098_spd_10 = "CTAS"
sym_099_spd_10 = "IDXX"
sym_100_spd_10 = "ODFL"
sym_101_spd_10 = "ORLY"
sym_102_spd_10 = "SNPS"

////////////////////////////////////////////////////////// Common Strike Price Difference in NSE F&O

spd_0_25 = 0.25
spd_0_5 = 0.5
spd_1 = 1
spd_2_5 = 2.5
spd_5 = 5
spd_10 = 10



////////////////////////////////////////////////////////// Price Pivots 

ttSrc = "• Custom: Enter the price manually after choosing the Source as Custom to show the Pivots at that price.\n• LTP: Pivot is calculated based on Last Traded Price.\n• Day Open: Pivot is calculated based on current day opening price.\n• PD Close: Pivot is calculated based on previous day closing price.\n• PD HL2: Pivot is calculated based on previous day average of High and Low.\n• PD HLC3: Pivot is calculated based on previous day average of High, Low and Close."
ttHis = "Increase numbers for prevoius pivots"
ttCus = "Enter price manually to calculate pivots of that price level"

gpPP = "Price Pivots"

show_pp = input.bool(true, title="Show Price Pivots", group=gpPP, inline="01")
show_pp_label = input.bool(true, title="Price Labels", group=gpPP, inline="01")
i_timeframe = input.string("D", title="Timeframe", options=["1", "3", "5", "15", "30", "45", "60", "120", "180", "240", "D", "5D", "W", "2W", "3W", "M", "3M", "6M", "12M"], group=gpPP)
i_source = input.string("PD Close", title="Source", options=["Custom", "LTP","Day Open", "PD Close", "PD HL2", "PD HLC3"], group=gpPP, tooltip=ttSrc)
i_pd_ltp_o = input.int(0, title="Historical (If Source is Day Open)", minval=0, group=gpPP, tooltip=ttHis)
i_pd_c_hl2_hlc3 = input.int(1, title="Historical (If Source is PD Close, HL2, HLC3)", minval=1, group=gpPP, tooltip=ttHis)
i_custom = input.float(0, title="Enter Price (If Source is Custom)", minval=0, group=gpPP, tooltip=ttCus)

////////////////////////////////////////////////////// OHLC

day_open = request.security(syminfo.tickerid, i_timeframe, open[i_pd_ltp_o], lookahead=barmerge.lookahead_on)
pd_high = request.security(syminfo.tickerid, i_timeframe, high[i_pd_c_hl2_hlc3], lookahead=barmerge.lookahead_on)
pd_low = request.security(syminfo.tickerid, i_timeframe, low[i_pd_c_hl2_hlc3], lookahead=barmerge.lookahead_on)
pd_close = request.security(syminfo.tickerid, i_timeframe, close[i_pd_c_hl2_hlc3], lookahead=barmerge.lookahead_on)

get_high = request.security(syminfo.tickerid, "60", high)
get_low = request.security(syminfo.tickerid, "60", low)

////////////////////////////////////////////////////// Source

price_input = i_source == "LTP" ? close[i_pd_ltp_o] :
     i_source == "Day Open" ? day_open :
     i_source == "PD Close" ? pd_close :
     i_source == "PD HL2" ? math.avg(pd_high, pd_low) :
     i_source == "PD HLC3" ? math.avg(pd_high, pd_low, pd_close) : i_custom

price_option = i_source == "Custom" ? i_custom : price_input

////////////////////////////////////////////////////// Price Levels Settings

ttR5 = "This number is for R5 which can be adjusted for extended price pivots"
ttS5 = "This number is for S5 which can be adjusted for extended price pivots"

i_r_col = input.color(color.silver, title="", group=gpPP, inline="05")
show_r_1 = input.bool(true, title="R1", group=gpPP, inline="05")
show_r_2 = input.bool(true, title="R2", group=gpPP, inline="05")
show_r_3 = input.bool(false, title="R3", group=gpPP, inline="05")
show_r_4 = input.bool(false, title="R4", group=gpPP, inline="05")
show_r_5 = input.bool(false, title="R5", group=gpPP, inline="05")
i_r_5x_level = input.int(4, minval=4, title="", group=gpPP, inline="05", tooltip=ttR5)

i_s_col = input.color(color.silver, title="", group=gpPP, inline="06")
show_s_1 = input.bool(true, title="S1", group=gpPP, inline="06")
show_s_2 = input.bool(true, title="S2", group=gpPP, inline="06")
show_s_3 = input.bool(false, title="S3", group=gpPP, inline="06")
show_s_4 = input.bool(false, title="S4", group=gpPP, inline="06")
show_s_5 = input.bool(false, title="S5", group=gpPP, inline="06")
i_s_5x_level = input.int(4, minval=4, title="", group=gpPP, inline="06", tooltip=ttS5)

i_pp_style = input.string(line.style_solid, title = "", options = [line.style_solid, line.style_dashed, line.style_dotted], group=gpPP, inline="07")
i_pp_width = input.int(1, title = "", minval=1, group=gpPP, inline="07")

show_avg = input.bool(false, title="Average Levels", group=gpPP, inline="08")
i_pp_avg_style = input.string(line.style_dashed, title = "", options = [line.style_solid, line.style_dashed, line.style_dotted], group=gpPP, inline="08")
i_pp_avg_width = input.int(1, title = "", minval=1, group=gpPP, inline="08")

i_extend = input.string("None", title="Extend Lines", options=["None", "Left", "Right", "Both"], group=gpPP, inline="09")
ext_option = i_extend == "None" ? extend.none : i_extend == "Left" ? extend.left : i_extend == "Right" ? extend.right : i_extend == "Both" ? extend.both : na

////////////////////////////////////////////////////////// Strike Price Difference Formula

// Strike Price Difference 0.25
upper_val_spd_0_25 = math.round(price_input[i_pd_ltp_o] / spd_0_25, 0) * spd_0_25
lower_val_spd_0_25 = math.round(price_input[i_pd_ltp_o] / spd_0_25, 0) * spd_0_25
upper_spd_0_25 = upper_val_spd_0_25 < price_input[i_pd_ltp_o] ? upper_val_spd_0_25 + spd_0_25 : upper_val_spd_0_25
lower_spd_0_25 = lower_val_spd_0_25 > price_input[i_pd_ltp_o] ? lower_val_spd_0_25 - spd_0_25 : lower_val_spd_0_25

// Strike Price Difference 0.5
upper_val_spd_0_5 = math.round(price_input[i_pd_ltp_o] / spd_0_5, 0) * spd_0_5
lower_val_spd_0_5 = math.round(price_input[i_pd_ltp_o] / spd_0_5, 0) * spd_0_5
upper_spd_0_5 = upper_val_spd_0_5 < price_input[i_pd_ltp_o] ? upper_val_spd_0_5 + spd_0_5 : upper_val_spd_0_5
lower_spd_0_5 = lower_val_spd_0_5 > price_input[i_pd_ltp_o] ? lower_val_spd_0_5 - spd_0_5 : lower_val_spd_0_5

// Strike Price Difference 1
upper_val_spd_1 = math.round(price_input[i_pd_ltp_o] / spd_1, 0) * spd_1
lower_val_spd_1 = math.round(price_input[i_pd_ltp_o] / spd_1, 0) * spd_1
upper_spd_1 = upper_val_spd_1 < price_input[i_pd_ltp_o] ? upper_val_spd_1 + spd_1 : upper_val_spd_1
lower_spd_1 = lower_val_spd_1 > price_input[i_pd_ltp_o] ? lower_val_spd_1 - spd_1 : lower_val_spd_1

// Strike Price Difference 2.5
upper_val_spd_2_5 = math.round(price_input[i_pd_ltp_o] / spd_2_5, 0) * spd_2_5
lower_val_spd_2_5 = math.round(price_input[i_pd_ltp_o] / spd_2_5, 0) * spd_2_5
upper_spd_2_5 = upper_val_spd_2_5 < price_input[i_pd_ltp_o] ? upper_val_spd_2_5 + spd_2_5 : upper_val_spd_2_5
lower_spd_2_5 = lower_val_spd_2_5 > price_input[i_pd_ltp_o] ? lower_val_spd_2_5 - spd_2_5 : lower_val_spd_2_5

// Strike Price Difference 5
upper_val_spd_5 = math.round(price_input[i_pd_ltp_o] / spd_5, 0) * spd_5
lower_val_spd_5 = math.round(price_input[i_pd_ltp_o] / spd_5, 0) * spd_5
upper_spd_5 = upper_val_spd_5 < price_input[i_pd_ltp_o] ? upper_val_spd_5 + spd_5 : upper_val_spd_5
lower_spd_5 = lower_val_spd_5 > price_input[i_pd_ltp_o] ? lower_val_spd_5 - spd_5 : lower_val_spd_5

// Strike Price Difference 10
upper_val_spd_10 = math.round(price_input[i_pd_ltp_o] / spd_10, 0) * spd_10
lower_val_spd_10 = math.round(price_input[i_pd_ltp_o] / spd_10, 0) * spd_10
upper_spd_10 = upper_val_spd_10 < price_input[i_pd_ltp_o] ? upper_val_spd_10 + spd_10 : upper_val_spd_10
lower_spd_10 = lower_val_spd_10 > price_input[i_pd_ltp_o] ? lower_val_spd_10 - spd_10 : lower_val_spd_10


////////////////////////////////////////////////////////// Upper & Lower Strikes

upper_strike = syminfo.root == sym_001_spd_0_25 ? upper_spd_0_25 : syminfo.root == sym_002_spd_0_25 ? upper_spd_0_25 : 
     syminfo.root == sym_003_spd_0_5 ? upper_spd_0_5 : syminfo.root == sym_004_spd_0_5 ? upper_spd_0_5 : syminfo.root == sym_005_spd_0_5 ? upper_spd_0_5 : 
     syminfo.root == sym_006_spd_0_5 ? upper_spd_0_5 : syminfo.root == sym_007_spd_0_5 ? upper_spd_0_5 : syminfo.root == sym_008_spd_0_5 ? upper_spd_0_5 : 
     syminfo.root == sym_009_spd_0_5 ? upper_spd_0_5 : syminfo.root == sym_010_spd_0_5 ? upper_spd_0_5 : 
     syminfo.root == sym_011_spd_1 ? upper_spd_1 : syminfo.root == sym_012_spd_1 ? upper_spd_1 : syminfo.root == sym_013_spd_1 ? upper_spd_1 : 
     syminfo.root == sym_014_spd_1 ? upper_spd_1 : syminfo.root == sym_015_spd_1 ? upper_spd_1 : syminfo.root == sym_016_spd_1 ? upper_spd_1 : 
     syminfo.root == sym_017_spd_1 ? upper_spd_1 : syminfo.root == sym_018_spd_1 ? upper_spd_1 : syminfo.root == sym_019_spd_1 ? upper_spd_1 : 
     syminfo.root == sym_020_spd_1 ? upper_spd_1 : syminfo.root == sym_021_spd_1 ? upper_spd_1 : syminfo.root == sym_022_spd_1 ? upper_spd_1 : 
     syminfo.root == sym_023_spd_1 ? upper_spd_1 : syminfo.root == sym_024_spd_1 ? upper_spd_1 : syminfo.root == sym_025_spd_1 ? upper_spd_1 : 
     syminfo.root == sym_026_spd_1 ? upper_spd_1 : syminfo.root == sym_027_spd_1 ? upper_spd_1 : syminfo.root == sym_028_spd_1 ? upper_spd_1 : 
     syminfo.root == sym_029_spd_1 ? upper_spd_1 : syminfo.root == sym_030_spd_1 ? upper_spd_1 : syminfo.root == sym_031_spd_1 ? upper_spd_1 : 
     syminfo.root == sym_032_spd_1 ? upper_spd_1 : syminfo.root == sym_033_spd_1 ? upper_spd_1 : syminfo.root == sym_034_spd_1 ? upper_spd_1 : 
     syminfo.root == sym_035_spd_1 ? upper_spd_1 : syminfo.root == sym_036_spd_1 ? upper_spd_1 : syminfo.root == sym_037_spd_1 ? upper_spd_1 : 
     syminfo.root == sym_038_spd_1 ? upper_spd_1 : syminfo.root == sym_039_spd_1 ? upper_spd_1 : syminfo.root == sym_040_spd_1 ? upper_spd_1 : 
     syminfo.root == sym_041_spd_1 ? upper_spd_1 : syminfo.root == sym_042_spd_1 ? upper_spd_1 : syminfo.root == sym_043_spd_1 ? upper_spd_1 : 
     syminfo.root == sym_044_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_045_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_046_spd_2_5 ? upper_spd_2_5 : 
     syminfo.root == sym_047_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_048_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_049_spd_2_5 ? upper_spd_2_5 : 
     syminfo.root == sym_050_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_051_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_052_spd_2_5 ? upper_spd_2_5 : 
     syminfo.root == sym_053_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_054_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_055_spd_2_5 ? upper_spd_2_5 : 
     syminfo.root == sym_056_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_057_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_058_spd_2_5 ? upper_spd_2_5 : 
     syminfo.root == sym_059_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_060_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_061_spd_2_5 ? upper_spd_2_5 : 
     syminfo.root == sym_062_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_063_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_064_spd_2_5 ? upper_spd_2_5 : 
     syminfo.root == sym_065_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_066_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_067_spd_2_5 ? upper_spd_2_5 : 
     syminfo.root == sym_068_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_069_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_070_spd_2_5 ? upper_spd_2_5 : 
     syminfo.root == sym_071_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_072_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_073_spd_2_5 ? upper_spd_2_5 : 
     syminfo.root == sym_074_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_075_spd_2_5 ? upper_spd_2_5 : 
     syminfo.root == sym_076_spd_5 ? upper_spd_5 : syminfo.root == sym_077_spd_5 ? upper_spd_5 : syminfo.root == sym_078_spd_5 ? upper_spd_5 : 
     syminfo.root == sym_079_spd_5 ? upper_spd_5 : syminfo.root == sym_080_spd_5 ? upper_spd_5 : syminfo.root == sym_081_spd_5 ? upper_spd_5 : 
     syminfo.root == sym_082_spd_5 ? upper_spd_5 : syminfo.root == sym_083_spd_5 ? upper_spd_5 : syminfo.root == sym_084_spd_5 ? upper_spd_5 : 
     syminfo.root == sym_085_spd_5 ? upper_spd_5 : syminfo.root == sym_086_spd_5 ? upper_spd_5 : syminfo.root == sym_087_spd_5 ? upper_spd_5 : 
     syminfo.root == sym_088_spd_5 ? upper_spd_5 : syminfo.root == sym_089_spd_5 ? upper_spd_5 : syminfo.root == sym_090_spd_5 ? upper_spd_5 : 
     syminfo.root == sym_091_spd_5 ? upper_spd_5 : syminfo.root == sym_092_spd_5 ? upper_spd_5 : syminfo.root == sym_093_spd_5 ? upper_spd_5 : 
     syminfo.root == sym_094_spd_5 ? upper_spd_5 : syminfo.root == sym_095_spd_5 ? upper_spd_5 : syminfo.root == sym_096_spd_5 ? upper_spd_5 : 
     syminfo.root == sym_097_spd_10 ? upper_spd_10 : syminfo.root == sym_098_spd_10 ? upper_spd_10 : syminfo.root == sym_099_spd_10 ? upper_spd_10 : 
     syminfo.root == sym_100_spd_10 ? upper_spd_10 : syminfo.root == sym_101_spd_10 ? upper_spd_10 : syminfo.root == sym_102_spd_10 ? upper_spd_10 : na

lower_strike = syminfo.root == sym_001_spd_0_25 ? lower_spd_0_25 : syminfo.root == sym_002_spd_0_25 ? lower_spd_0_25 : 
     syminfo.root == sym_003_spd_0_5 ? lower_spd_0_5 : syminfo.root == sym_004_spd_0_5 ? lower_spd_0_5 : syminfo.root == sym_005_spd_0_5 ? lower_spd_0_5 : 
     syminfo.root == sym_006_spd_0_5 ? lower_spd_0_5 : syminfo.root == sym_007_spd_0_5 ? lower_spd_0_5 : syminfo.root == sym_008_spd_0_5 ? lower_spd_0_5 : 
     syminfo.root == sym_009_spd_0_5 ? lower_spd_0_5 : syminfo.root == sym_010_spd_0_5 ? lower_spd_0_5 : 
     syminfo.root == sym_011_spd_1 ? lower_spd_1 : syminfo.root == sym_012_spd_1 ? lower_spd_1 : syminfo.root == sym_013_spd_1 ? lower_spd_1 : 
     syminfo.root == sym_014_spd_1 ? lower_spd_1 : syminfo.root == sym_015_spd_1 ? lower_spd_1 : syminfo.root == sym_016_spd_1 ? lower_spd_1 : 
     syminfo.root == sym_017_spd_1 ? lower_spd_1 : syminfo.root == sym_018_spd_1 ? lower_spd_1 : syminfo.root == sym_019_spd_1 ? lower_spd_1 : 
     syminfo.root == sym_020_spd_1 ? lower_spd_1 : syminfo.root == sym_021_spd_1 ? lower_spd_1 : syminfo.root == sym_022_spd_1 ? lower_spd_1 : 
     syminfo.root == sym_023_spd_1 ? lower_spd_1 : syminfo.root == sym_024_spd_1 ? lower_spd_1 : syminfo.root == sym_025_spd_1 ? lower_spd_1 : 
     syminfo.root == sym_026_spd_1 ? lower_spd_1 : syminfo.root == sym_027_spd_1 ? lower_spd_1 : syminfo.root == sym_028_spd_1 ? lower_spd_1 : 
     syminfo.root == sym_029_spd_1 ? lower_spd_1 : syminfo.root == sym_030_spd_1 ? lower_spd_1 : syminfo.root == sym_031_spd_1 ? lower_spd_1 : 
     syminfo.root == sym_032_spd_1 ? lower_spd_1 : syminfo.root == sym_033_spd_1 ? lower_spd_1 : syminfo.root == sym_034_spd_1 ? lower_spd_1 : 
     syminfo.root == sym_035_spd_1 ? lower_spd_1 : syminfo.root == sym_036_spd_1 ? lower_spd_1 : syminfo.root == sym_037_spd_1 ? lower_spd_1 : 
     syminfo.root == sym_038_spd_1 ? lower_spd_1 : syminfo.root == sym_039_spd_1 ? lower_spd_1 : syminfo.root == sym_040_spd_1 ? lower_spd_1 : 
     syminfo.root == sym_041_spd_1 ? lower_spd_1 : syminfo.root == sym_042_spd_1 ? lower_spd_1 : syminfo.root == sym_043_spd_1 ? lower_spd_1 : 
     syminfo.root == sym_044_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_045_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_046_spd_2_5 ? lower_spd_2_5 : 
     syminfo.root == sym_047_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_048_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_049_spd_2_5 ? lower_spd_2_5 : 
     syminfo.root == sym_050_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_051_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_052_spd_2_5 ? lower_spd_2_5 : 
     syminfo.root == sym_053_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_054_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_055_spd_2_5 ? lower_spd_2_5 : 
     syminfo.root == sym_056_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_057_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_058_spd_2_5 ? lower_spd_2_5 : 
     syminfo.root == sym_059_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_060_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_061_spd_2_5 ? lower_spd_2_5 : 
     syminfo.root == sym_062_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_063_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_064_spd_2_5 ? lower_spd_2_5 : 
     syminfo.root == sym_065_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_066_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_067_spd_2_5 ? lower_spd_2_5 : 
     syminfo.root == sym_068_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_069_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_070_spd_2_5 ? lower_spd_2_5 : 
     syminfo.root == sym_071_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_072_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_073_spd_2_5 ? lower_spd_2_5 : 
     syminfo.root == sym_074_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_075_spd_2_5 ? lower_spd_2_5 : 
     syminfo.root == sym_076_spd_5 ? lower_spd_5 : syminfo.root == sym_077_spd_5 ? lower_spd_5 : syminfo.root == sym_078_spd_5 ? lower_spd_5 : 
     syminfo.root == sym_079_spd_5 ? lower_spd_5 : syminfo.root == sym_080_spd_5 ? lower_spd_5 : syminfo.root == sym_081_spd_5 ? lower_spd_5 : 
     syminfo.root == sym_082_spd_5 ? lower_spd_5 : syminfo.root == sym_083_spd_5 ? lower_spd_5 : syminfo.root == sym_084_spd_5 ? lower_spd_5 : 
     syminfo.root == sym_085_spd_5 ? lower_spd_5 : syminfo.root == sym_086_spd_5 ? lower_spd_5 : syminfo.root == sym_087_spd_5 ? lower_spd_5 : 
     syminfo.root == sym_088_spd_5 ? lower_spd_5 : syminfo.root == sym_089_spd_5 ? lower_spd_5 : syminfo.root == sym_090_spd_5 ? lower_spd_5 : 
     syminfo.root == sym_091_spd_5 ? lower_spd_5 : syminfo.root == sym_092_spd_5 ? lower_spd_5 : syminfo.root == sym_093_spd_5 ? lower_spd_5 : 
     syminfo.root == sym_094_spd_5 ? lower_spd_5 : syminfo.root == sym_095_spd_5 ? lower_spd_5 : syminfo.root == sym_096_spd_5 ? lower_spd_5 : 
     syminfo.root == sym_097_spd_10 ? lower_spd_10 : syminfo.root == sym_098_spd_10 ? lower_spd_10 : syminfo.root == sym_099_spd_10 ? lower_spd_10 : 
     syminfo.root == sym_100_spd_10 ? lower_spd_10 : syminfo.root == sym_101_spd_10 ? lower_spd_10 : syminfo.root == sym_102_spd_10 ? lower_spd_10 : na

////////////////////////////////////////////////////////// Strike Price Difference

spd = upper_strike - lower_strike

////////////////////////////////////////////////////////// Higher Strikes

upper_strike_2 = upper_strike + spd
upper_strike_3 = upper_strike + (2 * spd)
upper_strike_4 = upper_strike + (3 * spd)
upper_strike_5 = upper_strike + (i_r_5x_level * spd)

lower_strike_2 = lower_strike - spd
lower_strike_3 = lower_strike - (2 * spd)
lower_strike_4 = lower_strike - (3 * spd)
lower_strike_5 = lower_strike - (i_s_5x_level * spd)

////////////////////////////////////////////////////////// Average Levels

up_lo_avg = math.avg(upper_strike, lower_strike)

up_avg_2 = math.avg(upper_strike, upper_strike_2)
up_avg_3 = math.avg(upper_strike_2, upper_strike_3)
up_avg_4 = math.avg(upper_strike_3, upper_strike_4)
up_avg_5 = math.avg(upper_strike_4, upper_strike_5)

lo_avg_2 = math.avg(lower_strike, lower_strike_2)
lo_avg_3 = math.avg(lower_strike_2, lower_strike_3)
lo_avg_4 = math.avg(lower_strike_3, lower_strike_4)
lo_avg_5 = math.avg(lower_strike_4, lower_strike_5)

////////////////////////////////////////////////////////// Percentage from Close

up_percent_1 = ((close - upper_strike)/close)*100
up_percent_2 = ((close - upper_strike_2)/close)*100
up_percent_3 = ((close - upper_strike_3)/close)*100
up_percent_4 = ((close - upper_strike_4)/close)*100
up_percent_5 = ((close - upper_strike_5)/close)*100

lo_percent_1 = ((close - lower_strike)/close)*100
lo_percent_2 = ((close - lower_strike_2)/close)*100
lo_percent_3 = ((close - lower_strike_3)/close)*100
lo_percent_4 = ((close - lower_strike_4)/close)*100
lo_percent_5 = ((close - lower_strike_5)/close)*100

//////////////////////////////////////////////////////////  Points from Close

up_points_1 = upper_strike - close
up_points_2 = upper_strike_2 - close
up_points_3 = upper_strike_3 - close
up_points_4 = upper_strike_4 - close
up_points_5 = upper_strike_5 - close

lo_points_1 = lower_strike - close
lo_points_2 = lower_strike_2 - close
lo_points_3 = lower_strike_3 - close
lo_points_4 = lower_strike_4 - close
lo_points_5 = lower_strike_5 - close

////////////////////////////////////////////////////////// Draw Lines & Labels

// Narest Strike Price

if show_pp
    var line upper_line_1 = na
    upper_line_1 := line.new(x1=bar_index - 225, y1=upper_strike, x2=bar_index + 10, y2=upper_strike, color=i_r_col, width=i_pp_width, style=i_pp_style, extend=ext_option)
    line.delete(upper_line_1[1])
    if show_pp_label
        var label upper_label_1 = na
        upper_label_1 := label.new(x=bar_index + 10, y=upper_strike, text=str.tostring(upper_strike, "#.## (") + str.tostring(up_percent_1, "#.##") + "%｜" + str.tostring(up_points_1, "#.##") + ")", style=label.style_label_left, color=color.new(color.white, 100), textcolor=i_r_col)
        label.delete(upper_label_1[1])

    var line lower_line_1 = na
    lower_line_1 := line.new(x1=bar_index - 225, y1=lower_strike, x2=bar_index + 10, y2=lower_strike, color=i_s_col, width=i_pp_width, style=i_pp_style, extend=ext_option)
    line.delete(lower_line_1[1])
    if show_pp_label
        var label lower_label_1 = na
        lower_label_1 := label.new(x=bar_index + 10, y=lower_strike, text=str.tostring(lower_strike, "#.## (") + str.tostring(lo_percent_1, "#.##") + "%｜" + str.tostring(lo_points_1, "#.##") + ")", style=label.style_label_left, color=color.new(color.white, 100), textcolor=i_s_col)
        label.delete(lower_label_1[1])

    linefill.new(upper_line_1, lower_line_1, color.new(color.silver, 95))

if show_avg and show_pp
    var line up_lo_line = na
    up_lo_line := line.new(x1=bar_index - 225, y1=up_lo_avg, x2=bar_index + 10, y2=up_lo_avg, color=color.silver, width=i_pp_avg_width, style=i_pp_avg_style, extend=ext_option)
    line.delete(up_lo_line[1])

// Upper Lines

if show_r_2 and show_pp
    var line upper_line_2 = na
    upper_line_2 := line.new(x1=bar_index - 225, y1=upper_strike_2, x2=bar_index + 10, y2=upper_strike_2, color=i_r_col, width=i_pp_width, style=i_pp_style, extend=ext_option)
    line.delete(upper_line_2[1])
    if show_pp_label
        var label upper_label_2 = na
        upper_label_2 := label.new(x=bar_index + 10, y=upper_strike_2, text=str.tostring(upper_strike_2, "#.## (") + str.tostring(up_percent_2, "#.##") + "%｜" + str.tostring(up_points_2, "#.##") + ")", style=label.style_label_left, color=color.new(color.white, 100), textcolor=i_r_col)
        label.delete(upper_label_2[1])
    if show_avg
        var line up_avg_2_line = na
        up_avg_2_line := line.new(x1=bar_index - 225, y1=up_avg_2, x2=bar_index + 10, y2=up_avg_2, color=i_r_col, width=i_pp_avg_width, style=i_pp_avg_style, extend=ext_option)
        line.delete(up_avg_2_line[1])

if show_r_3 and show_pp
    var line upper_line_3 = na
    upper_line_3 := line.new(x1=bar_index - 225, y1=upper_strike_3, x2=bar_index + 10, y2=upper_strike_3, color=i_r_col, width=i_pp_width, style=i_pp_style, extend=ext_option)
    line.delete(upper_line_3[1])
    if show_pp_label
        var label upper_label_3 = na
        upper_label_3 := label.new(x=bar_index + 10, y=upper_strike_3, text=str.tostring(upper_strike_3, "#.## (") + str.tostring(up_percent_3, "#.##") + "%｜" + str.tostring(up_points_3, "#.##") + ")", style=label.style_label_left, color=color.new(color.white, 100), textcolor=i_r_col)
        label.delete(upper_label_3[1])
    if show_avg
        var line up_avg_3_line = na
        up_avg_3_line := line.new(x1=bar_index - 225, y1=up_avg_3, x2=bar_index + 10, y2=up_avg_3, color=i_r_col, width=i_pp_avg_width, style=i_pp_avg_style, extend=ext_option)
        line.delete(up_avg_3_line[1])

if show_r_4 and show_pp
    var line upper_line_4 = na
    upper_line_4 := line.new(x1=bar_index - 225, y1=upper_strike_4, x2=bar_index + 10, y2=upper_strike_4, color=i_r_col, width=i_pp_width, style=i_pp_style, extend=ext_option)
    line.delete(upper_line_4[1])
    if show_pp_label
        var label upper_label_4 = na
        upper_label_4 := label.new(x=bar_index + 10, y=upper_strike_4, text=str.tostring(upper_strike_4, "#.## (") + str.tostring(up_percent_4, "#.##") + "%｜" + str.tostring(up_points_4, "#.##") + ")", style=label.style_label_left, color=color.new(color.white, 100), textcolor=i_r_col)
        label.delete(upper_label_4[1])
    if show_avg
        var line up_avg_4_line = na
        up_avg_4_line := line.new(x1=bar_index - 225, y1=up_avg_4, x2=bar_index + 10, y2=up_avg_4, color=i_r_col, width=i_pp_avg_width, style=i_pp_avg_style, extend=ext_option)
        line.delete(up_avg_4_line[1])

if show_r_5 and show_pp
    var line upper_line_5 = na
    upper_line_5 := line.new(x1=bar_index - 225, y1=upper_strike_5, x2=bar_index + 10, y2=upper_strike_5, color=i_r_col, width=i_pp_width, style=i_pp_style, extend=ext_option)
    line.delete(upper_line_5[1])
    if show_pp_label
        var label upper_label_5 = na
        upper_label_5 := label.new(x=bar_index + 10, y=upper_strike_5, text=str.tostring(upper_strike_5, "#.## (") + str.tostring(up_percent_5, "#.##") + "%｜" + str.tostring(up_points_5, "#.##") + ")", style=label.style_label_left, color=color.new(color.white, 100), textcolor=i_r_col)
        label.delete(upper_label_5[1])
    if show_avg
        var line up_avg_5_line = na
        up_avg_5_line := line.new(x1=bar_index - 225, y1=up_avg_5, x2=bar_index + 10, y2=up_avg_5, color=i_r_col, width=i_pp_avg_width, style=i_pp_avg_style, extend=ext_option)
        line.delete(up_avg_5_line[1])

// Lower Lines

if show_s_2 and show_pp
    var line lower_line_2 = na
    lower_line_2 := line.new(x1=bar_index - 225, y1=lower_strike_2, x2=bar_index + 10, y2=lower_strike_2, color=i_s_col, width=i_pp_width, style=i_pp_style, extend=ext_option)
    line.delete(lower_line_2[1])
    if show_pp_label
        var label lower_label_2 = na
        lower_label_2 := label.new(x=bar_index + 10, y=lower_strike_2, text=str.tostring(lower_strike_2, "#.## (") + str.tostring(lo_percent_2, "#.##") + "%｜" + str.tostring(lo_points_2, "#.##") + ")", style=label.style_label_left, color=color.new(color.white, 100), textcolor=i_s_col)
        label.delete(lower_label_2[1])
    if show_avg
        var line lo_avg_2_line = na
        lo_avg_2_line := line.new(x1=bar_index - 225, y1=lo_avg_2, x2=bar_index + 10, y2=lo_avg_2, color=i_s_col, width=i_pp_avg_width, style=i_pp_avg_style, extend=ext_option)
        line.delete(lo_avg_2_line[1])

if show_s_3 and show_pp
    var line lower_line_3 = na
    lower_line_3 := line.new(x1=bar_index - 225, y1=lower_strike_3, x2=bar_index + 10, y2=lower_strike_3, color=i_s_col, width=i_pp_width, style=i_pp_style, extend=ext_option)
    line.delete(lower_line_3[1])
    if show_pp_label
        var label lower_label_3 = na
        lower_label_3 := label.new(x=bar_index + 10, y=lower_strike_3, text=str.tostring(lower_strike_3, "#.## (") + str.tostring(lo_percent_3, "#.##") + "%｜" + str.tostring(lo_points_3, "#.##") + ")", style=label.style_label_left, color=color.new(color.white, 100), textcolor=i_s_col)
        label.delete(lower_label_3[1])
    if show_avg
        var line lo_avg_3_line = na
        lo_avg_3_line := line.new(x1=bar_index - 225, y1=lo_avg_3, x2=bar_index + 10, y2=lo_avg_3, color=i_s_col, width=i_pp_avg_width, style=i_pp_avg_style, extend=ext_option)
        line.delete(lo_avg_3_line[1])

if show_s_4 and show_pp
    var line lower_line_4 = na
    lower_line_4 := line.new(x1=bar_index - 225, y1=lower_strike_4, x2=bar_index + 10, y2=lower_strike_4, color=i_s_col, width=i_pp_width, style=i_pp_style, extend=ext_option)
    line.delete(lower_line_4[1])
    if show_pp_label
        var label lower_label_4 = na
        lower_label_4 := label.new(x=bar_index + 10, y=lower_strike_4, text=str.tostring(lower_strike_4, "#.## (") + str.tostring(lo_percent_4, "#.##") + "%｜" + str.tostring(lo_points_4, "#.##") + ")", style=label.style_label_left, color=color.new(color.white, 100), textcolor=i_s_col)
        label.delete(lower_label_4[1])
    if show_avg
        var line lo_avg_4_line = na
        lo_avg_4_line := line.new(x1=bar_index - 225, y1=lo_avg_4, x2=bar_index + 10, y2=lo_avg_4, color=i_s_col, width=i_pp_avg_width, style=i_pp_avg_style, extend=ext_option)
        line.delete(lo_avg_4_line[1])

if show_s_5 and show_pp
    var line lower_line_5 = na
    lower_line_5 := line.new(x1=bar_index - 225, y1=lower_strike_5, x2=bar_index + 10, y2=lower_strike_5, color=i_s_col, width=i_pp_width, style=i_pp_style, extend=ext_option)
    line.delete(lower_line_5[1])
    if show_pp_label
        var label lower_label_5 = na
        lower_label_5 := label.new(x=bar_index + 10, y=lower_strike_5, text=str.tostring(lower_strike_5, "#.## (") + str.tostring(lo_percent_5, "#.##") + "%｜" + str.tostring(lo_points_5, "#.##") + ")", style=label.style_label_left, color=color.new(color.white, 100), textcolor=i_s_col)
        label.delete(lower_label_5[1])
    if show_avg
        var line lo_avg_5_line = na
        lo_avg_5_line := line.new(x1=bar_index - 225, y1=lo_avg_5, x2=bar_index + 10, y2=lo_avg_5, color=i_s_col, width=i_pp_avg_width, style=i_pp_avg_style, extend=ext_option)
        line.delete(lo_avg_5_line[1])



////////////////////////////////////////////////////////// Important Pivots

high_low_time = time(timeframe.period, "1030-1031")
pivot_time = time(timeframe.period, "1030-1600")
no_trade_time = time(timeframe.period, "0930-1029")

high_1hr = ta.valuewhen(no_trade_time, get_high, 0)
low_1hr = ta.valuewhen(no_trade_time, get_low, 0)

////////////////////////////////////////////////////// Price Levels Settings

gpL = "Important Pivots"

//i_r_col = input.color(color.rgb(240, 83, 80), title="", group=gpL, inline="01")
show_rz_1 = input.bool(true, title="R1", group=gpL, inline="01")
show_rz_2 = input.bool(false, title="R2", group=gpL, inline="01")

//s_color = input.color(color.rgb(38, 166, 154), title="", group=gpL, inline="02")
show_sz_1 = input.bool(true, title="S1", group=gpL, inline="01")
show_sz_2 = input.bool(false, title="S2", group=gpL, inline="01")

//show_last = input.bool(true, title="Hide Historical", group=gpL, inline="02")
//islast = show_last ? request.security(syminfo.tickerid, i_timeframe, barstate.islast, lookahead=barmerge.lookahead_on) : true

////////////////////////////////////////////////////////// Strike Price Difference Formula

// Strike Price Difference 0.25
upper_val_spd_0_25_plot_plot = math.round(price_input[i_pd_ltp_o] / spd_2_5, 0) * spd_2_5
lower_val_spd_0_25_plot_plot = math.round(price_input[i_pd_ltp_o] / spd_2_5, 0) * spd_2_5
upper_spd_0_25_plot = upper_val_spd_0_25_plot_plot < price_input[i_pd_ltp_o] ? upper_val_spd_0_25_plot_plot + spd_2_5 : upper_val_spd_0_25_plot_plot
lower_spd_0_25_plot = lower_val_spd_0_25_plot_plot > price_input[i_pd_ltp_o] ? lower_val_spd_0_25_plot_plot - spd_2_5 : lower_val_spd_0_25_plot_plot

// Strike Price Difference 0.5
upper_val_spd_0_5_plot = math.round(price_input[i_pd_ltp_o] / spd_0_5, 0) * spd_0_5
lower_val_spd_0_5_plot = math.round(price_input[i_pd_ltp_o] / spd_0_5, 0) * spd_0_5
upper_spd_0_5_plot = upper_val_spd_0_5_plot < price_input[i_pd_ltp_o] ? upper_val_spd_0_5_plot + spd_0_5 : upper_val_spd_0_5_plot
lower_spd_0_5_plot = lower_val_spd_0_5_plot > price_input[i_pd_ltp_o] ? lower_val_spd_0_5_plot - spd_0_5 : lower_val_spd_0_5_plot

// Strike Price Difference 1
upper_val_spd_1_plot = math.round(price_input[i_pd_ltp_o] / spd_1, 0) * spd_1
lower_val_spd_1_plot = math.round(price_input[i_pd_ltp_o] / spd_1, 0) * spd_1
upper_spd_1_plot = upper_val_spd_1_plot < price_input[i_pd_ltp_o] ? upper_val_spd_1_plot + spd_1 : upper_val_spd_1_plot
lower_spd_1_plot = lower_val_spd_1_plot > price_input[i_pd_ltp_o] ? lower_val_spd_1_plot - spd_1 : lower_val_spd_1_plot

// Strike Price Difference 2.5
upper_val_spd_2_5_plot = math.round(price_input[i_pd_ltp_o] / spd_2_5, 0) * spd_2_5
lower_val_spd_2_5_plot = math.round(price_input[i_pd_ltp_o] / spd_2_5, 0) * spd_2_5
upper_spd_2_5_plot = upper_val_spd_2_5_plot < price_input[i_pd_ltp_o] ? upper_val_spd_2_5_plot + spd_2_5 : upper_val_spd_2_5_plot
lower_spd_2_5_plot = lower_val_spd_2_5_plot > price_input[i_pd_ltp_o] ? lower_val_spd_2_5_plot - spd_2_5 : lower_val_spd_2_5_plot

// Strike Price Difference 5
upper_val_spd_5_plot = math.round(price_input[i_pd_ltp_o] / spd_5, 0) * spd_5
lower_val_spd_5_plot = math.round(price_input[i_pd_ltp_o] / spd_5, 0) * spd_5
upper_spd_5_plot = upper_val_spd_5_plot < price_input[i_pd_ltp_o] ? upper_val_spd_5_plot + spd_5 : upper_val_spd_5_plot
lower_spd_5_plot = lower_val_spd_5_plot > price_input[i_pd_ltp_o] ? lower_val_spd_5_plot - spd_5 : lower_val_spd_5_plot

// Strike Price Difference 10
upper_val_spd_10_plot = math.round(price_input[i_pd_ltp_o] / spd_10, 0) * spd_10
lower_val_spd_10_plot = math.round(price_input[i_pd_ltp_o] / spd_10, 0) * spd_10
upper_spd_10_plot = upper_val_spd_10_plot < price_input[i_pd_ltp_o] ? upper_val_spd_10_plot + spd_10 : upper_val_spd_10_plot
lower_spd_10_plot = lower_val_spd_10_plot > price_input[i_pd_ltp_o] ? lower_val_spd_10_plot - spd_10 : lower_val_spd_10_plot

////////////////////////////////////////////////////////// Upper & Lower Strikes

upper_strike_plot = syminfo.root == sym_001_spd_0_25 ? upper_spd_0_25_plot : syminfo.root == sym_002_spd_0_25 ? upper_spd_0_25_plot : 
     syminfo.root == sym_003_spd_0_5 ? upper_spd_0_5_plot : syminfo.root == sym_004_spd_0_5 ? upper_spd_0_5_plot : syminfo.root == sym_005_spd_0_5 ? upper_spd_0_5_plot : 
     syminfo.root == sym_006_spd_0_5 ? upper_spd_0_5_plot : syminfo.root == sym_007_spd_0_5 ? upper_spd_0_5_plot : syminfo.root == sym_008_spd_0_5 ? upper_spd_0_5_plot : 
     syminfo.root == sym_009_spd_0_5 ? upper_spd_0_5_plot : syminfo.root == sym_010_spd_0_5 ? upper_spd_0_5_plot : 
     syminfo.root == sym_011_spd_1 ? upper_spd_1_plot : syminfo.root == sym_012_spd_1 ? upper_spd_1_plot : syminfo.root == sym_013_spd_1 ? upper_spd_1_plot : 
     syminfo.root == sym_014_spd_1 ? upper_spd_1_plot : syminfo.root == sym_015_spd_1 ? upper_spd_1_plot : syminfo.root == sym_016_spd_1 ? upper_spd_1_plot : 
     syminfo.root == sym_017_spd_1 ? upper_spd_1_plot : syminfo.root == sym_018_spd_1 ? upper_spd_1_plot : syminfo.root == sym_019_spd_1 ? upper_spd_1_plot : 
     syminfo.root == sym_020_spd_1 ? upper_spd_1_plot : syminfo.root == sym_021_spd_1 ? upper_spd_1_plot : syminfo.root == sym_022_spd_1 ? upper_spd_1_plot : 
     syminfo.root == sym_023_spd_1 ? upper_spd_1_plot : syminfo.root == sym_024_spd_1 ? upper_spd_1_plot : syminfo.root == sym_025_spd_1 ? upper_spd_1_plot : 
     syminfo.root == sym_026_spd_1 ? upper_spd_1_plot : syminfo.root == sym_027_spd_1 ? upper_spd_1_plot : syminfo.root == sym_028_spd_1 ? upper_spd_1_plot : 
     syminfo.root == sym_029_spd_1 ? upper_spd_1_plot : syminfo.root == sym_030_spd_1 ? upper_spd_1_plot : syminfo.root == sym_031_spd_1 ? upper_spd_1_plot : 
     syminfo.root == sym_032_spd_1 ? upper_spd_1_plot : syminfo.root == sym_033_spd_1 ? upper_spd_1_plot : syminfo.root == sym_034_spd_1 ? upper_spd_1_plot : 
     syminfo.root == sym_035_spd_1 ? upper_spd_1_plot : syminfo.root == sym_036_spd_1 ? upper_spd_1_plot : syminfo.root == sym_037_spd_1 ? upper_spd_1_plot : 
     syminfo.root == sym_038_spd_1 ? upper_spd_1_plot : syminfo.root == sym_039_spd_1 ? upper_spd_1_plot : syminfo.root == sym_040_spd_1 ? upper_spd_1_plot : 
     syminfo.root == sym_041_spd_1 ? upper_spd_1_plot : syminfo.root == sym_042_spd_1 ? upper_spd_1_plot : syminfo.root == sym_043_spd_1 ? upper_spd_1_plot : 
     syminfo.root == sym_044_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_045_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_046_spd_2_5 ? upper_spd_2_5_plot : 
     syminfo.root == sym_047_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_048_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_049_spd_2_5 ? upper_spd_2_5_plot : 
     syminfo.root == sym_050_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_051_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_052_spd_2_5 ? upper_spd_2_5_plot : 
     syminfo.root == sym_053_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_054_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_055_spd_2_5 ? upper_spd_2_5_plot : 
     syminfo.root == sym_056_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_057_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_058_spd_2_5 ? upper_spd_2_5_plot : 
     syminfo.root == sym_059_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_060_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_061_spd_2_5 ? upper_spd_2_5_plot : 
     syminfo.root == sym_062_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_063_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_064_spd_2_5 ? upper_spd_2_5_plot : 
     syminfo.root == sym_065_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_066_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_067_spd_2_5 ? upper_spd_2_5_plot : 
     syminfo.root == sym_068_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_069_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_070_spd_2_5 ? upper_spd_2_5_plot : 
     syminfo.root == sym_071_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_072_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_073_spd_2_5 ? upper_spd_2_5_plot : 
     syminfo.root == sym_074_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_075_spd_2_5 ? upper_spd_2_5_plot : 
     syminfo.root == sym_076_spd_5 ? upper_spd_5_plot : syminfo.root == sym_077_spd_5 ? upper_spd_5_plot : syminfo.root == sym_078_spd_5 ? upper_spd_5_plot : 
     syminfo.root == sym_079_spd_5 ? upper_spd_5_plot : syminfo.root == sym_080_spd_5 ? upper_spd_5_plot : syminfo.root == sym_081_spd_5 ? upper_spd_5_plot : 
     syminfo.root == sym_082_spd_5 ? upper_spd_5_plot : syminfo.root == sym_083_spd_5 ? upper_spd_5_plot : syminfo.root == sym_084_spd_5 ? upper_spd_5_plot : 
     syminfo.root == sym_085_spd_5 ? upper_spd_5_plot : syminfo.root == sym_086_spd_5 ? upper_spd_5_plot : syminfo.root == sym_087_spd_5 ? upper_spd_5_plot : 
     syminfo.root == sym_088_spd_5 ? upper_spd_5_plot : syminfo.root == sym_089_spd_5 ? upper_spd_5_plot : syminfo.root == sym_090_spd_5 ? upper_spd_5_plot : 
     syminfo.root == sym_091_spd_5 ? upper_spd_5_plot : syminfo.root == sym_092_spd_5 ? upper_spd_5_plot : syminfo.root == sym_093_spd_5 ? upper_spd_5_plot : 
     syminfo.root == sym_094_spd_5 ? upper_spd_5_plot : syminfo.root == sym_095_spd_5 ? upper_spd_5_plot : syminfo.root == sym_096_spd_5 ? upper_spd_5_plot : 
     syminfo.root == sym_097_spd_10 ? upper_spd_10_plot : syminfo.root == sym_098_spd_10 ? upper_spd_10_plot : syminfo.root == sym_099_spd_10 ? upper_spd_10_plot : 
     syminfo.root == sym_100_spd_10 ? upper_spd_10_plot : syminfo.root == sym_101_spd_10 ? upper_spd_10_plot : syminfo.root == sym_102_spd_10 ? upper_spd_10_plot : na

lower_strike_plot = syminfo.root == sym_001_spd_0_25 ? lower_spd_0_25_plot : syminfo.root == sym_002_spd_0_25 ? lower_spd_0_25_plot : 
     syminfo.root == sym_003_spd_0_5 ? lower_spd_0_5_plot : syminfo.root == sym_004_spd_0_5 ? lower_spd_0_5_plot : syminfo.root == sym_005_spd_0_5 ? lower_spd_0_5_plot : 
     syminfo.root == sym_006_spd_0_5 ? lower_spd_0_5_plot : syminfo.root == sym_007_spd_0_5 ? lower_spd_0_5_plot : syminfo.root == sym_008_spd_0_5 ? lower_spd_0_5_plot : 
     syminfo.root == sym_009_spd_0_5 ? lower_spd_0_5_plot : syminfo.root == sym_010_spd_0_5 ? lower_spd_0_5_plot : 
     syminfo.root == sym_011_spd_1 ? lower_spd_1_plot : syminfo.root == sym_012_spd_1 ? lower_spd_1_plot : syminfo.root == sym_013_spd_1 ? lower_spd_1_plot : 
     syminfo.root == sym_014_spd_1 ? lower_spd_1_plot : syminfo.root == sym_015_spd_1 ? lower_spd_1_plot : syminfo.root == sym_016_spd_1 ? lower_spd_1_plot : 
     syminfo.root == sym_017_spd_1 ? lower_spd_1_plot : syminfo.root == sym_018_spd_1 ? lower_spd_1_plot : syminfo.root == sym_019_spd_1 ? lower_spd_1_plot : 
     syminfo.root == sym_020_spd_1 ? lower_spd_1_plot : syminfo.root == sym_021_spd_1 ? lower_spd_1_plot : syminfo.root == sym_022_spd_1 ? lower_spd_1_plot : 
     syminfo.root == sym_023_spd_1 ? lower_spd_1_plot : syminfo.root == sym_024_spd_1 ? lower_spd_1_plot : syminfo.root == sym_025_spd_1 ? lower_spd_1_plot : 
     syminfo.root == sym_026_spd_1 ? lower_spd_1_plot : syminfo.root == sym_027_spd_1 ? lower_spd_1_plot : syminfo.root == sym_028_spd_1 ? lower_spd_1_plot : 
     syminfo.root == sym_029_spd_1 ? lower_spd_1_plot : syminfo.root == sym_030_spd_1 ? lower_spd_1_plot : syminfo.root == sym_031_spd_1 ? lower_spd_1_plot : 
     syminfo.root == sym_032_spd_1 ? lower_spd_1_plot : syminfo.root == sym_033_spd_1 ? lower_spd_1_plot : syminfo.root == sym_034_spd_1 ? lower_spd_1_plot : 
     syminfo.root == sym_035_spd_1 ? lower_spd_1_plot : syminfo.root == sym_036_spd_1 ? lower_spd_1_plot : syminfo.root == sym_037_spd_1 ? lower_spd_1_plot : 
     syminfo.root == sym_038_spd_1 ? lower_spd_1_plot : syminfo.root == sym_039_spd_1 ? lower_spd_1_plot : syminfo.root == sym_040_spd_1 ? lower_spd_1_plot : 
     syminfo.root == sym_041_spd_1 ? lower_spd_1_plot : syminfo.root == sym_042_spd_1 ? lower_spd_1_plot : syminfo.root == sym_043_spd_1 ? lower_spd_1_plot : 
     syminfo.root == sym_044_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_045_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_046_spd_2_5 ? lower_spd_2_5_plot : 
     syminfo.root == sym_047_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_048_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_049_spd_2_5 ? lower_spd_2_5_plot : 
     syminfo.root == sym_050_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_051_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_052_spd_2_5 ? lower_spd_2_5_plot : 
     syminfo.root == sym_053_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_054_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_055_spd_2_5 ? lower_spd_2_5_plot : 
     syminfo.root == sym_056_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_057_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_058_spd_2_5 ? lower_spd_2_5_plot : 
     syminfo.root == sym_059_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_060_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_061_spd_2_5 ? lower_spd_2_5_plot : 
     syminfo.root == sym_062_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_063_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_064_spd_2_5 ? lower_spd_2_5_plot : 
     syminfo.root == sym_065_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_066_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_067_spd_2_5 ? lower_spd_2_5_plot : 
     syminfo.root == sym_068_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_069_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_070_spd_2_5 ? lower_spd_2_5_plot : 
     syminfo.root == sym_071_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_072_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_073_spd_2_5 ? lower_spd_2_5_plot : 
     syminfo.root == sym_074_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_075_spd_2_5 ? lower_spd_2_5_plot : 
     syminfo.root == sym_076_spd_5 ? lower_spd_5_plot : syminfo.root == sym_077_spd_5 ? lower_spd_5_plot : syminfo.root == sym_078_spd_5 ? lower_spd_5_plot : 
     syminfo.root == sym_079_spd_5 ? lower_spd_5_plot : syminfo.root == sym_080_spd_5 ? lower_spd_5_plot : syminfo.root == sym_081_spd_5 ? lower_spd_5_plot : 
     syminfo.root == sym_082_spd_5 ? lower_spd_5_plot : syminfo.root == sym_083_spd_5 ? lower_spd_5_plot : syminfo.root == sym_084_spd_5 ? lower_spd_5_plot : 
     syminfo.root == sym_085_spd_5 ? lower_spd_5_plot : syminfo.root == sym_086_spd_5 ? lower_spd_5_plot : syminfo.root == sym_087_spd_5 ? lower_spd_5_plot : 
     syminfo.root == sym_088_spd_5 ? lower_spd_5_plot : syminfo.root == sym_089_spd_5 ? lower_spd_5_plot : syminfo.root == sym_090_spd_5 ? lower_spd_5_plot : 
     syminfo.root == sym_091_spd_5 ? lower_spd_5_plot : syminfo.root == sym_092_spd_5 ? lower_spd_5_plot : syminfo.root == sym_093_spd_5 ? lower_spd_5_plot : 
     syminfo.root == sym_094_spd_5 ? lower_spd_5_plot : syminfo.root == sym_095_spd_5 ? lower_spd_5_plot : syminfo.root == sym_096_spd_5 ? lower_spd_5_plot : 
     syminfo.root == sym_097_spd_10 ? lower_spd_10_plot : syminfo.root == sym_098_spd_10 ? lower_spd_10_plot : syminfo.root == sym_099_spd_10 ? lower_spd_10_plot : 
     syminfo.root == sym_100_spd_10 ? lower_spd_10_plot : syminfo.root == sym_101_spd_10 ? lower_spd_10_plot : syminfo.root == sym_102_spd_10 ? lower_spd_10_plot : na

////////////////////////////////////////////////////////// Strike Price Difference

spd_plot = upper_strike_plot - lower_strike_plot

////////////////////////////////////////////////////////// Higher Strikes

upper_strike_2_plot = upper_strike_plot + spd_plot
upper_strike_3_plot = upper_strike_plot + (2 * spd_plot)

lower_strike_2_plot = lower_strike_plot - spd_plot
lower_strike_3_plot = lower_strike_plot - (2 * spd_plot)

////////////////////////////////////////////////////////// First One Hour Highlight

//bgcolor(no_trade_time ? color.new(color.silver, 95) : na)

////////////////////////////////////////////////////////// Plot Important Pivots

rz_1_2_line = plot(pivot_time and show_rz_1 ? upper_strike_plot : na, "R1", style=plot.style_linebr, color=color.new(#EF5350, 0), linewidth=3)
rz_2_2_line = plot(pivot_time and show_rz_2 ? upper_strike_2_plot : na, "R2", style=plot.style_linebr, color=color.new(#EF5350, 0), linewidth=3)

sz_1_2_line = plot(pivot_time and show_sz_1 ? lower_strike_plot : na, "S1", style=plot.style_linebr, color=color.new(#26A69A, 0), linewidth=3)
sz_2_2_line = plot(pivot_time and show_sz_2 ? lower_strike_2_plot : na, "S2", style=plot.style_linebr, color=color.new(#26A69A, 0), linewidth=3)



////////////////////////////////////////////////////////// Time Markers

gpT = "Time (IST) (Vertical)"

show_time_01 = input.bool(false, title="", group=gpT, inline="_01")
i_hour_01 = input.int(10, minval=0, title="", group=gpT, inline="_01")
i_minute_01 = input.int(30, minval=0, title=":", group=gpT, inline="_01")
i_t_col_01 = input.color(color.silver, title="", group=gpT, inline="_01")

show_time_02 = input.bool(true, title="", group=gpT, inline="_02")
i_hour_02 = input.int(11, minval=0, title="", group=gpT, inline="_02")
i_minute_02 = input.int(30, minval=0, title=":", group=gpT, inline="_02")
i_t_col_02 = input.color(color.silver, title="", group=gpT, inline="_02")

show_time_03 = input.bool(false, title="", group=gpT, inline="_03")
i_hour_03 = input.int(12, minval=0, title="", group=gpT, inline="_03")
i_minute_03 = input.int(30, minval=0, title=":", group=gpT, inline="_03")
i_t_col_03 = input.color(color.silver, title="", group=gpT, inline="_03")

show_time_04 = input.bool(false, title="", group=gpT, inline="_04")
i_hour_04 = input.int(13, minval=0, title="", group=gpT, inline="_04")
i_minute_04 = input.int(30, minval=0, title=":", group=gpT, inline="_04")
i_t_col_04 = input.color(color.silver, title="", group=gpT, inline="_04")

show_time_05 = input.bool(false, title="", group=gpT, inline="_05")
i_hour_05 = input.int(14, minval=0, title="", group=gpT, inline="_05")
i_minute_05 = input.int(30, minval=0, title=":", group=gpT, inline="_05")
i_t_col_05 = input.color(color.silver, title="", group=gpT, inline="_05")

show_time_06 = input.bool(false, title="", group=gpT, inline="_06")
i_hour_06 = input.int(15, minval=0, title="", group=gpT, inline="_06")
i_minute_06 = input.int(30, minval=0, title=":", group=gpT, inline="_06")
i_t_col_06 = input.color(color.silver, title="", group=gpT, inline="_06")

i_t_style = input.string(line.style_dotted, title = "", options = [line.style_solid, line.style_dashed, line.style_dotted], group=gpT, inline="_07")
i_t_width = input.int(1, title = "", minval=1, group=gpT, inline="_07")

show_time_label = input.bool(false, title="Time Label", group=gpT, inline="_08")

if show_time_01
    time_01 = timestamp("GMT-0400", year, month, dayofmonth, i_hour_01, i_minute_01, 00)
    time_01_line = line.new(x1=time_01, y1=open, x2=time_01, y2=close, xloc=xloc.bar_time, extend=extend.both, color=i_t_col_01, style=i_t_style, width=i_t_width)
    line.delete(time_01_line[1])
    if show_time_label
        var label time_01_label = na
        time_01_label := label.new(x=time_01, y=high, text=str.tostring(i_hour_01) + ":" + str.tostring(i_minute_01), textcolor=i_t_col_01, textalign=text.align_center, color=color.new(color.white, 100), style=label.style_label_down, size=size.normal, xloc=xloc.bar_time, yloc=yloc.abovebar)
        label.delete(time_01_label[1])
    
//    nd_time_01 = timestamp("GMT-0400", year, month , dayofmonth + 1, i_hour_01, i_minute_01, 00)
//    nd_time_01_line = line.new(x1=nd_time_01, y1=open, x2=nd_time_01, y2=close, xloc=xloc.bar_time, extend=extend.both, color=color.new(color.silver, 0), style=i_t_style, width=i_t_width)
//    line.delete(nd_time_01_line[1])

    pd_time_02 = timestamp("GMT-0400", year, month , dayofmonth - 1, i_hour_05, i_minute_05, 00)
    pd_time_02_line = line.new(x1=pd_time_02, y1=open, x2=pd_time_02, y2=close, xloc=xloc.bar_time, extend=extend.both, color=i_t_col_05, style=i_t_style, width=i_t_width)
    line.delete(pd_time_02_line[1])
    if show_time_label
        var label pd_time_02_label = na
        pd_time_02_label := label.new(x=pd_time_02, y=high, text=str.tostring(i_hour_05) + ":" + str.tostring(i_minute_05), textcolor=i_t_col_05, textalign=text.align_center, color=color.new(color.white, 100), style=label.style_label_down, size=size.normal, xloc=xloc.bar_time, yloc=yloc.abovebar)
        label.delete(pd_time_02_label[1])

if show_time_02
    time_02 = timestamp("GMT-0400", year, month , dayofmonth, i_hour_02, i_minute_02, 00)
    time_02_line = line.new(x1=time_02, y1=open, x2=time_02, y2=close, xloc=xloc.bar_time, extend=extend.both, color=i_t_col_02, style=i_t_style, width=i_t_width)
    line.delete(time_02_line[1])
    if show_time_label
        var label time_02_label = na
        time_02_label := label.new(x=time_02, y=high, text=str.tostring(i_hour_02) + ":" + str.tostring(i_minute_02), textcolor=i_t_col_02, textalign=text.align_center, color=color.new(color.white, 100), style=label.style_label_down, size=size.normal, xloc=xloc.bar_time, yloc=yloc.abovebar)
        label.delete(time_02_label[1])

if show_time_03
    time_03 = timestamp("GMT-0400", year, month , dayofmonth, i_hour_03, i_minute_03, 00)
    time_03_line = line.new(x1=time_03, y1=open, x2=time_03, y2=close, xloc=xloc.bar_time, extend=extend.both, color=i_t_col_03, style=i_t_style, width=i_t_width)
    line.delete(time_03_line[1])
    if show_time_label
        var label time_03_label = na
        time_03_label := label.new(x=time_03, y=high, text=str.tostring(i_hour_03) + ":" + str.tostring(i_minute_03), textcolor=i_t_col_03, textalign=text.align_center, color=color.new(color.white, 100), style=label.style_label_down, size=size.normal, xloc=xloc.bar_time, yloc=yloc.abovebar)
        label.delete(time_03_label[1])

if show_time_04
    time_04 = timestamp("GMT-0400", year, month , dayofmonth, i_hour_04, i_minute_04, 00)
    time_04_line = line.new(x1=time_04, y1=open, x2=time_04, y2=close, xloc=xloc.bar_time, extend=extend.both, color=i_t_col_04, style=i_t_style, width=i_t_width)
    line.delete(time_04_line[1])
    if show_time_label
        var label time_04_label = na
        time_04_label := label.new(x=time_04, y=high, text=str.tostring(i_hour_04) + ":" + str.tostring(i_minute_04), textcolor=i_t_col_04, textalign=text.align_center, color=color.new(color.white, 100), style=label.style_label_down, size=size.normal, xloc=xloc.bar_time, yloc=yloc.abovebar)
        label.delete(time_04_label[1])

if show_time_05
    time_05 = timestamp("GMT-0400", year, month , dayofmonth, i_hour_05, i_minute_05, 00)
    time_05_line = line.new(x1=time_05, y1=open, x2=time_05, y2=close, xloc=xloc.bar_time, extend=extend.both, color=i_t_col_05, style=i_t_style, width=i_t_width)
    line.delete(time_05_line[1])
    if show_time_label
        var label time_05_label = na
        time_05_label := label.new(x=time_05, y=high, text=str.tostring(i_hour_05) + ":" + str.tostring(i_minute_05), textcolor=i_t_col_05, textalign=text.align_center, color=color.new(color.white, 100), style=label.style_label_down, size=size.normal, xloc=xloc.bar_time, yloc=yloc.abovebar)
        label.delete(time_05_label[1])

if show_time_06
    time_06 = timestamp("GMT-0400", year, month , dayofmonth, i_hour_06, i_minute_06, 00)
    time_06_line = line.new(x1=time_06, y1=open, x2=time_06, y2=close, xloc=xloc.bar_time, extend=extend.both, color=i_t_col_06, style=i_t_style, width=i_t_width)
    line.delete(time_06_line[1])
    if show_time_label
        var label time_06_label = na
        time_06_label := label.new(x=time_06, y=high, text=str.tostring(i_hour_06) + ":" + str.tostring(i_minute_06), textcolor=i_t_col_06, textalign=text.align_center, color=color.new(color.white, 100), style=label.style_label_down, size=size.normal, xloc=xloc.bar_time, yloc=yloc.abovebar)
        label.delete(time_06_label[1])
        
        //linefill.new(pd_time_02_line, time_01_line, color.new(color.black, 95))

////////////////////////////////////////////////////////// END