germanburrito
Active member
Volume Profile POC Plotted Forward ThinkOrSwim
I like this idea so here is this, I took a code I found in house and I added standard deviations to it, the problem is that is using the deviation from the whole chart not just the previous day, which I think might work better from experience. usually I would look at a weekly chart, for intraday movement, for weekly movement I would look at maybe a 20 day or 30 day that way you have a better idea of how much it has "deviated" thru out the month. let me know if you like this.
I like this idea so here is this, I took a code I found in house and I added standard deviations to it, the problem is that is using the deviation from the whole chart not just the previous day, which I think might work better from experience. usually I would look at a weekly chart, for intraday movement, for weekly movement I would look at maybe a 20 day or 30 day that way you have a better idea of how much it has "deviated" thru out the month. let me know if you like this.
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: