Volume Profile Indicator & POCs For ThinkOrSwim

This will add 1 day if the day of the week is Sunday/Monday for the lookback days.
Thanks for updating the script. I just want to see a line for the average vpoc and tried to comment out the others and change plot to def so they wouldn't show, but now the average vpoc line appears as a dash today only on the daily chart and doesn't extend to the right. The bubble and label do show. Thanks for your help.

https://tos.mx/StM6MSX
 
Last edited:
Thanks for updating the script. I just want to see a line for the average vpoc and tried to comment out the others and change plot to def so they wouldn't show, but now the average vpoc line appears as a dash today only on the daily chart and doesn't extend to the right. The bubble and label do show. Thanks for your help.

https://tos.mx/StM6MSX
This works as you wanted

Screenshot 2024-01-06 203519.png
Code:
# VPOC created by Sleepyz in Jan 2023
input hide_non_avg_plots = yes;
input Vdaysback = 1;
input V1daysback = 8;
input V2daysback = 15;
input V3daysback = 22;
input V4daysback = 29;

input showonexpansion = no;
input begin  = 0930;
input end    = 1600;
def ymd      = GetYYYYMMDD();
def candles  = !IsNaN(close);
def capture  = candles and ymd != ymd[1];
def dayCount = CompoundValue(1, if capture then dayCount[1] + 1 else dayCount[1], 0);
def thisDay  = (HighestAll(dayCount) - dayCount) ;
def na       = Double.NaN;
def rth      = SecondsFromTime(begin) >= 0 and SecondsTillTime(end) >= 0;

####### Chart Mode
input Chart_Mode = {default Intraday, Day};
def cond;
switch (Chart_Mode) {
case Intraday:
    cond = rth != rth[1];
case Day:
    cond = thisDay != thisDay[1];
}

profile vol   = VolumeProfile("startNewProfile" = cond and SecondsTillTime(end) >= 0, "onExpansion" = no, "numberOfProfiles" = 1000, pricePerRow = PricePerRow.TICKSIZE);
def pca       = if IsNaN(vol.GetPointOfControl())   then pca[1] else vol.GetPointOfControl()[1];
def poc       = if !rth or IsNaN(close) then poc[1] else pca[1];
###########

#Day of Week
input Show_DayofWeek_Test = yes;
def vday  = if thisDay == Vdaysback then GetDayOfWeek(GetYYYYMMDD()) else vday[1];
def v1day = if thisDay == V1daysback then GetDayOfWeek(GetYYYYMMDD()) else v1day[1];
def v2day = if thisDay == V2daysback then GetDayOfWeek(GetYYYYMMDD()) else v2day[1];
def v3day = if thisDay == V3daysback then GetDayOfWeek(GetYYYYMMDD()) else v3day[1];
def v4day = if thisDay == V4daysback then GetDayOfWeek(GetYYYYMMDD()) else v4day[1];
AddLabel(Show_DayofWeek_Test, "Test_ Day of Week || V: " + vday + "; V1: " + v1day + "; V2: " + v2day + "; V3: " + v3day + "; V4: " + v4day, Color.YELLOW);

######## Vpocs
def Vpoc      = if thisDay == Vdaysback + if vday == 1 then 1 else 0 and SecondsFromTime(begin) >= 0 then poc else Vpoc[1];
def V1poc     = if thisDay == V1daysback + if vday == 1 then 1 else 0  and SecondsFromTime(begin) >= 0 then poc else V1poc[1];
def V2poc     = if thisDay == V2daysback + if vday == 1 then 1 else 0  and SecondsFromTime(begin) >= 0 then poc else V2poc[1];
def V3poc     = if thisDay == V3daysback + if vday == 1 then 1 else 0  and SecondsFromTime(begin) >= 0 then poc else V3poc[1];
def V4poc     = if thisDay == V4daysback + if vday == 1 then 1 else 0  and SecondsFromTime(begin) >= 0 then poc else V4poc[1];

