```
declare hide_on_daily;
input MktOpen = 0930; #hint MktOpen: Cash Marekt open EST.
input MktClose = 1600; #hint MktClose: Cash Market close EST.
def h = high;
def l = low;
def c = close;
def Active = if SecondsFromTime(MktOpen) >= 0 and
SecondsTillTime(MktClose) >= 0
then 1
else 0;
def Today = GetDay() == GetLastDay();
def Yesterday = GetDay() == GetLastDay()-1;
def ap = AggregationPeriod.Day;
def last = if Yesterday and !last[1]
then close(period = ap)[1]
else if Yesterday and
SecondsTillTime(MktClose) == 0 and
SecondsFromTime(MktClose) == 0
then if c <> last[1]
then c
else last[1]
else last[1];
def prevHigh = if Yesterday and !prevHigh[1]
then high(period = ap)[1]
else if Yesterday and Active and !Active[1]
then h
else if Yesterday and Active and h > prevHigh[1]
then h
else prevHigh[1];
def prevLow = if Yesterday and !prevLow[1]
then low(period = ap)[1]
else if Yesterday and Active and !Active[1]
then l
else if Yesterday and Active and l < prevLow[1]
then l
else prevLow[1];
def BubbleLocation = if Today and Active and !Active[1]
then c
else double.nan;
plot LastClose = if Today and Active then last else Double.NaN;
LastClose.SetStyle(curve.short_dash);
LastClose.SetDefaultColor(Color.WHITE);
#AddChartBubble(BubbleLocation, LastClose, "C", Color.Dark_Gray, no);
plot pivot = Round(((LastClose + prevHigh + prevLow) / 3) / TickSize(), 0) * TickSize();
#AddChartBubble(BubbleLocation, (pivot), "Pivot", Color.Dark_Gray, yes);
plot R1 = Round(((2 * pivot) - prevLow) / TickSize(), 0) * TickSize();
#AddChartBubble(BubbleLocation, HighestAll(R1), "R1", Color.Dark_Gray, no);
plot S1 = Round(((2 * pivot) - prevHigh) / TickSize(), 0) * TickSize();
#AddChartBubble(BubbleLocation, HighestAll(S1), "S1", Color.Dark_Gray, yes);
plot R2 = Round((pivot + (R1 - S1)) / TickSize(), 0) * TickSize();
#AddChartBubble(BubbleLocation, HighestAll(R2), "R2", Color.Dark_Gray, no);
plot S2 = Round((pivot - (R1 - S1)) / TickSize(), 0) * TickSize();
#AddChartBubble(BubbleLocation, HighestAll(S2), "S2", Color.Dark_Gray, yes);
plot R3 = Round((prevHigh + (2 * (pivot - prevLow))) / TickSize(), 0) * TickSize();
#AddChartBubble(BubbleLocation, HighestAll(R3), "R3", Color.Dark_Gray, no);
plot S3 = Round((prevLow - (2 * (prevHigh - pivot))) / TickSize(), 0) * TickSize();
#AddChartBubble(BubbleLocation, HighestAll(S3), "S3", Color.Dark_Gray, yes);
plot R4 = Round((prevHigh + (3 * (pivot - prevLow))) / TickSize(), 0) * TickSize();
#AddChartBubble(BubbleLocation, HighestAll(R4), "R4", Color.Dark_Gray, no);
plot S4 = Round((prevLow - (3 * (prevHigh - pivot))) / TickSize(), 0) * TickSize();
#AddChartBubble(BubbleLocation, HighestAll(S4), "S4", Color.Dark_Gray, yes);
pivot.SetPaintingStrategy(PaintingStrategy.DASHES);
pivot.SetDefaultColor(Color.Dark_Orange);
pivot.SetLineWeight(1);
R1.SetPaintingStrategy(PaintingStrategy.DASHES);
R1.SetDefaultColor(Color.GREEN);
R1.SetLineWeight(1);
R2.SetPaintingStrategy(PaintingStrategy.DASHES);
R2.SetDefaultColor(Color.GREEN);
R2.SetLineWeight(1);
R3.SetPaintingStrategy(PaintingStrategy.DASHES);
R3.SetDefaultColor(Color.GREEN);
R3.SetLineWeight(1);
R4.SetPaintingStrategy(PaintingStrategy.DASHES);
R4.SetDefaultColor(Color.GREEN);
R4.SetLineWeight(1);
S1.SetPaintingStrategy(PaintingStrategy.DASHES);
S1.SetDefaultColor(Color.RED);
S1.SetLineWeight(1);
S2.SetPaintingStrategy(PaintingStrategy.DASHES);
S2.SetDefaultColor(Color.RED);
S2.SetLineWeight(1);
S3.SetPaintingStrategy(PaintingStrategy.DASHES);
S3.SetDefaultColor(Color.RED);
S3.SetLineWeight(1);
S4.SetPaintingStrategy(PaintingStrategy.DASHES);
S4.SetDefaultColor(Color.RED);
S4.SetLineWeight(1);
# End Code Shadow Trader Pivots
# Previous RTH_POC and Value Area Extended to Current Day
def bar = BarNumber();
def RTHBar1 = if SecondsFromTime(MktOpen) == 0 and
SecondsTillTime(MktOpen) == 0
then bar
else RTHBar1[1];
def RTHBarEnd = if SecondsFromTime(MktClose) == 0 and
SecondsTillTime(MktClose) == 0
then 1
else Double.NaN;
def cond = bar == RTHBar1; #Active != Active[1];
profile vol = VolumeProfile("startNewProfile" = cond, "onExpansion" = no, "numberOfProfiles" = 10, "pricePerRow" = PricePerRow.TICKSIZE, "value area percent" = 68.4);
def pc = if IsNaN(vol.GetPointOfControl())
then pc[1]
else vol.GetPointOfControl();
def hVA = if IsNaN(vol.GetHighestValueArea())
then hVA[1]
else vol.GetHighestValueArea();
def lVA = if IsNaN(vol.GetLowestValueArea())
then lVA[1]
else vol.GetLowestValueArea();
def hProfile = if IsNaN(vol.GetHighest())# and con
then hProfile[1]
else vol.GetHighest();
def lProfile = if IsNaN(vol.GetLowest())# and con
then lProfile[1]
else vol.GetLowest();
def POC = if Active then pc else Double.NaN;
def VAHigh = if Active then hVA else Double.NaN;
def VALow = if Active then lVA else Double.NaN;
def PrevPC = if !IsNaN(RTHBarEnd)
then POC[1]
else PrevPC[1];
def PrevPCBar = if !IsNaN(RTHBarEnd)
then bar
else PrevPCBar[1];
def PrevPC_Limit = if bar == PrevPCBar
then Double.NaN
else if bar > PrevPCBar
then bar - PrevPCBar
else PrevPC_Limit[1];
def PrevVAH = if !IsNaN(RTHBarEnd)
then VAHigh[1]
else PrevVAH[1];
def PrevVAHBar = if !IsNaN(RTHBarEnd)
then bar
else PrevVAHBar[1];
def PrevVAH_Limit = if bar == PrevVAHBar
then Double.NaN
else if bar > PrevVAHBar
then bar - PrevVAHBar
else PrevVAH_Limit[1];
def PrevVAL = if !IsNaN(RTHBarEnd)
then VALow[1]
else PrevVAL[1];
def PrevVALBar = if !IsNaN(RTHBarEnd)
then bar
else PrevVALBar[1];
def PrevVAL_Limit = if bar == PrevVALBar
then Double.NaN
else if bar > PrevVALBar
then bar - PrevVALBar
else PrevVAL_Limit[1];
script LinePlot {
input LineLimit = 0;
input OnExpansion = yes;
input data = close;
input bar = 0;
def ThisBar = HighestAll(bar);
def cLine = if bar == ThisBar
then data
else Double.NaN;
def cond1 = CompoundValue(1, if IsNaN(data)
then cond1[1]
else data, data);
plot P = if ThisBar - LineLimit <= bar
then HighestAll(cLine)
else Double.NaN;
plot ExpLine = if OnExpansion and
IsNaN(data[-1])
then cond1
else Double.NaN;
}
plot PrevPOC = LinePlot(data = PrevPC, LineLimit = PrevPC_Limit, OnExpansion = no, bar = PrevPCBar).P;
PrevPOC.SetDefaultColor(Color.RED);
PrevPOC.SetDefaultColor(Color.RED);
plot PrevVAHline = LinePlot(data = PrevVAH, LineLimit = PrevVAH_Limit, OnExpansion = no, bar = PrevVAHBar).P;
PrevVAHline.SetDefaultColor(Color.RED);
PrevVAHline.SetDefaultColor(Color.RED);
plot PrevVALline = LinePlot(data = PrevVAL, LineLimit = PrevVAL_Limit, OnExpansion = no, bar = PrevVALBar).P;
PrevVALline.SetDefaultColor(Color.RED);
PrevVALline.SetDefaultColor(Color.RED);
addCloud(PrevVALline, PrevVAHline, color.dark_Gray, Color.dark_Gray);
input bubbles = yes;
def n = 2;
def n1 = n + 1;
AddChartBubble(bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), PrevVAH[n1], "VAH", color = Color.YELLOW, yes);
AddChartBubble(bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), PrevVAL[n1], "VAL", Color.YELLOW, no);
AddChartBubble(bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), PrevPOC[n1], "POC", Color.RED, no);
# End POC and Value Area
```