#name: HalfGap_Open_PrevClose
input daysago = 1;
input marketOpenTime = 0930;
input marketCloseTime = 1559;
input period_day = AggregationPeriod.DAY;
input showtodayonly = no;
def begin = if IsNaN(close) then begin[1] else open(period = period_day);
##############
def Today = if GetDay() == GetLastDay() then 1 else 0;
def postmarketopentime = if SecondsFromTime(marketOpenTime) >= 0 then 1 else 0;
def postmarketclosetime = if SecondsTillTime(marketCloseTime) >= 0 then 1 else 0;
############
def yesterdaysClose = close(period = "DAY")[1];
def prevdayclose = close(period = "DAY")[2];
def secondsFromOpen = SecondsFromTime(marketOpenTime);
def secondsTillClose = SecondsTillTime(marketCloseTime);
def marketOpen = if secondsFromOpen >= 0 and secondsTillClose >= 0 then 1 else 0;
def RTH = if SecondsTillTime(marketCloseTime) > 0 and SecondsFromTime(marketOpenTime) >= 0 then 1 else 0;
rec regularHoursOpen = if (secondsFromOpen >= 0 and secondsFromOpen[1] < 0) or (GetDay() != GetDay()[1]) then open else regularHoursOpen[1];
def newDay = if GetDay() != GetDay()[1] then 1 else 0;
rec regHoursHigh = if newDay then high else if marketOpen then
if high > regHoursHigh[1] then high else regHoursHigh[1] else high;
rec regHoursLow = if newDay then low else if marketOpen then
if low < regHoursLow[1] then low else regHoursLow[1] else low;
def yc = if IsNaN(close) then yc[1] else if marketOpen then yesterdaysClose else Double.NaN;
def o = if IsNaN(close) then o[1] else if marketOpen then regularHoursOpen else Double.NaN;
def hg = if IsNaN(close) then hg[1] else o + (yc - o) / 2;
#VPOC
#The study that zzz posted displays the last 5 VPOC and provides an excellent visual as to where an instrument trades relative to the cluster of VPOCs during the past several sessions. Franz uses this cluster of VPOCs to determine the probable direction of the market.
#If price action is trading very close to the cluster of VPOCs, this means that the market is in balance. Should the market trade above this cluster of VPOCs and continue to move higher from there, we may consider a buy at the bottom of the VAL (value area low). Conversely, if the market trades below the cluster of VPOCs, then we’ll be looking for a short entry.
#This is essentially a play on support and resistance. VPOC can be viewed as clusters of support (floor) or resistance (ceiling) zones. If one floor breaks, then it is likely going to trade to the next floor, etc.
#Franz's setup is detailed here http://tos.mx/mVEhr9# For more background information on the subject, read the CME Market Profile Handbook
input painthigh = 4;#Hint painthigh: 1=dots,2=dashes,3=squares,4=horizontal
def paintingStrategyhigh = if painthigh == 1 then PaintingStrategy.POINTS else if painthigh == 4 then PaintingStrategy.DASHES else if painthigh == 3 then PaintingStrategy.SQUARES else PaintingStrategy.HORIZONTAL;
input colorhigh = 0;#Hint colorhigh: 0=magenta,1=cyan,2=light-red,3=light_green,4=yellow,5=red,6=green,7=light_gray,8=gold,9=white
#def volp = reference VolumeProfile("time per profile" = "DAY", "on expansion" = no, "price per row height mode" = "TICKSIZE");
def volp = if isnan(hg) then volp[1] else hg;
def ymd = GetYYYYMMDD();
def capture = !IsNaN(close) and ymd != ymd[1];
def dayCount = CompoundValue(1, if capture then dayCount[1] + 1 else dayCount[1], 0);
def thisDay = (HighestAll(dayCount) - dayCount) ;
rec pivot0 = if IsNaN(close) then pivot0[1] else if thisDay == 0 then volp else pivot0[1];
plot pp0 = pivot0;
pp0.SetPaintingStrategy(paintingStrategyhigh);
pp0.SetDefaultColor(GetColor(colorhigh));
rec pivot1 = if IsNaN(close) then pivot1[1] else if thisDay == 1 then volp else pivot1[1];
plot pp1 = pivot1;
pp1.SetPaintingStrategy(paintingStrategyhigh);
pp1.SetDefaultColor(GetColor(colorhigh));
rec pivot2 = if thisDay == 2 then volp else pivot2[1];
plot pp2 = pivot2;
pp2.SetPaintingStrategy(paintingStrategyhigh);
pp2.SetDefaultColor(GetColor(colorhigh));
rec pivot3 = if thisDay == 3 then volp else pivot3[1];
plot pp3 = pivot3;
pp3.SetPaintingStrategy(paintingStrategyhigh);
pp3.SetDefaultColor(GetColor(colorhigh));
rec pivot4 = if thisDay == 4 then volp else pivot4[1];
plot pp4 = pivot4;
pp4.SetPaintingStrategy(paintingStrategyhigh);
pp4.SetDefaultColor(GetColor(colorhigh));
rec pivot5 = if thisDay == 5 then volp else pivot5[1];
plot pp5 = pivot5;
pp5.SetPaintingStrategy(paintingStrategyhigh);
pp5.SetDefaultColor(GetColor(colorhigh));
rec pivot6 = if thisDay == 6 then volp else pivot6[1];
plot pp6 = pivot6;
pp6.SetPaintingStrategy(paintingStrategyhigh);
pp6.SetDefaultColor(GetColor(colorhigh));
rec pivot7 = if thisDay == 7 then volp else pivot7[1];
plot pp7 = pivot7;
pp7.SetPaintingStrategy(paintingStrategyhigh);
pp7.SetDefaultColor(GetColor(colorhigh));
rec pivot8 = if thisDay == 8 then volp else pivot8[1];
plot pp8 = pivot8;
pp8.SetPaintingStrategy(paintingStrategyhigh);
pp8.SetDefaultColor(GetColor(colorhigh));
rec pivot9 = if thisDay == 9 then volp else pivot9[1];
plot pp9 = pivot9;
pp9.SetPaintingStrategy(paintingStrategyhigh);
pp9.SetDefaultColor(GetColor(colorhigh));
rec pivot10 = if thisDay == 10 then volp else pivot10[1];
plot pp10 = pivot10;
pp10.SetPaintingStrategy(paintingStrategyhigh);
pp10.SetDefaultColor(GetColor(colorhigh));
input showbubbles = yes;
input bubblemover = 2;
def b = bubblemover;
def b1 = b + 1;
def mover = showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]);
AddChartBubble(mover, pivot0[b1], "P0", pp0.TakeValueColor());
AddChartBubble(mover, pivot1[b1], "P1", pp1.TakeValueColor());
AddChartBubble(mover, pivot2[b1], "P2", pp2.TakeValueColor());
AddChartBubble(mover, pivot3[b1], "P3", pp3.TakeValueColor());
AddChartBubble(mover, pivot4[b1], "P4", pp4.TakeValueColor());
AddChartBubble(mover, pivot5[b1], "P5", pp5.TakeValueColor());
AddChartBubble(mover, pivot6[b1], "P6", pp6.TakeValueColor());
AddChartBubble(mover, pivot7[b1], "P7", pp7.TakeValueColor());
AddChartBubble(mover, pivot8[b1], "P8", pp8.TakeValueColor());
AddChartBubble(mover, pivot9[b1], "P9", pp9.TakeValueColor());
AddChartBubble(mover, pivot10[b1], "P10", pp10.TakeValueColor());