Volume Profile Indicator & POCs For ThinkOrSwim

Appreciate this script.

Are there any ways to modify the AA/PM to be one continuous line like here?

F5iCXi0.png
Can you share this VP plz?
 
This is a paid script that I don't have

@draw9300 @Tiredoflosing - this is pretty close to that study you posted.


Code:
# Volume Profile RTH / ETH
# by bigboss

input rth_start = 0930;
input eth_start = 1800;

def cond = secondsTillTime(rth_start) == 0 or secondstilltime(eth_start)==0;
def eth = if secondstilltime(rth_start) == 0 then 0 else if secondstilltime(eth_start)==0 then 1 else eth[1];

profile vol = volumeProfile("startNewProfile" = cond, "onExpansion" = no, "numberOfProfiles" = 1000, "pricePerRow" = priceperrow.TICKSIZE, "value area percent" = 70);
def con = compoundValue(1, no, no);
def pc = if IsNaN(vol.getPointOfControl()) and con then pc[1] else vol.getPointOfControl();
def hVA = if IsNaN(vol.getHighestValueArea()) and con then hVA[1] else vol.getHighestValueArea();
def lVA = if IsNaN(vol.getLowestValueArea()) and con 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 plotsDomain = IsNaN(close) == no;

plot POC = if plotsDomain then pc else Double.NaN;
plot ProfileHigh = if plotsDomain then hProfile else Double.NaN;
plot ProfileLow = if plotsDomain then lProfile else Double.NaN;
plot VAHigh = if plotsDomain then hVA else Double.NaN;
plot VALow = if plotsDomain then lVA else Double.NaN;

DefineGlobalColor("Profile", color.gray);
DefineGlobalColor("Point Of Control", Color.LIGHT_ORANGE);
DefineGlobalColor("Value Area", GetColor(8));

vol.show(globalColor("Profile"), if yes then globalColor("Point Of Control") else color.current, if no then globalColor("Value Area") else color.current, 50);
POC.SetDefaultColor(globalColor("Point Of Control"));
POC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VALow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh.SetDefaultColor(globalColor("Value Area"));
VALow.SetDefaultColor(globalColor("Value Area"));
ProfileHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileHigh.SetDefaultColor(GetColor(3));
ProfileLow.SetDefaultColor(GetColor(3));

profilehigh.AssignValueColor(if eth then color.black else color.white);
profilelow.AssignValueColor(if eth then color.black else color.white);
poc.AssignValueColor(if eth then  createcolor(159,255,255) else color.orange);
profilehigh.setlineWeight(2);
profilelow.setlineWeight(2);
poc.setlineWeight(2);
vahigh.AssignValueColor(if eth then createcolor(55,125,125) else createcolor(22,65,144));
valow.AssignValueColor(if eth then createcolor(55,125,125) else createcolor(22,65,144));
def exp = eth;
addcloud(if !exp then vahigh else double.nan, if !exp then valow else double.nan,  createcolor(22,65,144),  createcolor(22,65,144));
addcloud(if exp then vahigh else double.nan, if exp then valow else double.nan, createcolor(55,125,125), createcolor(5,125,125));

addcloud(if exp then vahigh else double.nan, if exp then profilehigh else double.nan, color.gray, color.GRAY);
addcloud(if exp then valow else double.nan, if exp then profilelow else double.nan, color.gray, color.gray);
addcloud(if !exp then vahigh else double.nan, if !exp then profilehigh else double.nan, color.gray, color.GRAY);
addcloud(if !exp then valow else double.nan, if !exp then profilelow else double.nan, color.gray, color.gray);
 
Odd question but on the default TPO/VPOC scripts is there a way to remove the current time per profile line and keep only the previous anchored ones?
zAwkdKy.png


Like this 1 hour per profile line wouldn't open this new profile line until that hour is over

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2010-2022
#

input pricePerRowHeightMode = {default AUTOMATIC, TICKSIZE, CUSTOM};
input customRowHeight = 1.0;
input timePerProfile = {default CHART, MINUTE, HOUR, DAY, WEEK, MONTH, "OPT EXP", BAR};
input multiplier = 1;
input onExpansion = yes;
input profiles = 1000;
input showPointOfControl = yes;
input showValueArea = yes;
input valueAreaPercent = 70;
input opacity = 50;

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];
def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
    height = PricePerRow.AUTOMATIC;
case TICKSIZE:
    height = PricePerRow.TICKSIZE;
case CUSTOM:
    height = customRowHeight;
}