plot Vpoc1   = if showonexpansion and !IsNaN(close) or thisDay > Vdaysback then Double.NaN else Vpoc;
plot V1poc1  = if showonexpansion and !IsNaN(close) or thisDay > V1daysback then Double.NaN else V1poc;
plot V2poc1  = if showonexpansion and !IsNaN(close) or thisDay > V2daysback then Double.NaN else V2poc;
plot V3poc1  = if showonexpansion and !IsNaN(close) or thisDay > V3daysback then Double.NaN else V3poc;
plot V4poc1  = if showonexpansion and !IsNaN(close) or thisDay > V4daysback then Double.NaN else V4poc;

Vpoc1.SetDefaultColor(Color.YELLOW);
V1poc1.SetDefaultColor(Color.YELLOW);
V2poc1.SetDefaultColor(Color.YELLOW);
V3poc1.SetDefaultColor(Color.YELLOW);
V4poc1.SetDefaultColor(Color.YELLOW);

Vpoc1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
V1poc1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
V2poc1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
V3poc1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
V4poc1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

vpoc1.sethiding(hide_non_avg_plots);
v1poc1.sethiding(hide_non_avg_plots);
v2poc1.sethiding(hide_non_avg_plots);
v3poc1.sethiding(hide_non_avg_plots);
v4poc1.sethiding(hide_non_avg_plots);

######### Average of Vpocs

def avgpoc = if isnan(close) then avgpoc[1]
             else if GetDay() != GetLastDay() then Double.NaN
             else (Vpoc1 + V1poc1 + V2poc1 + V3poc1 + V4poc1) / 5;
plot AvgVpoc1 = avgpoc;
AvgVpoc1.SetDefaultColor(Color.CYAN);
AvgVpoc1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
AvgVpoc1.SetLineWeight(3);

AddLabel(1, "Avg Vpoc: " + AsText(AvgVpoc1), Color.CYAN);

######### Bubbles

input showbubbles = no;
input bubblemover = 2;
def b  = bubblemover;
def b1 = b + 1;
def mover = showbubbles and !IsNaN(close[b1]) and IsNaN(close[b]);

AddChartBubble(mover, AvgVpoc1, "AV", AvgVpoc1.TakeValueColor());
AddChartBubble(mover, Vpoc1, "V" + (Vdaysback + if vday == 1 then 1 else 0), Vpoc1.TakeValueColor());
AddChartBubble(mover, V1poc1, "V" + (V1daysback + if v1day == 1 then 1 else 0), V1poc1.TakeValueColor());
AddChartBubble(mover, V2poc1, "V" + (V2daysback + if v2day == 1 then 1 else 0), V2poc1.TakeValueColor());
AddChartBubble(mover, V3poc1, "V" + (V3daysback + if v3day == 1 then 1 else 0), V3poc1.TakeValueColor());
AddChartBubble(mover, V4poc1, "V" + (V4daysback + if v4day == 1 then 1 else 0), V4poc1.TakeValueColor());

#
 
For this indicator...is there way to have started time 18:00 ( 6:eek:o pm futures open) to 17:eek:o ( 5 pm futures close)..would like to use to on /ES.

Here is a mod to the Mobius script you referenced from horsender's post. The following allows the input begin/end to handle the overnight hours between days that you requested.

The image shows in the upperpane the inputs 1800/1700, the middle pane inputs 1800/0930 and the bottom pane is the original Mobius script with the default input of 0930/1600.

Screenshot 2024-01-07 134012.png

Code:
# Points Of Control Support / Resistance Areas
# Mobius
# V01.03.08.2016
# Locates last 10 Points of Control based on RTH only
# 20240107 Substituted inrange for rth to allow overnight hour inputs

declare Hide_On_Daily;

input RthBegin  = 1800;
input RthEnd    = 1700;

def sec1 = SecondsFromTime(RthBegin);
def sec2 = SecondsFromTime(RthEnd);
def isTime1 = (sec1 >= 0 and sec1[1] < 0) or (sec1 < sec1[1] and sec1 >= 0);
def isTime2 = (sec2 >= 0 and sec2[1] < 0) or (sec2 <= sec2[1] and sec2 >= 0) or istime1[-1]>0;
def inRange = CompoundValue(1, if isTime1 then 1 else if isTime2 then 0 else inRange[1], 0);

def bar = BarNumber();
def RTH = inrange;

