本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=4
study(title="Key Fib Pivot S/R Levels", shorttitle="S/R Levels", overlay=true)
// Function outputs 1 when it's the first bar of the D/W/M/Y
is_newbar(res) =>
ch = 0
if(res == 'Y')
t = year(time('D'))
ch := change(t) != 0 ? 1 : 0
else
t = time(res)
ch := change(t) != 0 ? 1 : 0
ch
//Inputs
pp_period = input(title = "Period", type=input.string, defval="Day", options = ['Day', 'Week', 'Month', 'Year'])
pp_res = pp_period == 'Day' ? 'D' : pp_period == 'Week' ? 'W' : pp_period == 'Month' ? 'M' : 'Y'
Year_SR = timeframe.period == '5' or timeframe.period == '15' or timeframe.period == '60' or timeframe.period == '240' or timeframe.period == 'D'
Month_SR = timeframe.period == '5' or timeframe.period == '15' or timeframe.period == '60'
Week_SR = timeframe.period == '1' or timeframe.period == '5' or timeframe.period == '15'
// Today's Session Start timestamp
y = year(timenow)
m = month(timenow)
d = dayofmonth(timenow)
// Start & End time for Today
start = timestamp(y, m, d, 00, 00)
end = start + 86400000
// Plot only if session started
isToday = timenow > start
red = color.new(#e57373,0)
green = color.new(#81c784,0)
/////////////////////
// Get HLC for Yearly Pivots//
// Calc High
yhigh_cur = 0.0
yhigh_cur := is_newbar('Y') ? high : max(yhigh_cur[1], high)
yphigh = 0.0
yphigh := is_newbar('Y') ? yhigh_cur[1] : yphigh[1]
// Calc Low
ylow_cur = 0.0
ylow_cur := is_newbar('Y') ? low : min(ylow_cur[1], low)
yplow = 0.0
yplow := is_newbar('Y') ? ylow_cur[1] : yplow[1]
// Calc Close
ypclose = 0.0
ypclose := is_newbar('Y') ? close[1] : ypclose[1]
//Yearly Pivot Points
ypivot = (yphigh + yplow + ypclose) / 3
yr10 = ypivot + (yphigh - yplow) * 2.000
yr9 = ypivot + (yphigh - yplow) * 1.618
yr8 = ypivot + (yphigh - yplow) * 1.414
yr7 = ypivot + (yphigh - yplow) * 1.272
yr6 = ypivot + (yphigh - yplow) * 1.000
yr5 = ypivot + (yphigh - yplow) * 0.764
yr4 = ypivot + (yphigh - yplow) * 0.618
yr3 = ypivot + (yphigh - yplow) * 0.500
yr2 = ypivot + (yphigh - yplow) * 0.382
yr1 = ypivot + (yphigh - yplow) * 0.236
ys1 = ypivot - (yphigh - yplow) * 0.236
ys2 = ypivot - (yphigh - yplow) * 0.382
ys3 = ypivot - (yphigh - yplow) * 0.500
ys4 = ypivot - (yphigh - yplow) * 0.618
ys5 = ypivot - (yphigh - yplow) * 0.764
ys6 = ypivot - (yphigh - yplow) * 1.000
ys7 = ypivot - (yphigh - yplow) * 1.272
ys8 = ypivot - (yphigh - yplow) * 1.414
ys9 = ypivot - (yphigh - yplow) * 1.618
ys10 = ypivot - (yphigh - yplow) * 2.000
// Get HLC for Monthly Pivots//
// Calc High
mhigh_cur = 0.0
mhigh_cur := is_newbar('M') ? high : max(mhigh_cur[1], high)
mphigh = 0.0
mphigh := is_newbar('M') ? mhigh_cur[1] : mphigh[1]
// Calc Low
mlow_cur = 0.0
mlow_cur := is_newbar('M') ? low : min(mlow_cur[1], low)
mplow = 0.0
mplow := is_newbar('M') ? mlow_cur[1] : mplow[1]
// Calc Close
mpclose = 0.0
mpclose := is_newbar('M') ? close[1] : mpclose[1]
//Monthly Pivot Points
mpivot = (mphigh + mplow + mpclose) / 3
mr10 = mpivot + (mphigh - mplow) * 2.000
mr9 = mpivot + (mphigh - mplow) * 1.618
mr8 = mpivot + (mphigh - mplow) * 1.414
mr7 = mpivot + (mphigh - mplow) * 1.272
mr6 = mpivot + (mphigh - mplow) * 1.000
mr5 = mpivot + (mphigh - mplow) * 0.764
mr4 = mpivot + (mphigh - mplow) * 0.618
mr3 = mpivot + (mphigh - mplow) * 0.500
mr2 = mpivot + (mphigh - mplow) * 0.382
mr1 = mpivot + (mphigh - mplow) * 0.236
ms1 = mpivot - (mphigh - mplow) * 0.236
ms2 = mpivot - (mphigh - mplow) * 0.382
ms3 = mpivot - (mphigh - mplow) * 0.500
ms4 = mpivot - (mphigh - mplow) * 0.618
ms5 = mpivot - (mphigh - mplow) * 0.764
ms6 = mpivot - (mphigh - mplow) * 1.000
ms7 = mpivot - (mphigh - mplow) * 1.272
ms8 = mpivot - (mphigh - mplow) * 1.414
ms9 = mpivot - (mphigh - mplow) * 1.618
ms10= mpivot - (mphigh - mplow) * 2.000
// Get HLC for Weekly Pivots//
// Calc High
whigh_cur = 0.0
whigh_cur := is_newbar('W') ? high : max(whigh_cur[1], high)
wphigh = 0.0
wphigh := is_newbar('W') ? whigh_cur[1] : wphigh[1]
// Calc Low
wlow_cur = 0.0
wlow_cur := is_newbar('W') ? low : min(wlow_cur[1], low)
wplow = 0.0
wplow := is_newbar('W') ? wlow_cur[1] : wplow[1]
// Calc Close
wpclose = 0.0
wpclose := is_newbar('W') ? close[1] : wpclose[1]
//Weekly Pivot Points
wpivot = (wphigh + wplow + wpclose) / 3
wr10 = wpivot + (wphigh - wplow) * 2.000
wr9 = wpivot + (wphigh - wplow) * 1.618
wr8 = wpivot + (wphigh - wplow) * 1.414
wr7 = wpivot + (wphigh - wplow) * 1.272
wr6 = wpivot + (wphigh - wplow) * 1.000
wr5 = wpivot + (wphigh - wplow) * 0.764
wr4 = wpivot + (wphigh - wplow) * 0.618
wr3 = wpivot + (wphigh - wplow) * 0.500
wr2 = wpivot + (wphigh - wplow) * 0.382
wr1 = wpivot + (wphigh - wplow) * 0.236
ws1 = wpivot - (wphigh - wplow) * 0.236
ws2 = wpivot - (wphigh - wplow) * 0.382
ws3 = wpivot - (wphigh - wplow) * 0.500
ws4 = wpivot - (wphigh - wplow) * 0.618
ws5 = wpivot - (wphigh - wplow) * 0.764
ws6 = wpivot - (wphigh - wplow) * 1.000
ws7 = wpivot - (wphigh - wplow) * 1.272
ws8 = wpivot - (wphigh - wplow) * 1.414
ws9 = wpivot - (wphigh - wplow) * 1.618
ws10 = wpivot - (wphigh - wplow) * 2.000
// Get HLC for Daily Pivots//
// Calc Close
pclose = 0.0
pclose := is_newbar('D') ? close[1] : pclose[1]
hclose = 0.0
hclose := is_newbar('60') ? close[1] : hclose[1]
mclose = 0.0
mclose := is_newbar('30') ? close[1] : mclose[1]
//Mid level pivots
bars_sinse = 0
bars_sinse := is_newbar('D') ? 0 : bars_sinse[1] + 1
//MONTH LEVELS
//Month Bull Rules
aboveYearPivot = mclose > wpivot
belowYearPivot = mclose < wpivot
aboveYearR1 = mclose > wr1
belowYearR1 = mclose < wr1
aboveYearR2 = mclose > wr2
belowYearR2 = mclose < wr2
aboveYearR4 = mclose > wr4
belowYearR4 = mclose < wr4
aboveYearR5 = mclose > wr5
belowYearR5 = mclose < wr5
aboveYearR6 = mclose > wr6
belowYearR6 = mclose < wr6
aboveYearR7 = mclose > wr7
belowYearR7 = mclose < wr7
aboveYearR8 = mclose > wr8
belowYearR8 = mclose < wr8
aboveYearR9 = mclose > wr9
belowYearR9 = mclose < wr9
aboveYearR10 = mclose > wr10
belowYearR10 = mclose < wr10
closeHigh1 = aboveYearPivot and belowYearR1
closeHigh2 = aboveYearR1 and belowYearR2
closeHigh3 = aboveYearR2 and belowYearR4
closeHigh4 = aboveYearR4 and belowYearR5
closeHigh5 = aboveYearR5 and belowYearR6
closeHigh6 = aboveYearR6 and belowYearR7
closeHigh7 = aboveYearR7 and belowYearR8
closeHigh8 = aboveYearR8 and belowYearR9
closeHigh9 = aboveYearR9 and belowYearR10
//Daily Bear Rules
aboveYearPivote = mclose > wpivot
belowYearPivote = mclose < wpivot
aboveYearS1e = mclose > ws1
belowYearS1e = mclose < ws1
aboveYearS2e = mclose > ws2
belowYearS2e = mclose < ws2
aboveYearS4e = mclose > ws4
belowYearS4e = mclose < ws4
aboveYearS5e = mclose > ws5
belowYearS5e = mclose < ws5
aboveYearS6e = mclose > ws6
belowYearS6e = mclose < ws6
aboveYearS7e = mclose > ws7
belowYearS7e = mclose < ws7
aboveYearS8e = mclose > ws8
belowYearS8e = mclose < ws8
aboveYearS9e = mclose > ws9
belowYearS9e = mclose < ws9
aboveYearS10e = mclose > ws10
belowYearS10e = mclose < ws10
closeLow1 = belowYearPivote and aboveYearS1e
closeLow2 = belowYearS1e and aboveYearS2e
closeLow3 = belowYearS2e and aboveYearS4e
closeLow4 = belowYearS4e and aboveYearS5e
closeLow5 = belowYearS5e and aboveYearS6e
closeLow6 = belowYearS6e and aboveYearS7e
closeLow7 = belowYearS7e and aboveYearS8e
closeLow8 = belowYearS8e and aboveYearS9e
closeLow9 = belowYearS9e and aboveYearS10e
//Year Bull S/R Levels
//Bull Situation 1
BullR1Resistance = 0.0
BullR1Resistance := closeHigh1 ? wr1 : na
BullPivotSupport = 0.0
BullPivotSupport := closeHigh1 ? wpivot : na
//Bull Situation 2
BullR2Resistance = 0.0
BullR2Resistance := closeHigh2 ? wr2 : na
BullR1Support = 0.0
BullR1Support := closeHigh2 ? wr1 : na
//Bull Situation 3
BullR4Resistance = 0.0
BullR4Resistance := closeHigh3 ? wr4 : na
BullR2Support = 0.0
BullR2Support := closeHigh3 ? wr2 : na
//Bull Situation 4
BullR5Resistance = 0.0
BullR5Resistance := closeHigh4 ? wr5 : na
BullR4Support = 0.0
BullR4Support := closeHigh4 ? wr4 : na
//Bull Situation 5
BullR6Resistance = 0.0
BullR6Resistance := closeHigh5 ? wr6 : na
BullR5Support = 0.0
BullR5Support := closeHigh5 ? wr5 : na
//Bull Situation 6
BullR7Resistance = 0.0
BullR7Resistance := closeHigh6 ? wr7 : na
BullR6Support = 0.0
BullR6Support := closeHigh6 ? wr6 : na
//Bull Situation 7
BullR8Resistance = 0.0
BullR8Resistance := closeHigh7 ? mr8 : na
BullR7Support = 0.0
BullR7Support := closeHigh7 ? mr7 : na
//Bull Situation 8
BullR9Resistance = 0.0
BullR9Resistance := closeHigh8 ? wr9 : na
BullR8Support = 0.0
BullR8Support := closeHigh8 ? wr8 : na
//Bull Situation 9
BullR10Resistance = 0.0
BullR10Resistance := closeHigh9 ? wr10 : na
BullR9Support = 0.0
BullR9Support := closeHigh9 ? wr9 : na
//Bull Values
//Bull Situation 1
BullR1RValue = valuewhen(isToday and Week_SR, BullR1Resistance, 0)
BullPivotSValue = valuewhen(isToday and Week_SR, BullPivotSupport, 0)
//Bull Situation 2
BullR2RValue = valuewhen(isToday and Week_SR, BullR2Resistance, 0)
BullR1SValue = valuewhen(isToday and Week_SR, BullR1Support, 0)
//Bull Situation 3
BullR4RValue = valuewhen(isToday and Week_SR, BullR4Resistance, 0)
BullR2SValue = valuewhen(isToday and Week_SR, BullR2Support, 0)
//Bull Situation 4
BullR5RValue = valuewhen(isToday and Week_SR, BullR5Resistance, 0)
BullR4SValue = valuewhen(isToday and Week_SR, BullR4Support, 0)
//Bull Situation 5
BullR6RValue = valuewhen(isToday and Week_SR, BullR6Resistance, 0)
BullR5SValue = valuewhen(isToday and Week_SR, BullR5Support, 0)
//Bull Situation 6
BullR7RValue = valuewhen(isToday and Week_SR, BullR7Resistance, 0)
BullR6SValue = valuewhen(isToday and Week_SR, BullR6Support, 0)
//Bull Situation 7
BullR8RValue = valuewhen(isToday and Week_SR, BullR8Resistance, 0)
BullR7SValue = valuewhen(isToday and Week_SR, BullR7Support, 0)
//Bull Situation 8
BullR9RValue = valuewhen(isToday and Week_SR, BullR9Resistance, 0)
BullR8SValue = valuewhen(isToday and Week_SR, BullR8Support, 0)
//Bull Situation 9
BullR10RValue = valuewhen(isToday and Week_SR, BullR10Resistance, 0)
BullR9SValue = valuewhen(isToday and Week_SR, BullR9Support, 0)
//Bull S/R Lines and Labels//
//Bull Situation 1
BullR1RLevel = line.new(bar_index[bars_sinse], BullR1RValue, bar_index, BullR1RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_BullR1RLevel = label.new(end, BullR1RValue, "Week R1", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
BullPivotSLevel = line.new(bar_index[bars_sinse], BullPivotSValue, bar_index, BullPivotSValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_BullPivotSLevel = label.new(end, BullPivotSValue, "Week Pivot", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bull Situation 2
BullR2RLevel = line.new(bar_index[bars_sinse], BullR2RValue, bar_index, BullR2RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_BullR2RLevel = label.new(end, BullR2RValue, "Week R2", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
BullR1SLevel = line.new(bar_index[bars_sinse], BullR1SValue, bar_index, BullR1SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_BullR1SLevel = label.new(end, BullR1SValue, "Week R1", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bull Situation 3
BullR4RLevel = line.new(bar_index[bars_sinse], BullR4RValue, bar_index, BullR4RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_BullR4RLevel = label.new(end, BullR4RValue, "Week R4", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
BullR2SLevel = line.new(bar_index[bars_sinse], BullR2SValue, bar_index, BullR2SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_BullR2SLevel = label.new(end, BullR2SValue, "Week R2", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bull Situation 4
BullR5RLevel = line.new(bar_index[bars_sinse], BullR5RValue, bar_index, BullR5RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_BullR5RLevel = label.new(end, BullR5RValue, "Week R5", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
BullR4SLevel = line.new(bar_index[bars_sinse], BullR4SValue, bar_index, BullR4SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_BullR4SLevel = label.new(end, BullR4SValue, "Week R4", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bull Situation 5
BullR6RLevel = line.new(bar_index[bars_sinse], BullR6RValue, bar_index, BullR6RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_BullR6RLevel = label.new(end, BullR6RValue, "Week R6", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
BullR5SLevel = line.new(bar_index[bars_sinse], BullR5SValue, bar_index, BullR5SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_BullR5SLevel = label.new(end, BullR5SValue, "Week R5", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bull Situation 6
BullR7RLevel = line.new(bar_index[bars_sinse], BullR7RValue, bar_index, BullR7RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_BullR7RLevel = label.new(end, BullR7RValue, "Week R7", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
BullR6SLevel = line.new(bar_index[bars_sinse], BullR6SValue, bar_index, BullR6SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_BullR6SLevel = label.new(end, BullR6SValue, "Week R6", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bull Situation 7
BullR8RLevel = line.new(bar_index[bars_sinse], BullR8RValue, bar_index, BullR8RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_BullR8RLevel = label.new(end, BullR8RValue, "Week R8", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
BullR17SLevel = line.new(bar_index[bars_sinse], BullR7SValue, bar_index, BullR7SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_BullR7SLevel = label.new(end, BullR7SValue, "Week R7", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bull Situation 8
BullR9RLevel = line.new(bar_index[bars_sinse], BullR9RValue, bar_index, BullR9RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_BullR9RLevel = label.new(end, BullR9RValue, "Week R9", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
BullR8SLevel = line.new(bar_index[bars_sinse], BullR8SValue, bar_index, BullR8SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_BullR8SLevel = label.new(end, BullR8SValue, "Week R8", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bull Situation 9
BullR10RLevel = line.new(bar_index[bars_sinse], BullR10RValue, bar_index, BullR10RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_BullR10RLevel = label.new(end, BullR10RValue, "Week R10", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
BullR9SLevel = line.new(bar_index[bars_sinse], BullR9SValue, bar_index, BullR9SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_BullR9SLevel = label.new(end, BullR9SValue, "Week R9", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Year Bear S/R Levels//
//Bear Situation 1
BearPivotResistance = 0.0
BearPivotResistance := closeLow1 ? wpivot : na
BearS1Support = 0.0
BearS1Support := closeLow1 ? ws1 : na
//Bear Situation 2
BearS1Resistance = 0.0
BearS1Resistance := closeLow2 ? ws1 : na
BearS2Support = 0.0
BearS2Support := closeLow2 ? ws2 : na
//Bear Situation 3
BearS2Resistance = 0.0
BearS2Resistance := closeLow3 ? ws2 : na
BearS4Support = 0.0
BearS4Support := closeLow3 ? ws4 : na
//Bear Situation 4
BearS4Resistance = 0.0
BearS4Resistance := closeLow4 ? ws4 : na
BearS5Support = 0.0
BearS5Support := closeLow4 ? ws5 : na
//Bear Situation 5
BearS5Resistance = 0.0
BearS5Resistance := closeLow5 ? ws5 : na
BearS6Support = 0.0
BearS6Support := closeLow5 ? ws6 : na
//Bear Situation 6
BearS6Resistance = 0.0
BearS6Resistance := closeLow6 ? ws6 : na
BearS7Support = 0.0
BearS7Support := closeLow6 ? ws7 : na
//Bear Situation 7
BearS7Resistance = 0.0
BearS7Resistance := closeLow7 ? ws7 : na
BearS8Support = 0.0
BearS8Support := closeLow7 ? ws8 : na
//Bear Situation 8
BearS8Resistance = 0.0
BearS8Resistance := closeLow8 ? ws8 : na
BearS9Support = 0.0
BearS9Support := closeLow8 ? ws9 : na
//Bear Situation 9
BearS9Resistance = 0.0
BearS9Resistance := closeLow9 ? ws9 : na
BearS10Support = 0.0
BearS10Support := closeLow9 ? ws10 : na
//Bear Values
//Bear Situation 1
BearPivotRValue = valuewhen(isToday and Week_SR, BearPivotResistance, 0)
BearS1SValue = valuewhen(isToday and Week_SR, BearS1Support, 0)
//Bear Situation 2
BearS1RValue = valuewhen(isToday and Week_SR, BearS1Resistance, 0)
BearS2SValue = valuewhen(isToday and Week_SR, BearS2Support, 0)
//Bear Situation 3
BearS2RValue = valuewhen(isToday and Week_SR, BearS2Resistance, 0)
BearS4SValue = valuewhen(isToday and Week_SR, BearS4Support, 0)
//Bear Situation 4
BearS4RValue = valuewhen(isToday and Week_SR, BearS4Resistance, 0)
BearS5SValue = valuewhen(isToday and Week_SR, BearS5Support, 0)
//Bear Situation 5
BearS5RValue = valuewhen(isToday and Week_SR, BearS5Resistance, 0)
BearS6SValue = valuewhen(isToday and Week_SR, BearS6Support, 0)
//Bear Situation 6
BearS6RValue = valuewhen(isToday and Week_SR, BearS6Resistance, 0)
BearS7SValue = valuewhen(isToday and Week_SR, BearS7Support, 0)
//Bear Situation 7
BearS7RValue = valuewhen(isToday and Week_SR, BearS7Resistance, 0)
BearS8SValue = valuewhen(isToday and Week_SR, BearS8Support, 0)
//Bear Situation 8
BearS8RValue = valuewhen(isToday and Week_SR, BearS8Resistance, 0)
BearS9SValue = valuewhen(isToday and Week_SR, BearS9Support, 0)
//Bear Situation 9
BearS9RValue = valuewhen(isToday and Week_SR, BearS9Resistance, 0)
BearS10SValue = valuewhen(isToday and Week_SR, BearS10Support, 0)
//Bear S/R Lines and Labels
//Bear Situation 1
BearPivotRLevel = line.new(bar_index[bars_sinse], BearPivotRValue, bar_index, BearPivotRValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_BearPivotRLevel = label.new(end, BearPivotRValue, "Week Pivot", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
BearS1SLevel = line.new(bar_index[bars_sinse], BearS1SValue, bar_index, BearS1SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_BearS1SLevel = label.new(end, BearS1SValue, "Week S1", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bear Situation 2
BearS1RLevel = line.new(bar_index[bars_sinse], BearS1RValue, bar_index, BearS1RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_BearS1RLevel = label.new(end, BearS1RValue, "Week S1", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
BearS2SLevel = line.new(bar_index[bars_sinse], BearS2SValue, bar_index, BearS2SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_BearS2SLevel = label.new(end, BearS2SValue, "Week S2", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bear Situation 3
BearS2RLevel = line.new(bar_index[bars_sinse], BearS2RValue, bar_index, BearS2RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_BearS2RLevel = label.new(end, BearS2RValue, "Week S2", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
BearS4SLevel = line.new(bar_index[bars_sinse], BearS4SValue, bar_index, BearS4SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_BearS4SLevel = label.new(end, BearS4SValue, "Week S4", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bear Situation 4
BearS4RLevel = line.new(bar_index[bars_sinse], BearS4RValue, bar_index, BearS4RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_BearS4RLevel = label.new(end, BearS4RValue, "Week S4", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
BearS5SLevel = line.new(bar_index[bars_sinse], BearS5SValue, bar_index, BearS5SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_BearS5SLevel = label.new(end, BearS5SValue, "Week S5", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bear Situation 5
BearS5RLevel = line.new(bar_index[bars_sinse], BearS5RValue, bar_index, BearS5RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_BearS5RLevel = label.new(end, BearS5RValue, "Week S5", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
BearS6SLevel = line.new(bar_index[bars_sinse], BearS6SValue, bar_index, BearS6SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_BearS6SLevel = label.new(end, BearS6SValue, "Week S6", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bear Situation 6
BearS6RLevel = line.new(bar_index[bars_sinse], BearS6RValue, bar_index, BearS6RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_BearS6RLevel = label.new(end, BearS6RValue, "Week S6", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
BearS7SLevel = line.new(bar_index[bars_sinse], BearS7SValue, bar_index, BearS7SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_BearS7SLevel = label.new(end, BearS7SValue, "Week S7", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bear Situation 7
BearS7RLevel = line.new(bar_index[bars_sinse], BearS7RValue, bar_index, BearS7RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_BearS7RLevel = label.new(end, BearS7RValue, "Week S7", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
BearS8SLevel = line.new(bar_index[bars_sinse], BearS8SValue, bar_index, BearS8SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_BearS8SLevel = label.new(end, BearS8SValue, "Week S8", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bear Situation 8
BearS8RLevel = line.new(bar_index[bars_sinse], BearS8RValue, bar_index, BearS8RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_BearS8RLevel = label.new(end, BearS8RValue, "Week S8", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
BearS9SLevel = line.new(bar_index[bars_sinse], BearS9SValue, bar_index, BearS9SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_BearS9SLevel = label.new(end, BearS9SValue, "Week S9", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bear Situation 9
BearS9RLevel = line.new(bar_index[bars_sinse], BearS9RValue, bar_index, BearS9RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_BearS9RLevel = label.new(end, BearS9RValue, "Week S9", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
BearS10SLevel = line.new(bar_index[bars_sinse], BearS10SValue, bar_index, BearS10SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_BearS10SLevel = label.new(end, BearS10SValue, "Week S10", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//MONTH LEVELS
//Month Bull Rules
aboveYearPivotc = hclose > mpivot
belowYearPivotc = hclose < mpivot
aboveYearR1c = hclose > mr1
belowYearR1c = hclose < mr1
aboveYearR2c = hclose > mr2
belowYearR2c = hclose < mr2
aboveYearR4c = hclose > mr4
belowYearR4c = hclose < mr4
aboveYearR5c = hclose > mr5
belowYearR5c = hclose < mr5
aboveYearR6c = hclose > mr6
belowYearR6c = hclose < mr6
aboveYearR7c = hclose > mr7
belowYearR7c = hclose < mr7
aboveYearR8c = hclose > mr8
belowYearR8c = hclose < mr8
aboveYearR9c = hclose > mr9
belowYearR9c = hclose < mr9
aboveYearR10c = hclose > mr10
belowYearR10c = hclose < mr10
mcloseHigh1 = aboveYearPivotc and belowYearR1c
mcloseHigh2 = aboveYearR1c and belowYearR2c
mcloseHigh3 = aboveYearR2c and belowYearR4c
mcloseHigh4 = aboveYearR4c and belowYearR5c
mcloseHigh5 = aboveYearR5c and belowYearR6c
mcloseHigh6 = aboveYearR6c and belowYearR7c
mcloseHigh7 = aboveYearR7c and belowYearR8c
mcloseHigh8 = aboveYearR8c and belowYearR9c
mcloseHigh9 = aboveYearR9c and belowYearR10c
//Month Bear Rules
aboveYearPivotd = hclose > mpivot
belowYearPivotd = hclose < mpivot
aboveYearS1d = hclose > ms1
belowYearS1d = hclose < ms1
aboveYearS2d = hclose > ms2
belowYearS2d = hclose < ms2
aboveYearS4d = hclose > ms4
belowYearS4d = hclose < ms4
aboveYearS5d = hclose > ms5
belowYearS5d = hclose < ms5
aboveYearS6d = hclose > ms6
belowYearS6d = hclose < ms6
aboveYearS7d = hclose > ms7
belowYearS7d = hclose < ms7
aboveYearS8d = hclose > ms8
belowYearS8d = hclose < ms8
aboveYearS9d = hclose > ms9
belowYearS9d = hclose < ms9
aboveYearS10d = hclose > ms10
belowYearS10d = hclose < ms10
mcloseLow1 = belowYearPivotd and aboveYearS1d
mcloseLow2 = belowYearS1d and aboveYearS2d
mcloseLow3 = belowYearS2d and aboveYearS4d
mcloseLow4 = belowYearS4d and aboveYearS5d
mcloseLow5 = belowYearS5d and aboveYearS6d
mcloseLow6 = belowYearS6d and aboveYearS7d
mcloseLow7 = belowYearS7d and aboveYearS8d
mcloseLow8 = belowYearS8d and aboveYearS9d
mcloseLow9 = belowYearS9d and aboveYearS10d
//Year Bull S/R Levels
//Bull Situation 1
mBullR1Resistance = 0.0
mBullR1Resistance := mcloseHigh1 ? mr1 : na
mBullPivotSupport = 0.0
mBullPivotSupport := mcloseHigh1 ? mpivot : na
//Bull Situation 2
mBullR2Resistance = 0.0
mBullR2Resistance := mcloseHigh2 ? mr2 : na
mBullR1Support = 0.0
mBullR1Support := mcloseHigh2 ? mr1 : na
//Bull Situation 3
mBullR4Resistance = 0.0
mBullR4Resistance := mcloseHigh3 ? mr4 : na
mBullR2Support = 0.0
mBullR2Support := mcloseHigh3 ? mr2 : na
//Bull Situation 4
mBullR5Resistance = 0.0
mBullR5Resistance := mcloseHigh4 ? mr5 : na
mBullR4Support = 0.0
mBullR4Support := mcloseHigh4 ? mr4 : na
//Bull Situation 5
mBullR6Resistance = 0.0
mBullR6Resistance := mcloseHigh5 ? mr6 : na
mBullR5Support = 0.0
mBullR5Support := mcloseHigh5 ? mr5 : na
//Bull Situation 6
mBullR7Resistance = 0.0
mBullR7Resistance := mcloseHigh6 ? mr7 : na
mBullR6Support = 0.0
mBullR6Support := mcloseHigh6 ? mr6 : na
//Bull Situation 7
mBullR8Resistance = 0.0
mBullR8Resistance := mcloseHigh7 ? mr8 : na
mBullR7Support = 0.0
mBullR7Support := mcloseHigh7 ? mr7 : na
//Bull Situation 8
mBullR9Resistance = 0.0
mBullR9Resistance := mcloseHigh8 ? mr9 : na
mBullR8Support = 0.0
mBullR8Support := mcloseHigh8 ? mr8 : na
//Bull Situation 9
mBullR10Resistance = 0.0
mBullR10Resistance := mcloseHigh9 ? mr10 : na
mBullR9Support = 0.0
mBullR9Support := mcloseHigh9 ? mr9 : na
//Bull Values
//Bull Situation 1
mBullR1RValue = valuewhen(isToday and Month_SR, mBullR1Resistance, 0)
mBullPivotSValue = valuewhen(isToday and Month_SR, mBullPivotSupport, 0)
//Bull Situation 2
mBullR2RValue = valuewhen(isToday and Month_SR, mBullR2Resistance, 0)
mBullR1SValue = valuewhen(isToday and Month_SR, mBullR1Support, 0)
//Bull Situation 3
mBullR4RValue = valuewhen(isToday and Month_SR, mBullR4Resistance, 0)
mBullR2SValue = valuewhen(isToday and Month_SR, mBullR2Support, 0)
//Bull Situation 4
mBullR5RValue = valuewhen(isToday and Month_SR, mBullR5Resistance, 0)
mBullR4SValue = valuewhen(isToday and Month_SR, mBullR4Support, 0)
//Bull Situation 5
mBullR6RValue = valuewhen(isToday and Month_SR, mBullR6Resistance, 0)
mBullR5SValue = valuewhen(isToday and Month_SR, mBullR5Support, 0)
//Bull Situation 6
mBullR7RValue = valuewhen(isToday and Month_SR, mBullR7Resistance, 0)
mBullR6SValue = valuewhen(isToday and Month_SR, mBullR6Support, 0)
//Bull Situation 7
mBullR8RValue = valuewhen(isToday and Month_SR, mBullR8Resistance, 0)
mBullR7SValue = valuewhen(isToday and Month_SR, mBullR7Support, 0)
//Bull Situation 8
mBullR9RValue = valuewhen(isToday and Month_SR, mBullR9Resistance, 0)
mBullR8SValue = valuewhen(isToday and Month_SR, mBullR8Support, 0)
//Bull Situation 9
mBullR10RValue = valuewhen(isToday and Month_SR, mBullR10Resistance, 0)
mBullR9SValue = valuewhen(isToday and Month_SR, mBullR9Support, 0)
//Bull S/R Lines and Labels//
//Bull Situation 1
mBullR1RLevel = line.new(bar_index[bars_sinse], mBullR1RValue, bar_index, mBullR1RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_mBullR1RLevel = label.new(end, mBullR1RValue, "Month R1", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
mBullPivotSLevel = line.new(bar_index[bars_sinse], mBullPivotSValue, bar_index, mBullPivotSValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_mBullPivotSLevel = label.new(end, mBullPivotSValue, "Month Pivot", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bull Situation 2
mBullR2RLevel = line.new(bar_index[bars_sinse], mBullR2RValue, bar_index, mBullR2RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_mBullR2RLevel = label.new(end, mBullR2RValue, "Month R2", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
mBullR1SLevel = line.new(bar_index[bars_sinse], mBullR1SValue, bar_index, mBullR1SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_mBullR1SLevel = label.new(end, mBullR1SValue, "Month R1", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bull Situation 3
mBullR4RLevel = line.new(bar_index[bars_sinse], mBullR4RValue, bar_index, mBullR4RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_mBullR4RLevel = label.new(end, mBullR4RValue, "Month R4", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
mBullR2SLevel = line.new(bar_index[bars_sinse], mBullR2SValue, bar_index, mBullR2SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_mBullR2SLevel = label.new(end, mBullR2SValue, "Month R2", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bull Situation 4
mBullR5RLevel = line.new(bar_index[bars_sinse], mBullR5RValue, bar_index, mBullR5RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_mBullR5RLevel = label.new(end, mBullR5RValue, "Month R5", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
mBullR4SLevel = line.new(bar_index[bars_sinse], mBullR4SValue, bar_index, mBullR4SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_mBullR4SLevel = label.new(end, mBullR4SValue, "Month R4", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bull Situation 5
mBullR6RLevel = line.new(bar_index[bars_sinse], mBullR6RValue, bar_index, mBullR6RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_mBullR6RLevel = label.new(end, mBullR6RValue, "Month R6", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
mBullR5SLevel = line.new(bar_index[bars_sinse], mBullR5SValue, bar_index, mBullR5SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_mBullR5SLevel = label.new(end, mBullR5SValue, "Month R5", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bull Situation 6
mBullR7RLevel = line.new(bar_index[bars_sinse], mBullR7RValue, bar_index, mBullR7RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_mBullR7RLevel = label.new(end, mBullR7RValue, "Month R7", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
mBullR6SLevel = line.new(bar_index[bars_sinse], mBullR6SValue, bar_index, mBullR6SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_mBullR6SLevel = label.new(end, mBullR6SValue, "Month R6", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bull Situation 7
mBullR8RLevel = line.new(bar_index[bars_sinse], mBullR8RValue, bar_index, mBullR8RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_mBullR8RLevel = label.new(end, mBullR8RValue, "Month R8", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
mBullR17SLevel = line.new(bar_index[bars_sinse], mBullR7SValue, bar_index, mBullR7SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_mBullR7SLevel = label.new(end, mBullR7SValue, "Month R7", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bull Situation 8
mBullR9RLevel = line.new(bar_index[bars_sinse], mBullR9RValue, bar_index, mBullR9RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_mBullR9RLevel = label.new(end, mBullR9RValue, "Month R9", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
mBullR8SLevel = line.new(bar_index[bars_sinse], mBullR8SValue, bar_index, mBullR8SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_mBullR8SLevel = label.new(end, mBullR8SValue, "Month R8", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bull Situation 9
mBullR10RLevel = line.new(bar_index[bars_sinse], mBullR10RValue, bar_index, mBullR10RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_mBullR10RLevel = label.new(end, mBullR10RValue, "Month R10", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
mBullR9SLevel = line.new(bar_index[bars_sinse], mBullR9SValue, bar_index, mBullR9SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_mBullR9SLevel = label.new(end, mBullR9SValue, "Month R9", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Year Bear S/R Levels//
//Bear Situation 1
mBearPivotResistance = 0.0
mBearPivotResistance := mcloseLow1 ? mpivot : na
mBearS1Support = 0.0
mBearS1Support := mcloseLow1 ? ms1 : na
//Bear Situation 2
mBearS1Resistance = 0.0
mBearS1Resistance := mcloseLow2 ? ms1 : na
mBearS2Support = 0.0
mBearS2Support := mcloseLow2 ? ms2 : na
//Bear Situation 3
mBearS2Resistance = 0.0
mBearS2Resistance := mcloseLow3 ? ms2 : na
mBearS4Support = 0.0
mBearS4Support := mcloseLow3 ? ms4 : na
//Bear Situation 4
mBearS4Resistance = 0.0
mBearS4Resistance := mcloseLow4 ? ms4 : na
mBearS5Support = 0.0
mBearS5Support := mcloseLow4 ? ms5 : na
//Bear Situation 5
mBearS5Resistance = 0.0
mBearS5Resistance := mcloseLow5 ? ms5 : na
mBearS6Support = 0.0
mBearS6Support := mcloseLow5 ? ms6 : na
//Bear Situation 6
mBearS6Resistance = 0.0
mBearS6Resistance := mcloseLow6 ? ms6 : na
mBearS7Support = 0.0
mBearS7Support := mcloseLow6 ? ms7 : na
//Bear Situation 7
mBearS7Resistance = 0.0
mBearS7Resistance := mcloseLow7 ? ms7 : na
mBearS8Support = 0.0
mBearS8Support := mcloseLow7 ? ms8 : na
//Bear Situation 8
mBearS8Resistance = 0.0
mBearS8Resistance := mcloseLow8 ? ms8 : na
mBearS9Support = 0.0
mBearS9Support := mcloseLow8 ? ms9 : na
//Bear Situation 9
mBearS9Resistance = 0.0
mBearS9Resistance := mcloseLow9 ? ms9 : na
mBearS10Support = 0.0
mBearS10Support := mcloseLow9 ? ms10 : na
//Bear Values
//Bear Situation 1
mBearPivotRValue = valuewhen(isToday and Month_SR, mBearPivotResistance, 0)
mBearS1SValue = valuewhen(isToday and Month_SR, mBearS1Support, 0)
//Bear Situation 2
mBearS1RValue = valuewhen(isToday and Month_SR, mBearS1Resistance, 0)
mBearS2SValue = valuewhen(isToday and Month_SR, mBearS2Support, 0)
//Bear Situation 3
mBearS2RValue = valuewhen(isToday and Month_SR, mBearS2Resistance, 0)
mBearS4SValue = valuewhen(isToday and Month_SR, mBearS4Support, 0)
//Bear Situation 4
mBearS4RValue = valuewhen(isToday and Month_SR, mBearS4Resistance, 0)
mBearS5SValue = valuewhen(isToday and Month_SR, mBearS5Support, 0)
//Bear Situation 5
mBearS5RValue = valuewhen(isToday and Month_SR, mBearS5Resistance, 0)
mBearS6SValue = valuewhen(isToday and Month_SR, mBearS6Support, 0)
//Bear Situation 6
mBearS6RValue = valuewhen(isToday and Month_SR, mBearS6Resistance, 0)
mBearS7SValue = valuewhen(isToday and Month_SR, mBearS7Support, 0)
//Bear Situation 7
mBearS7RValue = valuewhen(isToday and Month_SR, mBearS7Resistance, 0)
mBearS8SValue = valuewhen(isToday and Month_SR, mBearS8Support, 0)
//Bear Situation 8
mBearS8RValue = valuewhen(isToday and Month_SR, mBearS8Resistance, 0)
mBearS9SValue = valuewhen(isToday and Month_SR, mBearS9Support, 0)
//Bear Situation 9
mBearS9RValue = valuewhen(isToday and Month_SR, mBearS9Resistance, 0)
mBearS10SValue = valuewhen(isToday and Month_SR, mBearS10Support, 0)
//Bear S/R Lines and Labels
//Bear Situation 1
mBearPivotRLevel = line.new(bar_index[bars_sinse], mBearPivotRValue, bar_index, mBearPivotRValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_mBearPivotRLevel = label.new(end, mBearPivotRValue, "Month Pivot", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
mBearS1SLevel = line.new(bar_index[bars_sinse], mBearS1SValue, bar_index, mBearS1SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_mBearS1SLevel = label.new(end, mBearS1SValue, "Month S1", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bear Situation 2
mBearS1RLevel = line.new(bar_index[bars_sinse], mBearS1RValue, bar_index, mBearS1RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_mBearS1RLevel = label.new(end, mBearS1RValue, "Month S1", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
mBearS2SLevel = line.new(bar_index[bars_sinse], mBearS2SValue, bar_index, mBearS2SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_mBearS2SLevel = label.new(end, mBearS2SValue, "Month S2", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bear Situation 3
mBearS2RLevel = line.new(bar_index[bars_sinse], mBearS2RValue, bar_index, mBearS2RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_mBearS2RLevel = label.new(end, mBearS2RValue, "Month S2", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
mBearS4SLevel = line.new(bar_index[bars_sinse], mBearS4SValue, bar_index, mBearS4SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_mBearS4SLevel = label.new(end, mBearS4SValue, "Month S4", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bear Situation 4
mBearS4RLevel = line.new(bar_index[bars_sinse], mBearS4RValue, bar_index, mBearS4RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_mBearS4RLevel = label.new(end, mBearS4RValue, "Month S4", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
mBearS5SLevel = line.new(bar_index[bars_sinse], mBearS5SValue, bar_index, mBearS5SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_mBearS5SLevel = label.new(end, mBearS5SValue, "Month S5", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bear Situation 5
mBearS5RLevel = line.new(bar_index[bars_sinse], mBearS5RValue, bar_index, mBearS5RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_mBearS5RLevel = label.new(end, mBearS5RValue, "Month S5", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
mBearS6SLevel = line.new(bar_index[bars_sinse], mBearS6SValue, bar_index, mBearS6SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_mBearS6SLevel = label.new(end, mBearS6SValue, "Month S6", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bear Situation 6
mBearS6RLevel = line.new(bar_index[bars_sinse], mBearS6RValue, bar_index, mBearS6RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_mBearS6RLevel = label.new(end, mBearS6RValue, "Month S6", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
mBearS7SLevel = line.new(bar_index[bars_sinse], mBearS7SValue, bar_index, mBearS7SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_mBearS7SLevel = label.new(end, mBearS7SValue, "Month S7", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bear Situation 7
mBearS7RLevel = line.new(bar_index[bars_sinse], mBearS7RValue, bar_index, mBearS7RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_mBearS7RLevel = label.new(end, mBearS7RValue, "Month S7", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
mBearS8SLevel = line.new(bar_index[bars_sinse], mBearS8SValue, bar_index, mBearS8SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_mBearS8SLevel = label.new(end, mBearS8SValue, "Month S8", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bear Situation 8
mBearS8RLevel = line.new(bar_index[bars_sinse], mBearS8RValue, bar_index, mBearS8RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_mBearS8RLevel = label.new(end, mBearS8RValue, "Month S8", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
mBearS9SLevel = line.new(bar_index[bars_sinse], mBearS9SValue, bar_index, mBearS9SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_mBearS9SLevel = label.new(end, mBearS9SValue, "Month S9", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bear Situation 9
mBearS9RLevel = line.new(bar_index[bars_sinse], mBearS9RValue, bar_index, mBearS9RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_mBearS9RLevel = label.new(end, mBearS9RValue, "Month S9", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
mBearS10SLevel = line.new(bar_index[bars_sinse], mBearS10SValue, bar_index, mBearS10SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_mBearS10SLevel = label.new(end, mBearS10SValue, "Month S10", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//YEAR LEVELS
//Year Bull Rules
aboveYearPivota = pclose > ypivot
belowYearPivota = pclose < ypivot
aboveYearR1a = pclose > yr1
belowYearR1a = pclose < yr1
aboveYearR2a = pclose > yr2
belowYearR2a = pclose < yr2
aboveYearR4a = pclose > yr4
belowYearR4a = pclose < yr4
aboveYearR5a = pclose > yr5
belowYearR5a = pclose < yr5
aboveYearR6a = pclose > yr6
belowYearR6a = pclose < yr6
aboveYearR7a = pclose > yr7
belowYearR7a = pclose < yr7
aboveYearR8a = pclose > yr8
belowYearR8a = pclose < yr8
aboveYearR9a = pclose > yr9
belowYearR9a = pclose < yr9
aboveYearR10a = pclose > yr10
belowYearR10a = pclose < yr10
ycloseHigh1 = aboveYearPivota and belowYearR1a
ycloseHigh2 = aboveYearR1a and belowYearR2a
ycloseHigh3 = aboveYearR2a and belowYearR4a
ycloseHigh4 = aboveYearR4a and belowYearR5a
ycloseHigh5 = aboveYearR5a and belowYearR6a
ycloseHigh6 = aboveYearR6a and belowYearR7a
ycloseHigh7 = aboveYearR7a and belowYearR8a
ycloseHigh8 = aboveYearR8a and belowYearR9a
ycloseHigh9 = aboveYearR9a and belowYearR10a
//Year Bear Rules
aboveYearPivotb = pclose > ypivot
belowYearPivotb = pclose < ypivot
aboveYearS1b = pclose > ys1
belowYearS1b = pclose < ys1
aboveYearS2b = pclose > ys2
belowYearS2b = pclose < ys2
aboveYearS4b = pclose > ys4
belowYearS4b = pclose < ys4
aboveYearS5b = pclose > ys5
belowYearS5b = pclose < ys5
aboveYearS6b = pclose > ys6
belowYearS6b = pclose < ys6
aboveYearS7b = pclose > ys7
belowYearS7b = pclose < ys7
aboveYearS8b = pclose > ys8
belowYearS8b = pclose < ys8
aboveYearS9b = pclose > ys9
belowYearS9b = pclose < ys9
aboveYearS10b = pclose > ys10
belowYearS10b = pclose < ys10
ycloseLow1 = belowYearPivotb and aboveYearS1b
ycloseLow2 = belowYearS1b and aboveYearS2b
ycloseLow3 = belowYearS2b and aboveYearS4b
ycloseLow4 = belowYearS4b and aboveYearS5b
ycloseLow5 = belowYearS5b and aboveYearS6b
ycloseLow6 = belowYearS6b and aboveYearS7b
ycloseLow7 = belowYearS7b and aboveYearS8b
ycloseLow8 = belowYearS8b and aboveYearS9b
ycloseLow9 = belowYearS9b and aboveYearS10b
//Year Bull S/R Levels
//Bull Situation 1
yBullR1Resistance = 0.0
yBullR1Resistance := ycloseHigh1 ? yr1 : na
yBullPivotSupport = 0.0
yBullPivotSupport := ycloseHigh1 ? ypivot : na
//Bull Situation 2
yBullR2Resistance = 0.0
yBullR2Resistance := ycloseHigh2 ? yr2 : na
yBullR1Support = 0.0
yBullR1Support := ycloseHigh2 ? yr1 : na
//Bull Situation 3
yBullR4Resistance = 0.0
yBullR4Resistance := ycloseHigh3 ? yr4 : na
yBullR2Support = 0.0
yBullR2Support := ycloseHigh3 ? yr2 : na
//Bull Situation 4
yBullR5Resistance = 0.0
yBullR5Resistance := ycloseHigh4 ? yr5 : na
yBullR4Support = 0.0
yBullR4Support := ycloseHigh4 ? yr4 : na
//Bull Situation 5
yBullR6Resistance = 0.0
yBullR6Resistance := ycloseHigh5 ? yr6 : na
yBullR5Support = 0.0
yBullR5Support := ycloseHigh5 ? yr5 : na
//Bull Situation 6
yBullR7Resistance = 0.0
yBullR7Resistance := ycloseHigh6 ? yr7 : na
yBullR6Support = 0.0
yBullR6Support := ycloseHigh6 ? yr6 : na
//Bull Situation 7
yBullR8Resistance = 0.0
yBullR8Resistance := ycloseHigh7 ? yr8 : na
yBullR7Support = 0.0
yBullR7Support := ycloseHigh7 ? yr7 : na
//Bull Situation 8
yBullR9Resistance = 0.0
yBullR9Resistance := ycloseHigh8 ? yr9 : na
yBullR8Support = 0.0
yBullR8Support := ycloseHigh8 ? yr8 : na
//Bull Situation 9
yBullR10Resistance = 0.0
yBullR10Resistance := ycloseHigh9 ? yr10 : na
yBullR9Support = 0.0
yBullR9Support := ycloseHigh9 ? yr9 : na
//Bull Values
//Bull Situation 1
yBullR1RValue = valuewhen(isToday and Year_SR, yBullR1Resistance, 0)
yBullPivotSValue = valuewhen(isToday and Year_SR, yBullPivotSupport, 0)
//Bull Situation 2
yBullR2RValue = valuewhen(isToday and Year_SR, yBullR2Resistance, 0)
yBullR1SValue = valuewhen(isToday and Year_SR, yBullR1Support, 0)
//Bull Situation 3
yBullR4RValue = valuewhen(isToday and Year_SR, yBullR4Resistance, 0)
yBullR2SValue = valuewhen(isToday and Year_SR, yBullR2Support, 0)
//Bull Situation 4
yBullR5RValue = valuewhen(isToday and Year_SR, yBullR5Resistance, 0)
yBullR4SValue = valuewhen(isToday and Year_SR, yBullR4Support, 0)
//Bull Situation 5
yBullR6RValue = valuewhen(isToday and Year_SR, yBullR6Resistance, 0)
yBullR5SValue = valuewhen(isToday and Year_SR, yBullR5Support, 0)
//Bull Situation 6
yBullR7RValue = valuewhen(isToday and Year_SR, yBullR7Resistance, 0)
yBullR6SValue = valuewhen(isToday and Year_SR, yBullR6Support, 0)
//Bull Situation 7
yBullR8RValue = valuewhen(isToday and Year_SR, yBullR8Resistance, 0)
yBullR7SValue = valuewhen(isToday and Year_SR, yBullR7Support, 0)
//Bull Situation 8
yBullR9RValue = valuewhen(isToday and Year_SR, yBullR9Resistance, 0)
yBullR8SValue = valuewhen(isToday and Year_SR, yBullR8Support, 0)
//Bull Situation 9
yBullR10RValue = valuewhen(isToday and Year_SR, yBullR10Resistance, 0)
yBullR9SValue = valuewhen(isToday and Year_SR, yBullR9Support, 0)
//Bull S/R Lines and Labels//
//Bull Situation 1
yBullR1RLevel = line.new(bar_index[bars_sinse], yBullR1RValue, bar_index, yBullR1RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_yBullR1RLevel = label.new(end, yBullR1RValue, "Year R1", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
yBullPivotSLevel = line.new(bar_index[bars_sinse], yBullPivotSValue, bar_index, yBullPivotSValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_yBullPivotSLevel = label.new(end, yBullPivotSValue, "Year Pivot", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bull Situation 2
yBullR2RLevel = line.new(bar_index[bars_sinse], yBullR2RValue, bar_index, yBullR2RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_yBullR2RLevel = label.new(end, yBullR2RValue, "Year R2", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
yBullR1SLevel = line.new(bar_index[bars_sinse], yBullR1SValue, bar_index, yBullR1SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_yBullR1SLevel = label.new(end, yBullR1SValue, "Year R1", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bull Situation 3
yBullR4RLevel = line.new(bar_index[bars_sinse], yBullR4RValue, bar_index, yBullR4RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_yBullR4RLevel = label.new(end, yBullR4RValue, "Year R4", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
yBullR2SLevel = line.new(bar_index[bars_sinse], yBullR2SValue, bar_index, yBullR2SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_yBullR2SLevel = label.new(end, yBullR2SValue, "Year R2", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bull Situation 4
yBullR5RLevel = line.new(bar_index[bars_sinse], yBullR5RValue, bar_index, yBullR5RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_yBullR5RLevel = label.new(end, yBullR5RValue, "Year R5", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
yBullR4SLevel = line.new(bar_index[bars_sinse], yBullR4SValue, bar_index, yBullR4SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_yBullR4SLevel = label.new(end, yBullR4SValue, "Year R4", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bull Situation 5
yBullR6RLevel = line.new(bar_index[bars_sinse], yBullR6RValue, bar_index, yBullR6RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_yBullR6RLevel = label.new(end, yBullR6RValue, "Year R6", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
yBullR5SLevel = line.new(bar_index[bars_sinse], yBullR5SValue, bar_index, yBullR5SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_yBullR5SLevel = label.new(end, yBullR5SValue, "Year R5", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bull Situation 6
yBullR7RLevel = line.new(bar_index[bars_sinse], yBullR7RValue, bar_index, yBullR7RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_yBullR7RLevel = label.new(end, yBullR7RValue, "Year R7", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
yBullR6SLevel = line.new(bar_index[bars_sinse], yBullR6SValue, bar_index, yBullR6SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_yBullR6SLevel = label.new(end, yBullR6SValue, "Year R6", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bull Situation 7
yBullR8RLevel = line.new(bar_index[bars_sinse], yBullR8RValue, bar_index, yBullR8RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_yBullR8RLevel = label.new(end, yBullR8RValue, "Year R8", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
yBullR17SLevel = line.new(bar_index[bars_sinse], yBullR7SValue, bar_index, yBullR7SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_yBullR7SLevel = label.new(end, yBullR7SValue, "Year R7", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bull Situation 8
yBullR9RLevel = line.new(bar_index[bars_sinse], yBullR9RValue, bar_index, yBullR9RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_yBullR9RLevel = label.new(end, yBullR9RValue, "Year R9", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
yBullR8SLevel = line.new(bar_index[bars_sinse], yBullR8SValue, bar_index, yBullR8SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_yBullR8SLevel = label.new(end, yBullR8SValue, "Year R8", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bull Situation 9
yBullR10RLevel = line.new(bar_index[bars_sinse], yBullR10RValue, bar_index, yBullR10RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_yBullR10RLevel = label.new(end, yBullR10RValue, "Year R10", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
yBullR9SLevel = line.new(bar_index[bars_sinse], yBullR9SValue, bar_index, yBullR9SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_yBullR9SLevel = label.new(end, yBullR9SValue, "Year R9", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Year Bear S/R Levels//
//Bear Situation 1
yBearPivotResistance = 0.0
yBearPivotResistance := ycloseLow1 ? ypivot : na
yBearS1Support = 0.0
yBearS1Support := ycloseLow1 ? ys1 : na
//Bear Situation 2
yBearS1Resistance = 0.0
yBearS1Resistance := ycloseLow2 ? ys1 : na
yBearS2Support = 0.0
yBearS2Support := ycloseLow2 ? ys2 : na
//Bear Situation 3
yBearS2Resistance = 0.0
yBearS2Resistance := ycloseLow3 ? ys2 : na
yBearS4Support = 0.0
yBearS4Support := ycloseLow3 ? ys4 : na
//Bear Situation 4
yBearS4Resistance = 0.0
yBearS4Resistance := ycloseLow4 ? ys4 : na
yBearS5Support = 0.0
yBearS5Support := ycloseLow4 ? ys5 : na
//Bear Situation 5
yBearS5Resistance = 0.0
yBearS5Resistance := ycloseLow5 ? ys5 : na
yBearS6Support = 0.0
yBearS6Support := ycloseLow5 ? ys6 : na
//Bear Situation 6
yBearS6Resistance = 0.0
yBearS6Resistance := ycloseLow6 ? ys6 : na
yBearS7Support = 0.0
yBearS7Support := ycloseLow6 ? ys7 : na
//Bear Situation 7
yBearS7Resistance = 0.0
yBearS7Resistance := ycloseLow7 ? ys7 : na
yBearS8Support = 0.0
yBearS8Support := ycloseLow7 ? ys8 : na
//Bear Situation 8
yBearS8Resistance = 0.0
yBearS8Resistance := ycloseLow8 ? ys8 : na
yBearS9Support = 0.0
yBearS9Support := ycloseLow8 ? ys9 : na
//Bear Situation 9
yBearS9Resistance = 0.0
yBearS9Resistance := ycloseLow9 ? ys9 : na
yBearS10Support = 0.0
yBearS10Support := ycloseLow9 ? ys10 : na
//Bear Values
//Bear Situation 1
yBearPivotRValue = valuewhen(isToday and Year_SR, yBearPivotResistance, 0)
yBearS1SValue = valuewhen(isToday and Year_SR, yBearS1Support, 0)
//Bear Situation 2
yBearS1RValue = valuewhen(isToday and Year_SR, yBearS1Resistance, 0)
yBearS2SValue = valuewhen(isToday and Year_SR, yBearS2Support, 0)
//Bear Situation 3
yBearS2RValue = valuewhen(isToday and Year_SR, yBearS2Resistance, 0)
yBearS4SValue = valuewhen(isToday and Year_SR, yBearS4Support, 0)
//Bear Situation 4
yBearS4RValue = valuewhen(isToday and Year_SR, yBearS4Resistance, 0)
yBearS5SValue = valuewhen(isToday and Year_SR, yBearS5Support, 0)
//Bear Situation 5
yBearS5RValue = valuewhen(isToday and Year_SR, yBearS5Resistance, 0)
yBearS6SValue = valuewhen(isToday and Year_SR, yBearS6Support, 0)
//Bear Situation 6
yBearS6RValue = valuewhen(isToday and Year_SR, yBearS6Resistance, 0)
yBearS7SValue = valuewhen(isToday and Year_SR, yBearS7Support, 0)
//Bear Situation 7
yBearS7RValue = valuewhen(isToday and Year_SR, yBearS7Resistance, 0)
yBearS8SValue = valuewhen(isToday and Year_SR, yBearS8Support, 0)
//Bear Situation 8
yBearS8RValue = valuewhen(isToday and Year_SR, yBearS8Resistance, 0)
yBearS9SValue = valuewhen(isToday and Year_SR, yBearS9Support, 0)
//Bear Situation 9
yBearS9RValue = valuewhen(isToday and Year_SR, yBearS9Resistance, 0)
yBearS10SValue = valuewhen(isToday and Year_SR, yBearS10Support, 0)
//Bear S/R Lines and Labels
//Bear Situation 1
yBearPivotRLevel = line.new(bar_index[bars_sinse], yBearPivotRValue, bar_index, yBearPivotRValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_yBearPivotRLevel = label.new(end, yBearPivotRValue, "Year Pivot", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
yBearS1SLevel = line.new(bar_index[bars_sinse], yBearS1SValue, bar_index, yBearS1SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_yBearS1SLevel = label.new(end, yBearS1SValue, "Year S1", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bear Situation 2
yBearS1RLevel = line.new(bar_index[bars_sinse], yBearS1RValue, bar_index, yBearS1RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_yBearS1RLevel = label.new(end, yBearS1RValue, "Year S1", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
yBearS2SLevel = line.new(bar_index[bars_sinse], yBearS2SValue, bar_index, yBearS2SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_yBearS2SLevel = label.new(end, yBearS2SValue, "Year S2", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bear Situation 3
yBearS2RLevel = line.new(bar_index[bars_sinse], yBearS2RValue, bar_index, yBearS2RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_yBearS2RLevel = label.new(end, yBearS2RValue, "Year S2", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
yBearS4SLevel = line.new(bar_index[bars_sinse], yBearS4SValue, bar_index, yBearS4SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_yBearS4SLevel = label.new(end, yBearS4SValue, "Year S4", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bear Situation 4
yBearS4RLevel = line.new(bar_index[bars_sinse], yBearS4RValue, bar_index, yBearS4RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_yBearS4RLevel = label.new(end, yBearS4RValue, "Year S4", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
yBearS5SLevel = line.new(bar_index[bars_sinse], yBearS5SValue, bar_index, yBearS5SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_yBearS5SLevel = label.new(end, yBearS5SValue, "Year S5", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bear Situation 5
yBearS5RLevel = line.new(bar_index[bars_sinse], yBearS5RValue, bar_index, yBearS5RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_yBearS5RLevel = label.new(end, yBearS5RValue, "Year S5", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
yBearS6SLevel = line.new(bar_index[bars_sinse], yBearS6SValue, bar_index, yBearS6SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_yBearS6SLevel = label.new(end, yBearS6SValue, "Year S6", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bear Situation 6
yBearS6RLevel = line.new(bar_index[bars_sinse], yBearS6RValue, bar_index, yBearS6RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_yBearS6RLevel = label.new(end, yBearS6RValue, "Year S6", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
yBearS7SLevel = line.new(bar_index[bars_sinse], yBearS7SValue, bar_index, yBearS7SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_yBearS7SLevel = label.new(end, yBearS7SValue, "Year S7", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bear Situation 7
yBearS7RLevel = line.new(bar_index[bars_sinse], yBearS7RValue, bar_index, yBearS7RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_yBearS7RLevel = label.new(end, yBearS7RValue, "Year S7", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
yBearS8SLevel = line.new(bar_index[bars_sinse], yBearS8SValue, bar_index, yBearS8SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_yBearS8SLevel = label.new(end, yBearS8SValue, "Year S8", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bear Situation 8
yBearS8RLevel = line.new(bar_index[bars_sinse], yBearS8RValue, bar_index, yBearS8RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_yBearS8RLevel = label.new(end, yBearS8RValue, "Year S8", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
yBearS9SLevel = line.new(bar_index[bars_sinse], yBearS9SValue, bar_index, yBearS9SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_yBearS9SLevel = label.new(end, yBearS9SValue, "Year S9", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
//Bear Situation 9
yBearS9RLevel = line.new(bar_index[bars_sinse], yBearS9RValue, bar_index, yBearS9RValue, extend = extend.both, color = red, style = line.style_solid, width = 2)
label_yBearS9RLevel = label.new(end, yBearS9RValue, "Year S9", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)
yBearS10SLevel = line.new(bar_index[bars_sinse], yBearS10SValue, bar_index, yBearS10SValue, extend = extend.both, color = green, style = line.style_solid, width = 2)
label_yBearS10SLevel = label.new(end, yBearS10SValue, "Year S10", xloc = xloc.bar_time, yloc=yloc.price, style = label.style_none, textcolor = color.white, size = size.normal, textalign = text.align_right)