profile tpo = timeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
def con = compoundValue(1, onExpansion, no);
def pc = if IsNaN(tpo.getPointOfControl()) and con then pc[1] else tpo.getPointOfControl();
def hVA = if IsNaN(tpo.getHighestValueArea()) and con then hVA[1] else tpo.getHighestValueArea();
def lVA = if IsNaN(tpo.getLowestValueArea()) and con then lVA[1] else tpo.getLowestValueArea();

def hProfile = if IsNaN(tpo.getHighest()) and con then hProfile[1] else tpo.getHighest();
def lProfile = if IsNaN(tpo.getLowest()) and con then lProfile[1] else tpo.getLowest();
def plotsDomain = IsNaN(close) == onExpansion;

plot POC = if plotsDomain then pc else Double.NaN;
plot ProfileHigh = if plotsDomain then hProfile else Double.NaN;
plot ProfileLow = if plotsDomain then lProfile else Double.NaN;
plot VAHigh = if plotsDomain then hVA else Double.NaN;
plot VALow = if plotsDomain then lVA else Double.NaN;

DefineGlobalColor("Profile", GetColor(1));
DefineGlobalColor("Point Of Control", GetColor(5));
DefineGlobalColor("Value Area", GetColor(8));

tpo.show(globalColor("Profile"), if showPointOfControl then globalColor("Point Of Control") else color.current, if showValueArea then globalColor("Value Area") else color.current, opacity);
POC.SetDefaultColor(globalColor("Point Of Control"));
POC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VALow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh.SetDefaultColor(globalColor("Value Area"));
VALow.SetDefaultColor(globalColor("Value Area"));
ProfileHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileHigh.SetDefaultColor(GetColor(3));
ProfileLow.SetDefaultColor(GetColor(3));
ProfileHigh.hide();
ProfileLow.hide();
 
@BeakedFish There is an indicator that can create support and resistance zones based on high volume i believe, if this helps.

YlS7jnj.png


Code:
#A nice indicator to play with. See notes below.
#Using volume to determine significant areas of support / resistance on intra-day charts.
#This indicator will work on 5 minute charts or below. The green boxes show the major areas
#from the morning sessions; gray boxes are from the mid-day session; and yellow boxes are from
#the late-afternoon session. The gray lines are the significant areas from the previous day.

def Today = if getday() == getlastday() then 1 else 0;

# Split the day into three trading blocks
def block1 = if SecondsFromTime(0930) >= 0 and SecondsTillTime(1100) > 0 then 1 else 0;
def block2 = if SecondsFromTime(1100) >= 0 and SecondsTillTime(1400) > 0 then 1 else 0;
def block3 = if SecondsFromTime(1400) >= 0 and SecondsTillTime(1600) > 0 then 1 else 0;

def startBlock1 = if block1 and !block1[1] then 1 else 0;
def startBlock2 = if block2 and !block2[1] then 1 else 0;
def startBlock3 = if block3 and !block3[1] then 1 else 0;

# Determine the first bar of the day
def nMinutes = GetAggregationPeriod() / 60000;
def nBars = RoundUp(390 / nMinutes, 0);
def FirstBar = if (BarNumber() - 1) % nBars == 0 then 1 else 0;

# Determine day number
def dayNumber = 1 + RoundDown((BarNumber() - 1) / nBars, 0);

# Track volume in each session block
def vol1 = if !block1 then 0 else if block1 and volume(period="5 min" ) > vol1[1] then volume(period="5 min" ) else vol1[1];
def vol2 = if !block2 then 0 else if block2 and volume(period="5 min" ) > vol2[1] then volume(period="5 min" ) else vol2[1];
def vol3 = if !block3 then 0 else if block3 and volume(period="5 min" ) > vol3[1] then volume(period="5 min" ) else vol3[1];

# Determine high / low for each block
def HighB1 = if startBlock1 then high(period="5 min" ) else if block1 and volume(period="5 min" ) > vol1[1] then high(period="5 min" ) else HighB1[1];
def LowB1 = if startBlock1 then low(period="5 min" ) else if block1 and volume(period="5 min" ) > vol1[1] then low(period="5 min" ) else LowB1[1];
def HighB2 = if startBlock2 then high(period="5 min" ) else if block2 and volume(period="5 min" ) > vol2[1] then high(period="5 min" ) else HighB2[1];
def LowB2 = if startBlock2 then low(period="5 min" ) else if block2 and volume(period="5 min" ) > vol2[1] then low(period="5 min" ) else LowB2[1];
def HighB3 = if startBlock3 then high(period="5 min" ) else if block3 and volume(period="5 min" ) > vol3[1] then high(period="5 min" ) else HighB3[1];
def LowB3 = if startBlock3 then low(period="5 min" ) else if block3 and volume(period="5 min" ) > vol3[1] then low(period="5 min" ) else LowB3[1];

# Plot today's data
plot hb1 = HighB1;
plot lb1 = LowB1;
plot hb2 = if block1 and dayNumber == 1 then Double.NaN else HighB2;
plot lb2 = if block1 and dayNumber == 1 then Double.NaN else LowB2;
plot hb3 = if (block1 or block2) and dayNumber == 1 then Double.NaN else HighB3;
plot lb3 = if (block1 or block2) and dayNumber == 1 then Double.NaN else LowB3;

hb1.SetHiding(1);
hb2.SetHiding(1);
hb3.SetHiding(1);
lb1.SetHiding(1);
lb2.SetHiding(1);
lb3.SetHiding(1);

# Color between the lines
def chb1 = if  hb1 == hb1[-1] then hb1 else double.nan;
def chb2 = if  !block1 and hb2 == hb2[-1] then hb2 else double.nan;
def chb3 = if  block3 and hb3 == hb3[-1] then hb3 else double.nan;
AddCloud(chb1, lb1, color.light_green);
AddCloud(chb2, lb2, color.white);
AddCloud(chb3, lb3, color.yellow);

# Plot yesterday's data
def hb2_1 = if daynumber == 1 then double.nan else if firstbar then highb1[1] else hb2_1[1];
def lb2_1 = if daynumber == 1 then double.nan else if firstbar then lowb1[1] else lb2_1[1];
def hb2_2 = if daynumber ==1 then double.nan else if firstbar then highb2[1] else hb2_2[1];
def lb2_2 = if daynumber == 1 then double.nan else if firstbar then lowb2[1] else lb2_2[1];
def hb2_3 = if daynumber ==1 then double.nan else if firstbar then highb3[1] else hb2_3[1];
def lb2_3 = if daynumber == 1 then double.nan else if firstbar then lowb3[1] else lb2_3[1];

plot l1 = hb2_1;
plot l2 = lb2_1;
plot l3 = hb2_2;
plot l4 = lb2_2;
plot l5 = hb2_3;
plot l6 = lb2_3;

l1.setdefaultColor(color.light_gray);
l2.setdefaultcolor(color.light_gray);
l3.setdefaultcolor(color.light_gray);
l4.setdefaultcolor(color.light_gray);
l5.setdefaultcolor(color.light_gray);
l6.setdefaultcolor(color.light_gray);
l1.setpaintingStrategy(paintingStrategy.HORIZONTAL);
l2.setpaintingStrategy(paintingStrategy.HORIZONTAL);
l3.setpaintingStrategy(paintingStrategy.HORIZONTAL);
l4.setpaintingStrategy(paintingStrategy.HORIZONTAL);
l5.setpaintingStrategy(paintingStrategy.HORIZONTAL);
l6.setpaintingStrategy(paintingStrategy.HORIZONTAL);
Do you use this? If so, what do you make of the Grey and Yellow zones? Once out of the Green, Grey is upper lvl resistance, and yellow as support? I've seen on lower time frames the Grey zone being in the green zone. Just wondering how you read this. Thank you.
 
Do you use this? If so, what do you make of the Grey and Yellow zones? Once out of the Green, Grey is upper lvl resistance, and yellow as support? I've seen on lower time frames the Grey zone being in the green zone. Just wondering how you read this. Thank you.
i dont use it, i think its areas where there was high volume in think that grey zones are smaller volume areas, i just posted it for the code, incase someone wanted to use it.
 
Great thread. Does anyone have a script to post a clearly delineated day/week/month Volume Profile with POC on the same chart?
 
I am using volume profile POS values and trying to get the yellow POC line extend as price levels. Like white lines shown below in pic.

thanks in advance

cPPc2PK.png














input timeFrame = { default DAY, WEEK, MONTH};





input pricePerRowHeightMode = {default AUTOMATIC, TICKSIZE, CUSTOM};
input customRowHeight = 1.0;
input timePerProfile = {default CHART, MINUTE, HOUR, DAY, WEEK, MONTH, "OPT EXP", BAR};
input multiplier = 1;
input onExpansion = yes;
input profiles = 1000;
input showPointOfControl = yes;
input showValueArea = yes;
input valueAreaPercent = 70;
input opacity = 50;

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];
def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
height = PricePerRow.AUTOMATIC;
case TICKSIZE:
height = PricePerRow.TICKSIZE;
case CUSTOM:
height = customRowHeight;
}