def cond = RTH != RTH[1];
profile vol = VolumeProfile("startNewProfile" = cond, "onExpansion" = no, "numberOfProfiles" = 20, "pricePerRow" = PricePerRow.TICKSIZE, "value area percent" = 68.4);
def poc =  if RTH then Round(vol.GetPointOfControl(), 2)
else Double.NaN;
def Poc1 = if !RTH and RTH[1]
           then poc[1]
           else Poc1[1];
def Poc2 = if !RTH and RTH[1]
           then Poc1[1]
           else Poc2[1];
def Poc3 = if !RTH and RTH[1]
           then Poc2[1]
           else Poc3[1];
def Poc4 = if !RTH and RTH[1]
           then Poc3[1]
           else Poc4[1];
def Poc5 = if !RTH and RTH[1]
           then Poc4[1]
           else Poc5[1];
def Poc6 = if !RTH and RTH[1]
           then Poc5[1]
           else Poc6[1];
def Poc7 = if !RTH and RTH[1]
           then Poc6[1]
           else Poc7[1];
def Poc8 = if !RTH and RTH[1]
           then Poc7[1]
           else Poc8[1];
def Poc9 = if !RTH and RTH[1]
           then Poc8[1]
           else Poc9[1];
plot pc =  HighestAll(if isNaN(close[-1])
           then poc
           else double.nan);
pc.SetStyle(Curve.Firm);
pc.SetDefaultColor(Color.Orange);
pc.SetLineWeight(2);
plot pc1 = HighestAll(if isNaN(close[-1])
           then Poc1
           else double.nan);
pc1.SetStyle(Curve.Long_Dash);
pc1.SetDefaultColor(Color.Orange);

plot pc2 = HighestAll(if isNaN(close[-1])
           then poc2
           else double.nan);
pc2.SetStyle(Curve.Long_Dash);
pc2.SetDefaultColor(Color.Orange);

plot pc3 = HighestAll(if isNaN(close[-1])
           then poc3
           else double.nan);
pc3.SetStyle(Curve.Long_Dash);
pc3.SetDefaultColor(Color.Orange);

plot pc4 = HighestAll(if isNaN(close[-1])
           then poc4
           else double.nan);
pc4.SetStyle(Curve.Long_Dash);
pc4.SetDefaultColor(Color.Orange);

plot pc5 = HighestAll(if isNaN(close[-1])
           then poc5
           else double.nan);
pc5.SetStyle(Curve.Long_Dash);
pc5.SetDefaultColor(Color.Orange);

plot pc6 = HighestAll(if isNaN(close[-1])
           then poc6
           else double.nan);
pc6.SetStyle(Curve.Long_Dash);
pc6.SetDefaultColor(Color.Orange);

plot pc7 = HighestAll(if isNaN(close[-1])
           then poc7
           else double.nan);
pc7.SetStyle(Curve.Long_Dash);
pc7.SetDefaultColor(Color.Orange);

plot pc8 = HighestAll(if isNaN(close[-1])
           then poc8
           else double.nan);
pc8.SetStyle(Curve.Long_Dash);
pc8.SetDefaultColor(Color.Orange);

plot pc9 = HighestAll(if isNaN(close[-1])
           then poc9
           else double.nan);
pc9.SetStyle(Curve.Long_Dash);
pc9.SetDefaultColor(Color.Orange);
 
Thanks for updating the script. I just want to see a line for the average vpoc and tried to comment out the others and change plot to def so they wouldn't show, but now the average vpoc line appears as a dash today only on the daily chart and doesn't extend to the right. The bubble and label do show. Thanks for your help.

https://tos.mx/StM6MSX
Do you have indicator that points Monthly POC for X amount months and X amout of weeks?
 
@SleepyZ or anyone who can do this. Is it possible to create an average volume profile excluding the current day? For example, (D[1] + D[2] + D[3] + D[4]) /4, so it would plot an average VAH, VAL, and POC over the past 4 days, not including today.

I appreciate your help.
Thank you.
 
@SleepyZ or anyone who can do this. Is it possible to create an average volume profile excluding the current day? For example, (D[1] + D[2] + D[3] + D[4]) /4, so it would plot an average VAH, VAL, and POC over the past 4 days, not including today.

I appreciate your help.
Thank you.

This provides labels for the averages.
The image shows the TOS Volumeprofiles and the plots from the code for comparison for each day.
There are options to show labels and plots

