There are many ways to code for what you are looking for. Drawing clues from what has already been discussed in this KB Article and from what other Seniors have shared in their previous posts below is one way to code.
_SECTION_BEGIN( "CPR" );
dtDayStartComp = TimeFrameCompress( DateTime(), inDaily, compressOpen );
dtDayStartExp = TimeFrameExpand( dtDayStartComp, inDaily, expandFirst );
dtDayEndComp = TimeFrameCompress( DateTime(), inDaily, compressLast );
dtDayEndExp = TimeFrameExpand( dtDayEndComp, inDaily, expandFirst );
DayCond = DateTime() >= dtDayStartExp AND DateTime() < dtDayEndExp;
// Previous Days High Low Close
PDH = TimeFrameGetPrice( "H", inDaily, -1 );
PDL = TimeFrameGetPrice( "L", inDaily, -1 );
PDC = TimeFrameGetPrice( "C", inDaily, -1 );
PV = ( PDH + PDL + PDC ) / 3;
LB = ( PDH + PDL ) / 2;
UB = 2 * PV - LB;
Plot( IIf( DayCond, UB, Null ), "UB", colorAqua, styleLine, Null, Null, 0 );
Plot( IIf( DayCond, UB, Null ), "UB", colorAqua, styleLine, Null, Null, 2 );
Plot( IIf( DayCond, PV, Null), "Pivot", colorAqua, styleLine, Null, Null, 0 );
Plot( IIf( DayCond, PV, Null), "Pivot", colorAqua, styleLine, Null, Null, 2 );
Plot( IIf( DayCond, LB, Null), "LB", colorAqua, styleLine, Null, Null, 0 );
Plot( IIf( DayCond, LB, Null), "LB", colorAqua, styleLine, Null, Null, 2 );
_SECTION_END();
_SECTION_BEGIN( "Pivot Levels" );
//PDH = TimeFrameGetPrice( "H", inDaily, -1 );
//PDL = TimeFrameGetPrice( "L", inDaily, -1 );
//PDC = TimeFrameGetPrice( "C", inDaily, -1 );
//PV = ( PDH + PDL + PDC ) / 3;
R1 = 2 * PV - PDL;
R2 = PV + PDH - PDL;
S1 = 2 * PV - PDH;
S2 = PV - PDH + PDL;
Plot( IIf( DayCond, R1, Null ), "R1", colorRed, styleLine, Null, Null, 0 );
Plot( IIf( DayCond, R1, Null ), "R1", colorRed, styleLine, Null, Null, 2 );
Plot( IIf( DayCond, R2, Null ), "R2", colorOrange, styleLine, Null, Null, 0 );
Plot( IIf( DayCond, R2, Null ), "R2", colorOrange, styleLine, Null, Null, 2 );
Plot( IIf( DayCond, S1, Null ), "S1", colorGreen, styleLine, Null, Null, 0 );
Plot( IIf( DayCond, S1, Null ), "S1", colorGreen, styleLine, Null, Null, 2 );
Plot( IIf( DayCond, S2, Null ), "S2", colorLime, styleLine, Null, Null, 0 );
Plot( IIf( DayCond, S2, Null ), "S2", colorLime, styleLine, Null, Null, 2 );
_SECTION_END();
_SECTION_BEGIN( "Price1" );
SetChartOptions( 0, chartShowArrows | chartShowDates );
_N( Title = StrFormat( "{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );
Plot( C, "Close", ParamColor( "Color", colorDefault ), styleNoTitle | ParamStyle( "Style" ) | GetPriceStyle() );
_SECTION_END();
_SECTION_BEGIN( "To view Pivots of Next Day as Today closes" );
shift = 10; //Number of Bars to be shifted, could use a Param if needed
bi = BarIndex();
lvbi = LastValue( bi );
LAx0 = lvbi - shift + 1;
LAx1 = lvbi;
// Present Days High Low Close
// These levels will be dynamic as day progresses and would ahow up in the no bar region after the last visible Bar for shifted number of bars (i.e. 10 in this case)
// Do use "Bar Replay" to figure out what I mean
dH = TimeFrameGetPrice( "H", inDaily, 0 );
dL = TimeFrameGetPrice( "L", inDaily, 0 );
dC = TimeFrameGetPrice( "C", inDaily, 0 );
//Central Pivots shifted for Next Day
dPV = ( dH + dL + dC ) / 3;
LB = ( dH + dL ) / 2;
UB = 2 * dPV - LB;
y = LastValue( dPV );
la = LineArray( LAx0, y, LAx1, y );
Plot( la, "PV", colorAqua, styleLine, Null, Null, shift );
y = LastValue( LB );
la = LineArray( LAx0, y, LAx1, y );
Plot( la, "LB", colorAqua, styleLine, Null, Null, shift );
y = LastValue( UB );
la = LineArray( LAx0, y, LAx1, y );
Plot( la, "UB", colorAqua, styleLine, Null, Null, shift );
//Pivot Levels shifted for Next Day
R1 = 2 * dPV - dL;
R2 = dPV + dH - dL;
S1 = 2 * dPV - dH;
S2 = dPV - dH + dL;
y = LastValue( R1 );
la = LineArray( LAx0, y, LAx1, y );
Plot( la, "R1", colorRed, styleLine, Null, Null, shift );
y = LastValue( R2 );
la = LineArray( LAx0, y, LAx1, y );
Plot( la, "R2", colorOrange, styleLine, Null, Null, shift );
y = LastValue( S1 );
la = LineArray( LAx0, y, LAx1, y );
Plot( la, "S1", colorGreen, styleLine, Null, Null, shift );
y = LastValue( S2 );
la = LineArray( LAx0, y, LAx1, y );
Plot( la, "S2", colorLime, styleLine, Null, Null, shift );
_SECTION_END();