profile vol = volumeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
def con = compoundValue(1, onExpansion, no);
def pc = if IsNaN(vol.getPointOfControl()) and con then pc[1] else vol.getPointOfControl();
def hVA = if IsNaN(vol.getHighestValueArea()) and con then hVA[1] else vol.getHighestValueArea();
def lVA = if IsNaN(vol.getLowestValueArea()) and con 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 plotsDomain = IsNaN(close) == onExpansion;

def tf1d = AggregationPeriod.week;


plot POC = if plotsDomain then pc else Double.NaN;
plot ProfileHigh = if plotsDomain then hProfile else Double.NaN;
plot ProfileLow = if plotsDomain then lProfile else Double.NaN;
plot VAHigh = if plotsDomain then hVA else Double.NaN;
plot VALow = if plotsDomain then lVA else Double.NaN;

DefineGlobalColor("Profile", GetColor(1));
DefineGlobalColor("Point Of Control", GetColor(5));
DefineGlobalColor("Value Area", GetColor(8));

vol.show(globalColor("Profile"), if showPointOfControl then globalColor("Point Of Control") else color.current, if showValueArea then globalColor("Value Area") else color.current, opacity);
POC.SetDefaultColor(globalColor("Point Of Control"));
POC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VALow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh.SetDefaultColor(globalColor("Value Area"));
VALow.SetDefaultColor(globalColor("Value Area"));
ProfileHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileHigh.SetDefaultColor(GetColor(3));
ProfileLow.SetDefaultColor(GetColor(3));
ProfileHigh.hide();
ProfileLow.hide();
 
Great thread. Does anyone have a script to post a clearly delineated day/week/month Volume Profile with POC on the same chart?

This uses the script function to create the 3 profilles

Capture.jpg
Ruby:
script vp {
# TD Ameritrade IP Company, Inc. (c) 2010-2022
#

    input pricePerRowHeightMode = {AUTOMATIC, default TICKSIZE, CUSTOM};
    input customRowHeight = 1.0;
    input timePerProfile = {default CHART, MINUTE, HOUR, DAY, WEEK, MONTH, "OPT EXP", BAR};
    input multiplier = 1;
    input onExpansion = no;
    input profiles = 1;
    input showPointOfControl = yes;
    input showValueArea = yes;
    input valueAreaPercent = 70;
    input opacity = 50;

    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];
    def height;
    switch (pricePerRowHeightMode) {
    case AUTOMATIC:
        height = PricePerRow.AUTOMATIC;
    case TICKSIZE:
        height = PricePerRow.TICKSIZE;
    case CUSTOM:
        height = customRowHeight;
}

    profile vol = VolumeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
    def con = CompoundValue(1, onExpansion, no);
    def pc = if IsNaN(vol.GetPointOfControl()) and con then pc[1] else vol.GetPointOfControl();
    def hVA = if IsNaN(vol.GetHighestValueArea()) and con then hVA[1] else vol.GetHighestValueArea();
    def lVA = if IsNaN(vol.GetLowestValueArea()) and con 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 plotsDomain = IsNaN(close) == onExpansion;

    plot POC = if plotsDomain then pc else Double.NaN;
    plot ProfileHigh = if plotsDomain then hProfile else Double.NaN;
    plot ProfileLow = if plotsDomain then lProfile else Double.NaN;
    plot VAHigh = if plotsDomain then hVA else Double.NaN;
    plot VALow = if plotsDomain then lVA else Double.NaN;

    DefineGlobalColor("Profile", GetColor(1));
    DefineGlobalColor("Point Of Control", GetColor(5));
    DefineGlobalColor("Value Area", GetColor(8));

    vol.Show(GlobalColor("Profile"), if showPointOfControl then GlobalColor("Point Of Control") else Color.CURRENT, if showValueArea then GlobalColor("Value Area") else Color.CURRENT, opacity);
}

plot dpoc = vp("time per profile" = "DAY");
plot wpoc = vp("time per profile" = "WEEK");
plot mpoc = vp("time per profile" = "MONTH");

plot dvah = vp("time per profile" = "DAY").VAHigh;
plot wvah = vp("time per profile" = "WEEK").VAHigh;
plot mvah = vp("time per profile" = "MONTH").VAHigh;

plot dval = vp("time per profile" = "DAY").VALow;
plot wval = vp("time per profile" = "WEEK").VALow;
plot mval = vp("time per profile" = "MONTH").VALow;

DefineGlobalColor("Profile", GetColor(1));
DefineGlobalColor("Point Of Control", GetColor(5));
DefineGlobalColor("Value Area", GetColor(8));

dpoc.SetDefaultColor(GlobalColor("Point Of Control"));
dpoc.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
dvah.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
dval.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
dvah.SetDefaultColor(GlobalColor("Value Area"));
dval.SetDefaultColor(GlobalColor("Value Area"));

wpoc.SetDefaultColor(GlobalColor("Point Of Control"));
wpoc.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
wvah.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
wval.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
wvah.SetDefaultColor(GlobalColor("Value Area"));
wval.SetDefaultColor(GlobalColor("Value Area"));

mpoc.SetDefaultColor(GlobalColor("Point Of Control"));
mpoc.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
mvah.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
mval.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
mvah.SetDefaultColor(GlobalColor("Value Area"));
mval.SetDefaultColor(GlobalColor("Value Area"));

input showbubbles = yes;
input bubblemover = 3;
def m = bubblemover;
def m1 = m + 1;

AddChartBubble(showbubbles and IsNaN(close[m]) and !IsNaN(close[m1]), dpoc[m1], "DPOC", dpoc.TakeValueColor());
AddChartBubble(showbubbles and IsNaN(close[m]) and !IsNaN(close[m1]), wpoc[m1], "WPOC", wpoc.TakeValueColor());
AddChartBubble(showbubbles and IsNaN(close[m]) and !IsNaN(close[m1]), mpoc[m1], "MPOC", mpoc.TakeValueColor());

AddChartBubble(showbubbles and IsNaN(close[m]) and !IsNaN(close[m1]), dvah[m1], "DVAH", dvah.TakeValueColor());
AddChartBubble(showbubbles and IsNaN(close[m]) and !IsNaN(close[m1]), wvah[m1], "WVAH", wvah.TakeValueColor());
AddChartBubble(showbubbles and IsNaN(close[m]) and !IsNaN(close[m1]), mvah[m1], "MVAH", mvah.TakeValueColor());

AddChartBubble(showbubbles and IsNaN(close[m]) and !IsNaN(close[m1]), dval[m1], "DVAL", dval.TakeValueColor());
AddChartBubble(showbubbles and IsNaN(close[m]) and !IsNaN(close[m1]), wval[m1], "WVAL", wval.TakeValueColor());
AddChartBubble(showbubbles and IsNaN(close[m]) and !IsNaN(close[m1]), mval[m1], "MVAL", mval.TakeValueColor());
 
This might work on most symbols and timeframes that match the periods you requested. The way this works is to assign different values to each period, which remain the same until the next period. The variable cond then prints a new volume profile when the values change.

Is there way to change the layout of the volume profile. The Volume profile starts from right to left. Is there way to flip the profile starts from right side of the chart?

Thank u🙏
 
I am using volume profile POS values and trying to get the yellow POC line extend as price levels. Like white lines shown below in pic.

thanks in advance

cPPc2PK.png

Here is the script you provided with 5 poc extensions to the right added at the bottom of the code. You can create more using the logic in the code. It is a very manual process.

Capture.jpg
Ruby:
#input timeFrame = { default DAY, WEEK, MONTH};

input pricePerRowHeightMode = {default AUTOMATIC, TICKSIZE, CUSTOM};
input customRowHeight = 1.0;
input timePerProfile = {default CHART, MINUTE, HOUR, DAY, WEEK, MONTH, "OPT EXP", BAR};
input multiplier = 1;
input onExpansion = yes;
input profiles = 1000;
input showPointOfControl = yes;
input showValueArea = yes;
input valueAreaPercent = 70;
input opacity = 50;

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];
def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
    height = PricePerRow.AUTOMATIC;
case TICKSIZE:
    height = PricePerRow.TICKSIZE;
case CUSTOM:
    height = customRowHeight;
}

profile vol = VolumeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
def con = CompoundValue(1, onExpansion, no);
def pc = if IsNaN(vol.GetPointOfControl()) and con then pc[1] else vol.GetPointOfControl();
def hVA = if IsNaN(vol.GetHighestValueArea()) and con then hVA[1] else vol.GetHighestValueArea();
def lVA = if IsNaN(vol.GetLowestValueArea()) and con 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 plotsDomain = IsNaN(close) == onExpansion;

def tf1d = AggregationPeriod.WEEK;


plot POC = if plotsDomain then pc else Double.NaN;
plot ProfileHigh = if plotsDomain then hProfile else Double.NaN;
plot ProfileLow = if plotsDomain then lProfile else Double.NaN;
plot VAHigh = if plotsDomain then hVA else Double.NaN;
plot VALow = if plotsDomain then lVA else Double.NaN;

DefineGlobalColor("Profile", GetColor(1));
DefineGlobalColor("Point Of Control", GetColor(5));
DefineGlobalColor("Value Area", GetColor(8));