Screenshot 2024-04-14 120443.png
Code:
#VPOC_VAH_VAL_AVG_xDays

input showlabels = yes;
input showplots  = yes;

def volpoc = reference VolumeProfile("time per profile" = "DAY", "on expansion" = no, "price per row height mode" = "TICKSIZE").POC;
def volvah = reference VolumeProfile("time per profile" = "DAY", "on expansion" = no, "price per row height mode" = "TICKSIZE").VAHigh;
def volval = reference VolumeProfile("time per profile" = "DAY", "on expansion" = no, "price per row height mode" = "TICKSIZE").VALow;

#Define Days
def ymd = GetYYYYMMDD();
def count = if !IsNaN(volpoc) and ymd != ymd[1] then count[1] + 1 else count[1];
def cond  = HighestAll(count) - count ;

#POC
def p1 = if cond == 1 then volpoc else p1[1];
plot poc1 = p1;
def p2 = if cond == 2 then volpoc else p2[1];
plot poc2 = p2;
def p3 = if cond == 3 then volpoc else p3[1];
plot poc3 = p3;
def p4 = if cond == 4 then volpoc else p4[1];
plot poc4 = p4;

#VAH
def h1 = if cond == 1 then volvah else h1[1];
plot hva1 = h1;
def h2 = if cond == 2 then volvah else h2[1];
plot hva2 = h2;
def h3 = if cond == 3 then volvah else h3[1];
plot hva3 = h3;
def h4 = if cond == 4 then volvah else h4[1];
plot hva4 = h4;

#VAL
def l1 = if cond == 1 then volval else l1[1];
plot lva1 = l1;
def l2 = if cond == 2 then volval else l2[1];
plot lva2 = l2;
def l3 = if cond == 3 then volval else l3[1];
plot lva3 = l3;
def l4 = if cond == 4 then volval else l4[1];
plot lva4 = l4;

#Labels

AddLabel(showlabels, "Prior 4 Days", Color.WHITE);
AddLabel(showlabels, "AVG VAH: " + AsDollars((h1 + h2 + h3 + h4) / 4), Color.GREEN);
AddLabel(showlabels, "AVG POC: " + AsDollars((p1 + p2 + p3 + p4) / 4), Color.CYAN);
AddLabel(showlabels, "AVG VAL: " + AsDollars((l1 + l2 + l3 + l4) / 4), Color.RED);

#Hide Plots

poc1.SetHiding(!showplots);
poc2.SetHiding(!showplots);
poc3.SetHiding(!showplots);
poc4.SetHiding(!showplots);

hva1.SetHiding(!showplots);
hva2.SetHiding(!showplots);
hva3.SetHiding(!showplots);
hva4.SetHiding(!showplots);

lva1.SetHiding(!showplots);
lva2.SetHiding(!showplots);
lva3.SetHiding(!showplots);
lva4.SetHiding(!showplots);

#
 
This provides labels for the averages.
The image shows the TOS Volumeprofiles and the plots from the code for comparison for each day.
There are options to show labels and plots
@SleepyZ I added plots for the averages, i.e., avgPOC = (p1 + p2 + p3 + p4) / 4; etc but it doesn't plot the past history. Is it possible to make it plot the past averages for the avgPOC, avgHVA, and avgLVA?

In addition, is it possible to be able to select from the preferences menu, Day, Week, etc?

Thank you.
 
@SleepyZ I added plots for the averages, i.e., avgPOC = (p1 + p2 + p3 + p4) / 4; etc but it doesn't plot the past history. Is it possible to make it plot the past averages for the avgPOC, avgHVA, and avgLVA?

In addition, is it possible to be able to select from the preferences menu, Day, Week, etc?

Thank you.

Here is the AVG plots, Timeperprofile (D, W & M), Optional sideways Bubbles
To do past averages whould likely require a lot of code through the script() function
Screenshot 2024-04-14 143619.png
Code:
#VPOC_VAH_VAL_AVG_xDays_v1
#Added timeperperofile (D,W,M), Avg Plots, Bubbles

input timeperprofile = {default DAY, WEEK, MONTH};
input showlabels     = yes;
input showtestplots  = no;
input showAVGplots   = yes;
input showbubbles    = yes;

