//@version=5
indicator('CPR - VSD_TamizhTrader', shorttitle='CPR by VSD', overlay=true)
getSeries(e, timeFrame) =>
request.security(syminfo.tickerid, timeFrame, e,
lookahead=barmerge.lookahead_on)
//Previous day datas
PrevDayClose = getSeries(close[1], 'D')
PrevDayOpen = getSeries(open[1], 'D')
PrevDayHigh = getSeries(high[1], 'D')
PrevDayLow = getSeries(low[1], 'D')
sw = input(true, title="Show Weekly Pivots?")
//Day CPR levels
DayPivotLevel = (PrevDayHigh + PrevDayLow + PrevDayClose) / 3
DayBCPRlevel = (PrevDayHigh + PrevDayLow) / 2
DayTCPRlevel = DayPivotLevel - DayBCPRlevel + DayPivotLevel
DayR1level = 2 * DayPivotLevel - PrevDayLow
DayS1level = 2 * DayPivotLevel - PrevDayHigh
DayR2level = DayPivotLevel + PrevDayHigh - PrevDayLow
DayS2level = DayPivotLevel - (PrevDayHigh - PrevDayLow)
DayR3level = PrevDayHigh + 2 * (DayPivotLevel - PrevDayLow)
DayS3level = PrevDayLow - 2 * (PrevDayHigh - DayPivotLevel)
DayR4level = DayR3level + DayR2level - DayR1level
DayS4level = DayS3level - (DayS1level - DayS2level)
//UX Input Arguments
DayPP = #673ab7
DayBC = #2196f3
DayTC = #2196f3
DayR1 = #ff0303
DayS1 = #ff0303
DayR2 = #ff0303
DayS2 = #ff0303
DayR3 = #ff0303
DayS3 = #ff0303
DayR4 = #ff0303
DayS4 = #ff0303
PrevDHigh = #363a45
PrevDLow = #363a45
//PrevDClose = color.gray
myWidthMainLevels = input.int(title='Line width for pivots', defval=2, minval=1)
DayPivot = input(true, title='Show Daily Pivot')
DaySR = input(true, title='Show Daily Support/Resistance')
DayCPR = input(true, title='Show Daily CPR Range')
PrevDayH = input(true, title='Show Previous Day High')
PrevDayL = input(true, title='Show Previous Day Low')
//PrevDayCL = input(true, title="Show Previous Day Close")
plot(DayPivot and DayPivotLevel and timeframe.isintraday ? DayPivotLevel : na,
title='DayPP', color=color.new(DayPP, 0), linewidth=myWidthMainLevels,
style=plot.style_circles, offset=0)
plot(DayCPR and DayBCPRlevel and timeframe.isintraday ? DayBCPRlevel : na,
title='DayBC', color=color.new(DayBC, 0), linewidth=myWidthMainLevels,
style=plot.style_circles, offset=0)
plot(DayCPR and DayTCPRlevel and timeframe.isintraday ? DayTCPRlevel : na,
title='DayTC', color=color.new(DayTC, 0), linewidth=myWidthMainLevels,
style=plot.style_circles, offset=0)
plot(DaySR and DayR1level and timeframe.isintraday ? DayR1level : na,
title='DayR1', color=color.new(DayR1, 0), linewidth=myWidthMainLevels,
style=plot.style_circles, offset=0)
plot(DaySR and DayS1level and timeframe.isintraday ? DayS1level : na,
title='DayS1', color=color.new(DayS1, 0), linewidth=myWidthMainLevels,
style=plot.style_circles, offset=0)
plot(DaySR and DayR2level and timeframe.isintraday ? DayR2level : na,
title='DayR2', color=color.new(DayR2, 0), linewidth=myWidthMainLevels,
style=plot.style_circles, offset=0)
plot(DaySR and DayS2level and timeframe.isintraday ? DayS2level : na,
title='DayS2', color=color.new(DayS2, 0), linewidth=myWidthMainLevels,
style=plot.style_circles, offset=0)
plot(DaySR and DayR3level and timeframe.isintraday ? DayR3level : na,
title='DayR3', color=color.new(DayR3, 0), linewidth=myWidthMainLevels,
style=plot.style_circles, offset=0)
plot(DaySR and DayS3level and timeframe.isintraday ? DayS3level : na,
title='DayS3', color=color.new(DayS3, 0), linewidth=myWidthMainLevels,
style=plot.style_circles, offset=0)
plot(DaySR and DayR4level and timeframe.isintraday ? DayR4level : na,
title='DayR4', color=color.new(DayR4, 0), linewidth=myWidthMainLevels,
style=plot.style_circles, offset=0)
plot(DaySR and DayS4level and timeframe.isintraday ? DayS4level : na,
title='DayS4', color=color.new(DayS4, 0), linewidth=myWidthMainLevels,
style=plot.style_circles, offset=0)
plot(PrevDayH and PrevDayHigh and timeframe.isintraday ? PrevDayHigh : na,
title='PrevDayHigh', color=color.new(PrevDHigh, 0), linewidth=myWidthMainLevels,
style=plot.style_circles, offset=0)
plot(PrevDayL and PrevDayLow and timeframe.isintraday ? PrevDayLow : na,
title='PrevDayLow', color=color.new(PrevDLow, 0), linewidth=myWidthMainLevels,
style=plot.style_circles, offset=0)
//plot(PrevDayCL and PrevDayClose and timeframe.isintraday ? PrevDayClose : na,
title="PrevDayClose", color=PrevDClose, linewidth=myWidthMainLevels,
style=plot.style_circles, offset=0, transp=0)
//Previous Week datas
PrevWeekClose = getSeries(close[1], 'W')
PrevWeekOpen = getSeries(open[1], 'W')
PrevWeekHigh = getSeries(high[1], 'W')
PrevWeekLow = getSeries(low[1], 'W')
NextWeekClose = getSeries(close[0], 'W')
NextWeekOpen = getSeries(open[0], 'W')
NextWeekHigh = getSeries(high[0], 'W')
NextWeekLow = getSeries(low[0], 'W')
//Week CPR levels
WeekPivotLevel = (PrevWeekHigh + PrevWeekLow + PrevWeekClose) / 3
WeekBCPRlevel = (PrevWeekHigh + PrevWeekLow) / 2
WeekTCPRlevel = WeekPivotLevel - WeekBCPRlevel + WeekPivotLevel
//Next Week CPR levels
NextWeekPivotLevel = (NextWeekHigh + NextWeekLow + NextWeekClose) / 3
NextWeekBCPRlevel = (NextWeekHigh + NextWeekLow) / 2
NextWeekTCPRlevel = NextWeekPivotLevel - NextWeekBCPRlevel + NextWeekPivotLevel
WeekR1level = 2 * WeekPivotLevel - PrevWeekLow
WeekS1level = 2 * WeekPivotLevel - PrevWeekHigh
WeekR2level = WeekPivotLevel + PrevWeekHigh - PrevWeekLow
WeekS2level = WeekPivotLevel - (PrevWeekHigh - PrevWeekLow)
WeekR3level = PrevWeekHigh + 2 * (WeekPivotLevel - PrevWeekLow)
WeekS3level = PrevWeekLow - 2 * (PrevWeekHigh - WeekPivotLevel)
WeekR4level = WeekR3level + WeekR2level - WeekR1level
WeekS4level = WeekS3level - (WeekS1level - WeekS2level)
//UX Input Arguments
WeekPP = #e91e63
WeekBC = #9c27b0
WeekTC = #9c27b0
WeekR1 = #4caf50
WeekS1 = #4caf50
WeekR2 = #4caf50
WeekS2 = #4caf50
WeekR3 = #4caf50
WeekS3 = #4caf50
WeekR4 = #4caf50
WeekS4 = #4caf50
PrevWHigh = #363a45
PrevWLow = #363a45
WeekPivot = input(true, title='Show Weekly Pivot')
NextWeekPivot = input(true, title='Show Next Weekly Pivot')
WeekSR = input(true, title='Show Weekly Support/Resistance')
WeekCPR = input(false, title='Show Weekly CPR Range')
NextWeekCPR = input(false, title='Show Next Weekly CPR Range')
PrevWeekH = input(true, title='Show Previous Week High')
PrevWeekL = input(true, title='Show Previous Week Low')
plot(WeekPivot and WeekPivotLevel and (timeframe.isintraday or timeframe.isdaily) ?
WeekPivotLevel : na, title='WeekPP', color=color.new(WeekPP, 0),
linewidth=myWidthMainLevels, style=plot.style_circles, offset=0)
plot(WeekCPR and WeekBCPRlevel and (timeframe.isintraday or timeframe.isdaily) ?
WeekBCPRlevel : na, title='WeekBC', color=color.new(WeekBC, 0),
linewidth=myWidthMainLevels, style=plot.style_circles, offset=0)
plot(WeekCPR and WeekTCPRlevel and (timeframe.isintraday or timeframe.isdaily) ?
WeekTCPRlevel : na, title='WeekTC', color=color.new(WeekTC, 0),
linewidth=myWidthMainLevels, style=plot.style_circles, offset=0)
plot(NextWeekPivot and NextWeekPivotLevel and (timeframe.isintraday or
timeframe.isdaily) ? NextWeekPivotLevel : na, title='WeekPP',
color=color.new(WeekPP, 0), linewidth=myWidthMainLevels, style=plot.style_circles,
offset=0)
plot(NextWeekCPR and NextWeekBCPRlevel and (timeframe.isintraday or
timeframe.isdaily) ? NextWeekBCPRlevel : na, title='WeekBC',
color=color.new(WeekBC, 0), linewidth=myWidthMainLevels, style=plot.style_circles,
offset=0)
plot(NextWeekCPR and NextWeekTCPRlevel and (timeframe.isintraday or
timeframe.isdaily) ? NextWeekTCPRlevel : na, title='WeekTC',
color=color.new(WeekTC, 0), linewidth=myWidthMainLevels, style=plot.style_circles,
offset=0)
//plot(WeekSR and WeekR1level and (timeframe.isintraday or timeframe.isdaily) ?
WeekR1level : na, title='WeekR1', color=color.new(WeekR1, 0),
linewidth=myWidthMainLevels, style=plot.style_circles, offset=0)
//plot(WeekSR and WeekS1level and (timeframe.isintraday or timeframe.isdaily) ?
WeekS1level : na, title='WeekS1', color=color.new(WeekS1, 0),
linewidth=myWidthMainLevels, style=plot.style_circles, offset=0)
//plot(WeekSR and WeekR2level and (timeframe.isintraday or timeframe.isdaily) ?
WeekR2level : na, title='WeekR2', color=color.new(WeekR2, 0),
linewidth=myWidthMainLevels, style=plot.style_circles, offset=0)
//plot(WeekSR and WeekS2level and (timeframe.isintraday or timeframe.isdaily) ?
WeekS2level : na, title='WeekS2', color=color.new(WeekS2, 0),
linewidth=myWidthMainLevels, style=plot.style_circles, offset=0)
plot(WeekSR and WeekR3level and (timeframe.isintraday or timeframe.isdaily) ?
WeekR3level : na, title='WeekR3', color=color.new(WeekR3, 0),
linewidth=myWidthMainLevels, style=plot.style_circles, offset=0)
plot(WeekSR and WeekS3level and (timeframe.isintraday or timeframe.isdaily) ?
WeekS3level : na, title='WeekS3', color=color.new(WeekS3, 0),
linewidth=myWidthMainLevels, style=plot.style_circles, offset=0)
plot(WeekSR and WeekR4level and (timeframe.isintraday or timeframe.isdaily) ?
WeekR4level : na, title='WeekR4', color=color.new(WeekR4, 0),
linewidth=myWidthMainLevels, style=plot.style_circles, offset=0)
plot(WeekSR and WeekS4level and (timeframe.isintraday or timeframe.isdaily) ?
WeekS4level : na, title='WeekS4', color=color.new(WeekS4, 0),
linewidth=myWidthMainLevels, style=plot.style_circles, offset=0)
plot(PrevWeekH and PrevWeekHigh and (timeframe.isintraday or timeframe.isdaily) ?
PrevWeekHigh : na, title='PrevWeekHigh', color=color.new(PrevWHigh, 40),
linewidth=myWidthMainLevels, style=plot.style_circles, offset=0)
plot(PrevWeekL and PrevWeekLow and (timeframe.isintraday or timeframe.isdaily) ?
PrevWeekLow : na, title='PrevWeekLow', color=color.new(PrevWLow, 40),
linewidth=myWidthMainLevels, style=plot.style_circles, offset=0)
//Previous Month datas
PrevMonthClose = getSeries(close[1], 'M')
PrevMonthOpen = getSeries(open[1], 'M')
PrevMonthHigh = getSeries(high[1], 'M')
PrevMonthLow = getSeries(low[1], 'M')
//Month CPR levels
MonthPivotLevel = (PrevMonthHigh + PrevMonthLow + PrevMonthClose) / 3
MonthBCPRlevel = (PrevMonthHigh + PrevMonthLow) / 2
MonthTCPRlevel = MonthPivotLevel - MonthBCPRlevel + MonthPivotLevel
MonthR1level = 2 * MonthPivotLevel - PrevMonthLow
MonthS1level = 2 * MonthPivotLevel - PrevMonthHigh
MonthR2level = MonthPivotLevel + PrevMonthHigh - PrevMonthLow
MonthS2level = MonthPivotLevel - (PrevMonthHigh - PrevMonthLow)
MonthR3level = PrevMonthHigh + 2 * (MonthPivotLevel - PrevMonthLow)
MonthS3level = PrevMonthLow - 2 * (PrevMonthHigh - MonthPivotLevel)
MonthR4level = MonthR3level + MonthR2level - MonthR1level
MonthS4level = MonthS3level - (MonthS1level - MonthS2level)
//UX Input Arguments
MonthPP = #ffeb3b
MonthBC = #ff9800
MonthTC = #ff9800
MonthR1 = #009688
MonthS1 = #009688
MonthR2 = #009688
MonthS2 = #009688
MonthR3 = #009688
MonthS3 = #009688
MonthR4 = #009688
MonthS4 = #009688
PrevMHigh = #363a45
PrevMLow = #363a45
MonthPivot = input(true, title='Show Monthly Pivot')
MonthSR = input(true, title='Show Monthly Support/Resistance')
MonthCPR = input(false, title='Show Monthly CPR Range')
PrevMonthH = input(true, title='Show Previous Month High')
PrevMonthL = input(true, title='Show Previous Month Low')
plot(MonthPivot and MonthPivotLevel and (timeframe.isintraday or timeframe.isdaily
or timeframe.isweekly) ? MonthPivotLevel : na, title='MonthPP',
color=color.new(MonthPP, 0), linewidth=myWidthMainLevels, style=plot.style_circles,
offset=0)
plot(MonthCPR and MonthBCPRlevel and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly) ? MonthBCPRlevel : na, title='MonthBC',
color=color.new(MonthBC, 0), linewidth=myWidthMainLevels, style=plot.style_circles,
offset=0)
plot(MonthCPR and MonthTCPRlevel and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly) ? MonthTCPRlevel : na, title='MonthTC',
color=color.new(MonthTC, 0), linewidth=myWidthMainLevels, style=plot.style_circles,
offset=0)
plot(MonthSR and MonthR1level and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly) ? MonthR1level : na, title='MonthR1', color=color.new(MonthR1,
0), linewidth=myWidthMainLevels, style=plot.style_circles, offset=0)
plot(MonthSR and MonthS1level and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly) ? MonthS1level : na, title='MonthS1', color=color.new(MonthS1,
0), linewidth=myWidthMainLevels, style=plot.style_circles, offset=0)
plot(MonthSR and MonthR2level and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly) ? MonthR2level : na, title='MonthR2', color=color.new(MonthR2,
0), linewidth=myWidthMainLevels, style=plot.style_circles, offset=0)
plot(MonthSR and MonthS2level and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly) ? MonthS2level : na, title='MonthS2', color=color.new(MonthS2,
0), linewidth=myWidthMainLevels, style=plot.style_circles, offset=0)
plot(MonthSR and MonthR3level and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly) ? MonthR3level : na, title='MonthR3', color=color.new(MonthR3,
0), linewidth=myWidthMainLevels, style=plot.style_circles, offset=0)
plot(MonthSR and MonthS3level and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly) ? MonthS3level : na, title='MonthS3', color=color.new(MonthS3,
0), linewidth=myWidthMainLevels, style=plot.style_circles, offset=0)
plot(MonthSR and MonthR4level and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly) ? MonthR4level : na, title='MonthR4', color=color.new(MonthR4,
0), linewidth=myWidthMainLevels, style=plot.style_circles, offset=0)
plot(MonthSR and MonthS4level and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly) ? MonthS4level : na, title='MonthS4', color=color.new(MonthS4,
0), linewidth=myWidthMainLevels, style=plot.style_circles)
plot(PrevMonthH and PrevMonthHigh and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly) ? PrevMonthHigh : na, title='PrevMonthHigh',
color=color.new(PrevMHigh, 40), linewidth=myWidthMainLevels,
style=plot.style_circles, offset=0)
plot(PrevMonthL and PrevMonthLow and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly) ? PrevMonthLow : na, title='PrevMonthLow',
color=color.new(PrevMLow, 40), linewidth=myWidthMainLevels,
style=plot.style_circles, offset=0)
//Previous Year datas
PrevYearClose = getSeries(close[1], '12M')
PrevYearOpen = getSeries(open[1], '12M')
PrevYearHigh = getSeries(high[1], '12M')
PrevYearLow = getSeries(low[1], '12M')
//Year CPR levels
YearPivotLevel = (PrevYearHigh + PrevYearLow + PrevYearClose) / 3
YearBCPRlevel = (PrevYearHigh + PrevYearLow) / 2
YearTCPRlevel = YearPivotLevel - YearBCPRlevel + YearPivotLevel
YearR1level = 2 * YearPivotLevel - PrevYearLow
YearS1level = 2 * YearPivotLevel - PrevYearHigh
YearR2level = YearPivotLevel + PrevYearHigh - PrevYearLow
YearS2level = YearPivotLevel - (PrevYearHigh - PrevYearLow)
YearR3level = PrevYearHigh + 2 * (YearPivotLevel - PrevYearLow)
YearS3level = PrevYearLow - 2 * (PrevYearHigh - YearPivotLevel)
YearR4level = YearR3level + YearR2level - YearR1level
YearS4level = YearS3level - (YearS1level - YearS2level)
//UX Input Arguments
YearPP = color.blue
YearBC = color.blue
YearTC = color.blue
YearR1 = color.green
YearS1 = color.red
YearR2 = color.green
YearS2 = color.red
YearR3 = color.green
YearS3 = color.red
YearR4 = color.green
YearS4 = color.red
PrevYHigh = color.black
PrevYLow = color.black
YearPivot = input(false, title='Show Yearly Pivot')
YearSR = input(false, title='Show Yearly Support/Resistance')
YearCPR = input(false, title='Show Yearly CPR Range')
PrevYearH = input(false, title='Show Previous Year High')
PrevYearL = input(false, title='Show Previous Year Low')
plot(YearPivot and YearPivotLevel and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly or timeframe.ismonthly) ? YearPivotLevel : na, title='YearPP',
color=color.new(YearPP, 0), linewidth=myWidthMainLevels, style=plot.style_circles,
offset=0)
plot(YearCPR and YearBCPRlevel and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly or timeframe.ismonthly) ? YearBCPRlevel : na, title='YearBC',
color=color.new(YearBC, 0), linewidth=myWidthMainLevels, style=plot.style_circles,
offset=0)
plot(YearCPR and YearTCPRlevel and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly or timeframe.ismonthly) ? YearTCPRlevel : na, title='YearTC',
color=color.new(YearTC, 0), linewidth=myWidthMainLevels, style=plot.style_circles,
offset=0)
plot(YearSR and YearR1level and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly or timeframe.ismonthly) ? YearR1level : na, title='YearR1',
color=color.new(YearR1, 0), linewidth=myWidthMainLevels, style=plot.style_circles,
offset=0)
plot(YearSR and YearS1level and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly or timeframe.ismonthly) ? YearS1level : na, title='YearS1',
color=color.new(YearS1, 0), linewidth=myWidthMainLevels, style=plot.style_circles,
offset=0)
plot(YearSR and YearR2level and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly or timeframe.ismonthly) ? YearR2level : na, title='YearR2',
color=color.new(YearR2, 0), linewidth=myWidthMainLevels, style=plot.style_circles,
offset=0)
plot(YearSR and YearS2level and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly or timeframe.ismonthly) ? YearS2level : na, title='YearS2',
color=color.new(YearS2, 0), linewidth=myWidthMainLevels, style=plot.style_circles,
offset=0)
plot(YearSR and YearR3level and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly or timeframe.ismonthly) ? YearR3level : na, title='YearR3',
color=color.new(YearR3, 0), linewidth=myWidthMainLevels, style=plot.style_circles,
offset=0)
plot(YearSR and YearS3level and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly or timeframe.ismonthly) ? YearS3level : na, title='YearS3',
color=color.new(YearS3, 0), linewidth=myWidthMainLevels, style=plot.style_circles,
offset=0)
plot(YearSR and YearR4level and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly or timeframe.ismonthly) ? YearR4level : na, title='YearR4',
color=color.new(YearR4, 0), linewidth=myWidthMainLevels, style=plot.style_circles,
offset=0)
plot(YearSR and YearS4level and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly or timeframe.ismonthly) ? YearS4level : na, title='YearS4',
color=color.new(YearS4, 0), linewidth=myWidthMainLevels, style=plot.style_circles,
offset=0)
plot(PrevYearH and PrevYearHigh and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly or timeframe.ismonthly) ? PrevYearHigh : na,
title='PrevYearHigh', color=color.new(PrevYHigh, 40), linewidth=myWidthMainLevels,
style=plot.style_circles, offset=0)
plot(PrevYearL and PrevYearLow and (timeframe.isintraday or timeframe.isdaily or
timeframe.isweekly or timeframe.ismonthly) ? PrevYearLow : na, title='PrevYearLow',
color=color.new(PrevYLow, 40), linewidth=myWidthMainLevels,
style=plot.style_circles, offset=0)
//Tomorrow's Pivot Calculation
tpr = input.string(title='Next CPR resolution', defval='D', options=['D', 'W', 'M',
'12M'])
tpopen = request.security(syminfo.tickerid, tpr, open, barmerge.gaps_off,
barmerge.lookahead_on)
tphigh = request.security(syminfo.tickerid, tpr, high, barmerge.gaps_off,
barmerge.lookahead_on)
tplow = request.security(syminfo.tickerid, tpr, low, barmerge.gaps_off,
barmerge.lookahead_on)
tpclose = request.security(syminfo.tickerid, tpr, close, barmerge.gaps_off,
barmerge.lookahead_on)
tppivot = (tphigh + tplow + tpclose) / 3.0
tpbc = (tphigh + tplow) / 2.0
tptc = tppivot - tpbc + tppivot
tpR1level = 2 * tppivot - tplow
tpS1level = 2 * tppivot - tphigh
tpR2level = tppivot + tphigh - tplow
tpS2level = tppivot - (tphigh - tplow)
tpR3level = tphigh + 2 * (tppivot - tplow)
tpS3level = tplow - 2 * (tphigh - tppivot)
tpR4level = tpR3level + tpR2level - tpR1level
tpS4level = tpS3level - (tpS1level - tpS2level)
//UX Input Arguments
tpPP = color.blue
tpBC = color.blue
tpTC = color.blue
tpR1 = color.green
tpS1 = color.red
tpR2 = color.green
tpS2 = color.red
tpR3 = color.green
tpS3 = color.red
tpR4 = color.green
tpS4 = color.red
tp = input(false, title='Show Next CPR')
tpSR = input(false, title='Show Next Support/Resistance')
myoffset = input(title='Next CPR offset', defval=75)
plot(tp and tppivot ? tppivot : na, title='NextPP', color=color.new(tpPP, 0),
linewidth=myWidthMainLevels, style=plot.style_circles, offset=myoffset)
plot(tp and tpbc ? tpbc : na, title='NextBC', color=color.new(tpBC, 0),
linewidth=myWidthMainLevels, style=plot.style_circles, offset=myoffset)
plot(tp and tptc ? tptc : na, title='NextTC', color=color.new(tpTC, 0),
linewidth=myWidthMainLevels, style=plot.style_circles, offset=myoffset)
plot(tpSR and tpR1level ? tpR1level : na, title='NextR1', color=color.new(tpR1, 0),
linewidth=myWidthMainLevels, style=plot.style_circles, offset=myoffset)
plot(tpSR and tpS1level ? tpS1level : na, title='NextS1', color=color.new(tpS1, 0),
linewidth=myWidthMainLevels, style=plot.style_circles, offset=myoffset)
plot(tpSR and tpR2level ? tpR2level : na, title='NextR2', color=color.new(tpR2, 0),
linewidth=myWidthMainLevels, style=plot.style_circles, offset=myoffset)
plot(tpSR and tpS2level ? tpS2level : na, title='NextS2', color=color.new(tpS2, 0),
linewidth=myWidthMainLevels, style=plot.style_circles, offset=myoffset)
plot(tpSR and tpR3level ? tpR3level : na, title='NextR3', color=color.new(tpR3, 0),
linewidth=myWidthMainLevels, style=plot.style_circles, offset=myoffset)
plot(tpSR and tpS3level ? tpS3level : na, title='NextS3', color=color.new(tpS3, 0),
linewidth=myWidthMainLevels, style=plot.style_circles, offset=myoffset)
plot(tpSR and tpR4level ? tpR4level : na, title='NextR4', color=color.new(tpR4, 0),
linewidth=myWidthMainLevels, style=plot.style_circles, offset=myoffset)
plot(tpSR and tpS4level ? tpS4level : na, title='NextS4', color=color.new(tpS4, 0),
linewidth=myWidthMainLevels, style=plot.style_circles, offset=myoffset)
sopenw = getSeries(open[0], "W")
shighw = getSeries(high[0], "W")
sloww = getSeries(low[10], "W")
sclosew = getSeries(close[0], "W")
h3 = close + (high - low) * 1.1 / 4.0
l3 = close - (high - low) * 1.1 / 4.0
wtime_h3 = getSeries(h3[0], 'W' )
wtime_l3 = getSeries(l3[0], 'W')
plot(sw and wtime_h3 ? wtime_h3 : na, title="Next Week H3",color=color.new(tpR3,
0), linewidth=2)
plot(sw and wtime_l3 ? wtime_l3 : na, title="Next Week L3",color=color.new(tpR3,
0), linewidth=2)