vol.Show(GlobalColor("Profile"), if showPointOfControl then GlobalColor("Point Of Control") else Color.CURRENT, if showValueArea then GlobalColor("Value Area") else Color.CURRENT, opacity);
POC.SetDefaultColor(GlobalColor("Point Of Control"));
POC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VALow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh.SetDefaultColor(GlobalColor("Value Area"));
VALow.SetDefaultColor(GlobalColor("Value Area"));
ProfileHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileHigh.SetDefaultColor(GetColor(3));
ProfileLow.SetDefaultColor(GetColor(3));
ProfileHigh.Hide();
ProfileLow.Hide();


def vp = if IsNaN(close) then vp[1] else POC;
plot v = vp;
v.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
v.SetDefaultColor(Color.WHITE);
v.SetLineWeight(3);

def poc1 = if POC != POC[1] then POC[1] else poc1[1];
def vp1 = if IsNaN(close) then vp1[1] else poc1;
plot v1 = vp1;
v1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
v1.SetDefaultColor(Color.WHITE);
v1.SetLineWeight(3);

def poc2 = if poc1 != poc1[1] then poc1[1] else poc2[1];
def vp2 = if IsNaN(close) then vp2[1] else poc2;
plot v2 = vp2;
v2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
v2.SetDefaultColor(Color.WHITE);
v2.SetLineWeight(3);

def poc3 = if poc2 != poc2[1] then poc2[1] else poc3[1];
def vp3 = if IsNaN(close) then vp3[1] else poc3;
plot v3 = vp3;
v3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
v3.SetDefaultColor(Color.WHITE);
v3.SetLineWeight(3);

def poc4 = if poc3 != poc3[1] then poc3[1] else poc4[1];
def vp4 = if IsNaN(close) then vp4[1] else poc4;
plot v4 = vp4;
v4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
v4.SetDefaultColor(Color.WHITE);
v4.SetLineWeight(3);

def poc5 = if poc4 != poc4[1] then poc4[1] else poc5[1];
def vp5 = if IsNaN(close) then vp5[1] else poc5;
plot v5 = vp5;
v5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
v5.SetDefaultColor(Color.WHITE);
v5.SetLineWeight(3);
 
Last edited:
This might work on most symbols and timeframes that match the periods you requested. The way this works is to assign different values to each period, which remain the same until the next period. The variable cond then prints a new volume profile when the values change.
Can this indicator be turn into monkey bar indicator or flip the indicator? Starts from the right and points to left.

I looked at the link you shared. can it be applied to the code you created for me?
 
Last edited:
Can this indicator be turn into monkey bar indicator or flip the indicator? Starts from the right and points to left.

I looked at the link you shared. can it be applied to the code you created for me?
Basically, no. We do not have very much control or actual understanding of how TOS forms the profiles. The monkey bars does not look usable when breaking it down similar to the link.
 
@rlohmeyer Is this any better?

Code:
# Profile TPO & Volume
input profileType = {default Volume, Time};
input pricePerRowHeightMode = {default Ticksize, Automatic, Custom};
input customRowHeight = 1.0;
input timePerProfile = {default Day, Week, Month, Year, Hour, Chart, "Opt Exp"};
input multiplier = 1;
input OnExpansionProfile = No;
input OnExpansionValueArea = No;
input profiles = 2;
input showPointOfControl = Yes;
input showValueArea = Yes;
input ValueAreaPercent = 70;
input ShowHighLow = Yes;
input opacity = 5;
input ShowExtensions = No;
input DynamicHideExtensions = Yes;
def SE = ShowExtensions;


def period;
def yyyymmdd = GetYYYYMMDD();
def seconds = SecondsFromTime(0);
def month = GetYear() * 12 + GetMonth();
def year = GetYear();
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 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 Year:
    period = Floor(year - First(year));
case "Opt Exp":
    period = exp_opt - First(exp_opt);
}

def CloseByPeriod = close(Period = timePerProfile)[-1];
def Openbyperiod  = open(Period = timePerProfile)[-1];
def NewDay = if !IsNaN(CloseByPeriod) then 0 else 1;

rec Count = if period != period[1] then (Count[1] + period - period[1]) % 1 else Count[1];
def Cond = Count < Count[1] + period - period[1];
def height;
switch (pricePerRowHeightMode) {
case Automatic:
    height = PricePerRow.AUTOMATIC;
case Ticksize:
    height = PricePerRow.TICKSIZE;
case Custom:
    height = customRowHeight;
}

profile VOL = if profileType == profileType.Volume then VolumeProfile("startNewProfile" = Cond, "onExpansion" = onExpansionProfile, "NumberOfProfiles" = profiles, "PricePerRow" = height, "Value Area Percent" = ValueAreaPercent) else TimeProfile("startNewProfile" = Cond, "OnExpansion" = onExpansionProfile, "NumberOfProfiles" = profiles, "PricePerRow" = height, "Value Area Percent" = ValueAreaPercent);

def con = CompoundValue(1, onExpansionProfile, no);
rec pc = if IsNaN(VOL.GetPointOfControl()) and con then pc[1] else VOL.GetPointOfControl();
rec hVA = if IsNaN(VOL.GetHighestValueArea()) and con then hVA[1] else VOL.GetHighestValueArea();
rec lVA = if IsNaN(VOL.GetLowestValueArea()) and con then lVA[1] else VOL.GetLowestValueArea();
rec HVA_Last = if period == period[1] then HVA_Last[1] else hVA[1];
rec PC_Last  = if period == period[1] then PC_Last[1]  else pc[1];
rec LVA_Last = if period == period[1] then LVA_Last[1] else lVA[1];
rec hProfile = if IsNaN(VOL.GetHighest()) and con then hProfile[1] else VOL.GetHighest();
rec lProfile = if IsNaN(VOL.GetLowest()) and con then lProfile[1] else VOL.GetLowest();
def plotsDomain = IsNaN(close) == onExpansionProfile;

rec hP_Last = if period == period[1] then hP_Last[1] else hProfile[1];
rec lP_Last = if period == period[1] then lP_Last[1] else lProfile[1];

plot VAH  = if !showValueArea then Double.NaN else if IsNaN(close[0]) then HVA_Last[0] else if !OnExpansionValueArea then HVA_Last[0] else Double.NaN;
plot POC  = if IsNaN(close[0]) then PC_Last[0] else if !OnExpansionValueArea then PC_Last[0] else Double.NaN;
plot VAL  = if !showValueArea then Double.NaN else if IsNaN(close[0]) then LVA_Last[0] else if !OnExpansionValueArea then LVA_Last[0] else Double.NaN;
plot High = if !ShowHighLow then Double.NaN else if IsNaN(close[0]) then hP_Last[0] else if !OnExpansionValueArea then hP_Last[0] else Double.NaN;
plot Low = if !ShowHighLow then Double.NaN else if IsNaN(close[0]) then lP_Last[0] else if !OnExpansionValueArea then lP_Last[0] else Double.NaN;

DefineGlobalColor("Profile", GetColor(7));
DefineGlobalColor("Point Of Control", GetColor(5));
DefineGlobalColor("Value Area", GetColor(8));


POC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
POC.SetDefaultColor(Color.DARK_GRAY);
POC.SetLineWeight(1);
POC.HideTitle();

VAH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAH.SetDefaultColor(Color.DARK_GREEN);
VAH.SetLineWeight(1);
VAH.HideBubble();
VAH.HideTitle();

VAL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAL.SetDefaultColor(Color.DARK_RED);
VAL.SetLineWeight(1);
VAL.HideBubble();
VAL.HideTitle();

High.SetPaintingStrategy(PaintingStrategy.DASHES);
High.SetDefaultColor(CreateColor(38, 38, 8));
High.SetLineWeight(1);
High.HideBubble();
High.HideTitle();

Low.SetPaintingStrategy(PaintingStrategy.DASHES);
Low.SetDefaultColor(CreateColor(38, 38, 8));
Low.SetLineWeight(1);
Low.HideBubble();
Low.HideTitle();
For this particular code could someone add a piece of code to shade in between the VAH and VAL?
 
For this particular code could someone add a piece of code to shade in between the VAH and VAL?

Adjust the opacity and global color for value area to your liking in the following modification to the above code. Vol.show() was added to accomplish this.

Ruby:
# Profile TPO & Volume
input profileType = {default Volume, Time};
input pricePerRowHeightMode = {default Ticksize, Automatic, Custom};
input customRowHeight = 1.0;
input timePerProfile = {default Day, Week, Month, Year, Hour, Chart, "Opt Exp"};
input multiplier = 1;
input OnExpansionProfile = No;
input OnExpansionValueArea = No;
input profiles = 2;
input showPointOfControl = Yes;
input showValueArea = Yes;
input ValueAreaPercent = 70;
input ShowHighLow = Yes;
input opacity = 40;
input ShowExtensions = No;
input DynamicHideExtensions = Yes;
def SE = ShowExtensions;


def period;
def yyyymmdd = GetYYYYMMDD();
def seconds = SecondsFromTime(0);
def month = GetYear() * 12 + GetMonth();
def year = GetYear();
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 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 Year:
    period = Floor(year - First(year));
case "Opt Exp":
    period = exp_opt - First(exp_opt);
}

def CloseByPeriod = close(Period = timePerProfile)[-1];
def Openbyperiod  = open(Period = timePerProfile)[-1];
def NewDay = if !IsNaN(CloseByPeriod) then 0 else 1;

rec Count = if period != period[1] then (Count[1] + period - period[1]) % 1 else Count[1];
def Cond = Count < Count[1] + period - period[1];
def height;
switch (pricePerRowHeightMode) {
case Automatic:
    height = PricePerRow.AUTOMATIC;
case Ticksize:
    height = PricePerRow.TICKSIZE;
case Custom:
    height = customRowHeight;
}

profile VOL = if profileType == profileType.Volume then VolumeProfile("startNewProfile" = Cond, "onExpansion" = onExpansionProfile, "NumberOfProfiles" = profiles, "PricePerRow" = height, "Value Area Percent" = ValueAreaPercent) else TimeProfile("startNewProfile" = Cond, "OnExpansion" = onExpansionProfile, "NumberOfProfiles" = profiles, "PricePerRow" = height, "Value Area Percent" = ValueAreaPercent);

def con = CompoundValue(1, onExpansionProfile, no);
rec pc = if IsNaN(VOL.GetPointOfControl()) and con then pc[1] else VOL.GetPointOfControl();
rec hVA = if IsNaN(VOL.GetHighestValueArea()) and con then hVA[1] else VOL.GetHighestValueArea();
rec lVA = if IsNaN(VOL.GetLowestValueArea()) and con then lVA[1] else VOL.GetLowestValueArea();
rec HVA_Last = if period == period[1] then HVA_Last[1] else hVA[1];
rec PC_Last  = if period == period[1] then PC_Last[1]  else pc[1];
rec LVA_Last = if period == period[1] then LVA_Last[1] else lVA[1];
rec hProfile = if IsNaN(VOL.GetHighest()) and con then hProfile[1] else VOL.GetHighest();
rec lProfile = if IsNaN(VOL.GetLowest()) and con then lProfile[1] else VOL.GetLowest();
def plotsDomain = IsNaN(close) == onExpansionProfile;

rec hP_Last = if period == period[1] then hP_Last[1] else hProfile[1];
rec lP_Last = if period == period[1] then lP_Last[1] else lProfile[1];

plot VAH  = if !showValueArea then Double.NaN else if IsNaN(close[0]) then HVA_Last[0] else if !OnExpansionValueArea then HVA_Last[0] else Double.NaN;
plot POC  = if IsNaN(close[0]) then PC_Last[0] else if !OnExpansionValueArea then PC_Last[0] else Double.NaN;
plot VAL  = if !showValueArea then Double.NaN else if IsNaN(close[0]) then LVA_Last[0] else if !OnExpansionValueArea then LVA_Last[0] else Double.NaN;
plot High = if !ShowHighLow then Double.NaN else if IsNaN(close[0]) then hP_Last[0] else if !OnExpansionValueArea then hP_Last[0] else Double.NaN;
plot Low = if !ShowHighLow then Double.NaN else if IsNaN(close[0]) then lP_Last[0] else if !OnExpansionValueArea then lP_Last[0] else Double.NaN;

DefineGlobalColor("Profile", GetColor(7));
DefineGlobalColor("Point Of Control", GetColor(5));
DefineGlobalColor("Value Area", color.cyan);

vol.Show("va color" = globalColor("value area"), color = Color.CURRENT, "volume color" = Color.CURRENT, opacity = opacity);

POC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
POC.SetDefaultColor(Color.DARK_GRAY);
POC.SetLineWeight(1);
POC.HideTitle();

VAH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAH.SetDefaultColor(Color.DARK_GREEN);
VAH.SetLineWeight(1);
VAH.HideBubble();
VAH.HideTitle();

VAL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAL.SetDefaultColor(Color.DARK_RED);
VAL.SetLineWeight(1);
VAL.HideBubble();
VAL.HideTitle();

High.SetPaintingStrategy(PaintingStrategy.DASHES);
High.SetDefaultColor(CreateColor(38, 38, 8));
High.SetLineWeight(1);
High.HideBubble();
High.HideTitle();

Low.SetPaintingStrategy(PaintingStrategy.DASHES);
Low.SetDefaultColor(CreateColor(38, 38, 8));
Low.SetLineWeight(1);
Low.HideBubble();
Low.HideTitle();
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
196 Online
Create Post

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top