def na = Double.NaN;
def mode;
switch (timeperprofile) {
case DAY:
    mode = GetYYYYMMDD();
case WEEK:
    mode = GetWeek();
case MONTH:
    mode = GetMonth();
}

def volpoc = reference VolumeProfile("time per profile" = timeperprofile, "on expansion" = no, "price per row height mode" = "TICKSIZE").POC;
def volvah = reference VolumeProfile("time per profile" = timeperprofile, "on expansion" = no, "price per row height mode" = "TICKSIZE").VAHigh;
def volval = reference VolumeProfile("time per profile" = timeperprofile, "on expansion" = no, "price per row height mode" = "TICKSIZE").VALow;

#Define Mose Periods

def count = if !IsNaN(volpoc) and mode != mode[1] then count[1] + 1 else count[1];
def cond  = HighestAll(count) - count ;

#POC
def p1 = if cond == 1 then volpoc else p1[1];
plot poc1 = p1;
def p2 = if cond == 2 then volpoc else p2[1];
plot poc2 = p2;
def p3 = if cond == 3 then volpoc else p3[1];
plot poc3 = p3;
def p4 = if cond == 4 then volpoc else p4[1];
plot poc4 = p4;

#VAH
def h1 = if cond == 1 then volvah else h1[1];
plot hva1 = h1;
def h2 = if cond == 2 then volvah else h2[1];
plot hva2 = h2;
def h3 = if cond == 3 then volvah else h3[1];
plot hva3 = h3;
def h4 = if cond == 4 then volvah else h4[1];
plot hva4 = h4;

#VAL
def l1 = if cond == 1 then volval else l1[1];
plot lva1 = l1;
def l2 = if cond == 2 then volval else l2[1];
plot lva2 = l2;
def l3 = if cond == 3 then volval else l3[1];
plot lva3 = l3;
def l4 = if cond == 4 then volval else l4[1];
plot lva4 = l4;


#Plot Average POC, VAH and VAL
defineGlobalColor("H", color.green);
defineGlobalColor("P", color.cyan);
defineGlobalColor("L", color.red);

plot AvgVAH = if showAVGplots and cond < 1 then highestall((h1 + h2 + h3 + h4) / 4) else na;
plot AvgPOC = if showAVGplots and cond < 1 then highestall((p1 + p2 + p3 + p4) / 4) else na;
plot AvgVAL = if showAVGplots and cond < 1 then highestall((l1 + l2 + l3 + l4) / 4) else na;

AvgVAH.setdefaultColor(globalColor("H"));
AvgPOC.setdefaultColor(globalColor("P"));
AvgVAL.setdefaultColor(globalColor("L"));


#Labels

AddLabel(showlabels, "Prior 4 " + timeperprofile + "s", Color.WHITE);
AddLabel(showlabels, "AVG VAH: " + AsDollars((h1 + h2 + h3 + h4) / 4), Color.GREEN);
AddLabel(showlabels, "AVG POC: " + AsDollars((p1 + p2 + p3 + p4) / 4), Color.CYAN);
AddLabel(showlabels, "AVG VAL: " + AsDollars((l1 + l2 + l3 + l4) / 4), Color.RED);

#Bubbles

input bubblemover = 2;
def b     = bubblemover;
def mover = showbubbles and isnan(close[b]) and !isnan(close[b + 1]);
addchartBubble(mover, AvgVAH, "H: " + asdollars(AVGVAH), AVGVAH.takevaluecolor());
addchartBubble(mover, AvgPOC, "P: " + asdollars(AVGPOC), AVGPOC.takevaluecolor());
addchartBubble(mover, AvgVAL, "L: " + asdollars(AVGVAL), AVGVAL.takevaluecolor());

#Hide Plots

poc1.SetHiding(!showtestplots);
poc2.SetHiding(!showtestplots);
poc3.SetHiding(!showtestplots);
poc4.SetHiding(!showtestplots);

hva1.SetHiding(!showtestplots);
hva2.SetHiding(!showtestplots);
hva3.SetHiding(!showtestplots);
hva4.SetHiding(!showtestplots);

lva1.SetHiding(!showtestplots);
lva2.SetHiding(!showtestplots);
lva3.SetHiding(!showtestplots);
lva4.SetHiding(!showtestplots);

#
 

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
189 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