Hello, i have a question. I have zones in a chart and I want to fill them but when I do it fills them but connects them as well which I dont want to. Can anyone tell me how to use fill function properly on this please? This is my pine script:
study(CPR with MAs, Super Trend & VWAP by GuruprasadMeduri
, overlay = true, shorttitle=CPR
,precision=1)
//***************LOGICS***********************
//cenral pivot range
pivot = (high + low + close) /3 //Central Povit
BC = (high + low) / 2 //Below Central povit
TC = (pivot - BC) + pivot //Top Central povot
//3 support levels
S1 = (pivot * 2) - high
S2 = pivot - (high - low)
S3 = low - 2 * (high - pivot)
//3 resistance levels
R1 = (pivot * 2) - low
R2 = pivot + (high - low)
R3 = high + 2 * (pivot-low)
//Checkbox inputs
CPRPlot = input(title = Plot CPR?
, type=input.bool, defval=true)
DayS1R1 = input(title = Plot Daiy S1/R1?
, type=input.bool, defval=true)
DayS2R2 = input(title = Plot Daiy S2/R2?
, type=input.bool, defval=false)
DayS3R3 = input(title = Plot Daiy S3/R3?
, type=input.bool, defval=false)
WeeklyPivotInclude = input(title = Plot Weekly Pivot?
, type=input.bool, defval=false)
WeeklyS1R1 = input(title = Plot weekly S1/R1?
, type=input.bool, defval=false)
WeeklyS2R2 = input(title = Plot weekly S2/R2?
, type=input.bool, defval=false)
WeeklyS3R3 = input(title = Plot weekly S3/R3?
, type=input.bool, defval=false)
MonthlyPivotInclude = input(title = Plot Montly Pivot?
, type=input.bool, defval=false)
MonthlyS1R1 = input(title = Plot Monthly S1/R1?
, type=input.bool, defval=false)
MonthlyS2R2 = input(title = Plot Monthly S2/R2?
, type=input.bool, defval=false)
MonthlyS3R3 = input(title = Plot Montly S3/R3?
, type=input.bool, defval=false)
//***************DAYWISE CPR & PIVOTS***********************
// Getting daywise CPR
DayPivot = security(syminfo.tickerid, 240
, pivot[1], barmerge.gaps_off, barmerge.lookahead_on)
DayBC = security(syminfo.tickerid, 240
, BC[1], barmerge.gaps_off, barmerge.lookahead_on)
DayTC = security(syminfo.tickerid, 240
, TC[1], barmerge.gaps_off, barmerge.lookahead_on)
//Adding linebreaks daywse for CPR
CPColour = DayPivot != DayPivot[1] ? na : color.blue
BCColour = DayBC != DayBC[1] ? na : color.blue
TCColour = DayTC != DayTC[1] ? na : color.blue
//Plotting daywise CPR
plot(DayPivot, title = CP
, color = CPColour, style = plot.style_linebr, linewidth =2)
plot(CPRPlot ? DayBC : na , title = BC
, color = BCColour, style = plot.style_line, linewidth =1)
plot(CPRPlot ? DayTC : na , title = TC
, color = TCColour, style = plot.style_line, linewidth =1)
// Getting daywise Support levels
DayS1 = security(syminfo.tickerid, 240
, S1[1], barmerge.gaps_off, barmerge.lookahead_on)
DayS2 = security(syminfo.tickerid, 240
, S2[1], barmerge.gaps_off, barmerge.lookahead_on)
DayS3 = security(syminfo.tickerid, 240
, S3[1], barmerge.gaps_off, barmerge.lookahead_on)
//Adding linebreaks for daywise Support levels
DayS1Color =DayS1 != DayS1[1] ? na : color.green
DayS2Color =DayS2 != DayS2[1] ? na : color.green
DayS3Color =DayS3 != DayS3[1] ? na : color.green
//Plotting daywise Support levels
plot(DayS1R1 ? DayS1 : na, title = D-S1
, color = DayS1Color, style = plot.style_line, linewidth =1)
plot(DayS2R2 ? DayS2 : na, title = D-S2
, color = DayS2Color, style = plot.style_line, linewidth =1)
plot(DayS3R3 ? DayS3 : na, title = D-S3
, color = DayS3Color, style = plot.style_line, linewidth =1)
// Getting daywise Resistance levels
DayR1 = security(syminfo.tickerid, 240
, R1[1], barmerge.gaps_off, barmerge.lookahead_on)
DayR2 = security(syminfo.tickerid, 240
, R2[1], barmerge.gaps_off, barmerge.lookahead_on)
DayR3 = security(syminfo.tickerid, 240
, R3[1], barmerge.gaps_off, barmerge.lookahead_on)
//Adding linebreaks for daywise Support levels
DayR1Color =DayR1 != DayR1[1] ? na : color.red
DayR2Color =DayR2 != DayR2[1] ? na : color.red
DayR3Color =DayR3 != DayR3[1] ? na : color.red
//Plotting daywise Resistance levels
plot(DayS1R1 ? DayR1 : na, title = D-R1
, color = DayR1Color, style = plot.style_line, linewidth =1)
plot(DayS2R2 ? DayR2 : na, title = D-R2
, color = DayR2Color, style = plot.style_line, linewidth =1)
plot(DayS3R3 ? DayR3 : na, title = D-R3
, color = DayR3Color, style = plot.style_line, linewidth =1)
fill(plot1=plot(series=DayBC,show_last=1 , color=color.green),
plot2=plot(series=DayTC ,show_last=1, color=color.green),
color=color.green, transp=90)