Greetings all,
I was following the tos script ( Volume Profile POC Plotted Forward) by @germanburrito and @SleepyZ and it looks awesome. I was wondering if there was a way to plot a previous POC line from which the current POC shifts in the code. What I meant was, during any trading session, the POC moves up or down based on the volume transacted. If we can see how the new POC moved from the previous POC, then that would be a good indication of a bullish or bearish trend. Please advice.
Thanks
https://usethinkscript.com/threads/volume-profile-poc-plotted-forward-thinkorswim.8217/#post-77790
I was following the tos script ( Volume Profile POC Plotted Forward) by @germanburrito and @SleepyZ and it looks awesome. I was wondering if there was a way to plot a previous POC line from which the current POC shifts in the code. What I meant was, during any trading session, the POC moves up or down based on the volume transacted. If we can see how the new POC moved from the previous POC, then that would be a good indication of a bullish or bearish trend. Please advice.
Thanks
https://usethinkscript.com/threads/volume-profile-poc-plotted-forward-thinkorswim.8217/#post-77790
Code:
#VolumeProfile_PreviousDay_displayed_NextDay
#20190426 Sleepyz
#20210712 Sleepyz - revised to add option for pricePerRowHeightMode rather than just automatic
input pricePerRowHeightMode = {default AUTOMATIC, TICKSIZE, CUSTOM};
input customRowHeight = 1.0;
def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
height = PricePerRow.AUTOMATIC;
case TICKSIZE:
height = PricePerRow.TICKSIZE;
case CUSTOM:
height = customRowHeight;
}
input timePerProfile = {CHART, MINUTE, HOUR, default DAY, WEEK, MONTH, "OPT EXP", BAR};
input multiplier = 1;
input profiles = 1000;
input valueAreaPercent = 70;
def period;
def yyyymmdd = GetYYYYMMDD();
def seconds = SecondsFromTime(0);
def month = GetYear() * 12 + GetMonth();
def day_number = DaysFromDate(First(yyyymmdd)) + GetDayOfWeek(First(yyyymmdd));
def dom = GetDayOfMonth(yyyymmdd);
def dow = GetDayOfWeek(yyyymmdd - dom + 1);
def expthismonth = (if dow > 5 then 27 else 20) - dow;
def exp_opt = month + (dom > expthismonth);
switch (timePerProfile) {
case CHART:
period = 0;
case MINUTE:
period = Floor(seconds / 60 + day_number * 24 * 60);
case HOUR:
period = Floor(seconds / 3600 + day_number * 24);
case DAY:
period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
case WEEK:
period = Floor(day_number / 7);
case MONTH:
period = Floor(month - First(month));
case "OPT EXP":
period = exp_opt - First(exp_opt);
case BAR:
period = BarNumber() - 1;
}
def count = CompoundValue(1, if period != period[1] then (count[1] + period - period[1]) % multiplier else count[1], 0);
def cond = count < count[1] + period - period[1];
profile vol = VolumeProfile("startNewProfile" = cond, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent, onExpansion = no);
#Prior Day High/Low ValueAreas
def HVA = if IsNaN(vol.GetHighestValueArea()) then HVA[1] else vol.GetHighestValueArea();
def pHVA = CompoundValue(1, if cond then HVA[1] else pHVA[1], Double.NaN);
def LVA = if IsNaN(vol.GetLowestValueArea()) then LVA[1] else vol.GetLowestValueArea();
def pLVA = CompoundValue(1, if cond then LVA[1] else pLVA[1], Double.NaN);
plot PrevHVA = pHVA;
plot PrevLVA = pLVA;
PrevHVA.SetDefaultColor(Color.YELLOW);
PrevLVA.SetDefaultColor(Color.YELLOW);
PrevHVA.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PrevLVA.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
#Prior Day POC Calculated
def POC = if IsNaN(vol.GetPointOfControl()) and cond then POC[1] else vol.GetPointOfControl();
def pPOC = CompoundValue (1, if cond then POC[1] else pPOC[1], Double.NaN);
plot PrevPOC = pPOC;
PrevPOC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PrevPOC.SetDefaultColor(Color.MAGENTA);
def dev = StDevall(close);
plot dev1 = pPOC + dev * 1;
plot dev2 = pPOC - (dev * 1);
plot dev3 = pPOC + (dev * 2);
plot devN1 = pPOC - dev * 2;
plot devN2 = pPOC + (dev * 3);
plot devN3 = pPOC - (dev * 3);
dev1.SetDefaultColor(Color.WHITE);
dev2.SetDefaultColor(Color.WHITE);
dev3.SetDefaultColor(Color.WHITE);
devN1.SetDefaultColor(Color.WHITE);
devN2.SetDefaultColor(Color.WHITE);
devN3.SetDefaultColor(Color.WHITE);
addcloud(PrevHVA , PrevlVA , color.LIGHT_GRAY);
Last edited by a moderator: