Volume Profile Indicator & POCs For ThinkOrSwim

vgt2101

New member
This one has everything you asked for and more.

I have never used it with equities, only with futures. Be careful with the volume or TPO profile in TOS, it uses aggregated values, not a true tick, so it might lag the real profile, especially intraday. In addition, the values for different time frames often do not match.

Code:
#v1.1 - 5/10/18
#- Able to get Implied Volatity at any specified time. Default set to 9PM est 
#- Modified Settlement to take closing price of the last bar of the day. Previous version used "Closing Price" at 16:15 which was usually nowhere near ending settlement
#- Added option to substitute symbol used in IV/Deviation calculation for instruments with #no option chains such as /NKD 
#- Added customizable deviation line (hidden as default)

#===========================
#Steps if you want your VA to match u/uberbotman's:
#1) Set your chart to 30M, and show extended hours
#2) Go to options, make sure ShowLabels is set to "Yes" (hit apply if needed)
#3) Copy VAH, POC and VAL from the labels in the top left corner of your chart into Manual input locations
#4) Set Value Area Area Mode to Manual

declare upper;
declare once_per_bar;
#============================
#Inputs
#============================

input SetMode = {default Auto, Manual};#Hint SetMode: Select Auto to update Settlement automatically in input manually. \n\n NOTE: ToS doesn't support Settlement so LAST closing price is used. This is usually pretty close to within a single tick, but Manually entering Settlement from CME website or UBM's nightly post is more accurate
input Settlement = 2444.50;#Hint Settlement: Enter Settlement value when SetMode is set to Manual
input IVMode = {default Auto, Manual};#Hint IVMode: Select Auto to update Implied Volatility at time chosen on IVSettleTime
input IVSettleTime = 2100;#Hint IVSettleTime: Enter time_value of desired Implied Volatility "settlement" \n\n NOTE: If time selected is not visible on chart (i.e. 2100 on a chart not showing extended trading hours), IV will not calculate
input Volatility = 11.2;#Hint Volatility: Enter Implied Volatility value when IVMode is set to Manual
input IVSymbolMode = {default Auto, Manual};#Hint IVSymbolMode: Select Manual if you wish to use a different instrument's IV instead of what is on the chart
input Symbol = "EWJ";#Hint Symbol: Enter symbol of Implied Volatility you wish to substitute with. For use with products with no option chains (i.e. /NKD)
input ValueAreaMode = {default Auto, Manual};#Hint ValueAreaMode: Select Auto to update Value Areas automatically and is rounded to the nearest tick. Manual selection changes Value Area for today only \n\n NOTE: Value Area is typically calculated on a 30min chart, if the timeframe changes, then calculated value area may also change. To lock in the values from the 30min chart follow these steps: \n#1) Set your chart to 30M, and show extended hours \n#2) Go to options, make sure ShowLabels is set to "Yes" (hit apply if needed) \n#3) Copy VAH, POC and VAL from the labels showing in the top left corner of the chart into the Manual input locations \n#4) Set Value Area Area Mode to Manual and hit Apply
input ValueAreaHigh = 2445.00;#Hint ValueAreaHigh: Enter Value Area High when ValueAreaMode is set to Manual
input PointOfControl = 2442.00;#Hint PointOfControl: Enter Point of Control when ValueAreaMode is set to Manual
input ValueAreaLow = 2440.00;#Hint ValueAreaLow: Enter Value Area Low when ValueAreaMode is set to Manual
input ShowTodayOnly = {default "No", "Yes"};#Hint ShowTodayOnly: Show/Hide chart plots for previous days
input ShowBubbles = {"No", default "Yes"};#Hint ShowBubbles: Show/Hide chart bubbles
input ShowCloud = {"No", default "Yes"};#Hint ShowCloud: Show/Hide Value Area cloud
input ShowLabels = {"No", default "Yes"};#Hint ShowLabels: Show/Hide Labels with Value Area data and IV used for Std Deviation calculations in Auto setting
input ProfileType = {default Volume, Time};#Hint ProfileType: Switch between Volume Profile and Time Profile
input valueAreaPercent = 70;#Hint valueAreaPercent: Set the size of the Value Area
input ShowVWAP = {"No", default "Yes"};#Hint ShowVWAP: Show daily VWAP
input CustomDev = 3.5;#Hint CustomDev: Enter custom deviation line

#============================
#Std Dev Calc / Plot
#============================

def CloseTime2 = SecondsTillTime(0000) >= 0;
def OpenTime2 = SecondsFromTime(1700) >= 0;
def MarketOpen = OpenTime2 and CloseTime2;
def NewDay = IsNaN(close(period = “Day”)[-1]);
def Chart  = MarketOpen and NewDay;
def bar = BarNumber();

def SettleTime = 1800;
rec SetTimeValue = if(secondstilltime(SettleTime)== 0,close()[1],SetTimeValue[1]);
def SetAtTime = if(SetTimeValue == 0, double.nan,SetTimeValue);

def Set = if SetMode == SetMode."Manual" and NewDay then Settlement else SetAtTime;

rec IVTimeValue = if(secondstilltime(IVSettleTime)== 0,imp_volatility(symbol = if IVSymbolMode == IVSymbolMode."Auto" then GetSymbol() else Symbol)[1],IVTimeValue[1]);
def IVSet = if(IVTimeValue==0, double.nan,IVTimeValue);
def Vol = if IVMode == IVMode."Manual" and NewDay then Volatility else IVSet;


def a = Vol;
def b = a / Sqrt(252);
def SD = b * Set;


plot Settle = Round(If (MarketOpen, Set, If (ShowTodayOnly, Double.NaN, Set)) / TickSize(), 0) * TickSize();
Settle.SetDefaultColor(Color.DARK_GREEN);
Settle.SetStyle(Curve.FIRM);
Settle.SetLineWeight(2);
AddChartBubble(bar == HighestAll(bar) and ShowBubbles, Settle, "Set", Color.DARK_GREEN, no);

plot StdDev025H = Round(If (Chart, Set + (SD * 0.25), If (ShowTodayOnly, Double.NaN, Set + (SD * 0.25))) / TickSize(), 0) * TickSize();
StdDev025H.SetDefaultColor(Color.GRAY);
StdDev025H.SetStyle(Curve.SHORT_DASH);
AddChartBubble(bar == HighestAll(bar) and ShowBubbles, StdDev025H, "0.25 Std Dev ", Color.GRAY, no);

plot StdDev05H = Round(If (Chart, Set + (SD * 0.5), If (ShowTodayOnly, Double.NaN, Set + (SD * 0.5))) / TickSize(), 0) * TickSize();
StdDev05H.SetDefaultColor(Color.CYAN);
StdDev05H.SetStyle(Curve.SHORT_DASH);
AddChartBubble(bar == HighestAll(bar) and ShowBubbles, StdDev05H, "0.5 Std Dev ", Color.CYAN, no);

plot StdDev1H = Round(If (Chart, Set + (SD * 1), If (ShowTodayOnly, Double.NaN, Set + (SD * 1))) / TickSize(), 0) * TickSize();
StdDev1H.SetDefaultColor(Color.VIOLET);
StdDev1H.SetStyle(Curve.LONG_DASH);
AddChartBubble(bar == HighestAll(bar) and ShowBubbles, StdDev1H, "1 Std Dev", Color.VIOLET, no);

plot StdDev1_5H = Round(If (Chart, Set + (SD * 1.5), If (ShowTodayOnly, Double.NaN, Set + (SD * 1.5))) / TickSize(), 0) * TickSize();
StdDev1_5H.SetDefaultColor(Color.PLUM);
StdDev1_5H.SetStyle(Curve.LONG_DASH);
#AddChartBubble(bar == HighestAll(bar) and ShowBubbles, StdDev1_5H, "1.5 Std Dev", Color.PLUM, no);

plot StdDev2H = Round(If (Chart, Set + (SD * 2), If (ShowTodayOnly, Double.NaN, Set + (SD * 2))) / TickSize(), 0) * TickSize();
StdDev2H.SetDefaultColor(Color.PLUM);
StdDev2H.SetStyle(Curve.FIRM);
StdDev2H.SetLineWeight(3);
AddChartBubble(bar == HighestAll(bar) and ShowBubbles, StdDev2H, "2 Std Dev", Color.PLUM, no);

plot StdDev3H = Round(If (Chart, Set + (SD * 3), If (ShowTodayOnly, Double.NaN, Set + (SD * 3))) / TickSize(), 0) * TickSize();
StdDev3H.SetDefaultColor(Color.DARK_RED);
StdDev3H.SetStyle(Curve.FIRM);
StdDev3H.SetLineWeight(3);
AddChartBubble(bar == HighestAll(bar) and ShowBubbles, StdDev3H, "3 Std Dev", Color.DARK_RED, no);

plot StdDev025L = Round(If (Chart, Set + (SD * -0.25), If (ShowTodayOnly, Double.NaN, Set + (SD * -0.25))) / TickSize(), 0) * TickSize();
StdDev025L.SetDefaultColor(Color.GRAY);
StdDev025L.SetStyle(Curve.SHORT_DASH);
AddChartBubble(bar == HighestAll(bar) and ShowBubbles, StdDev025L, "-0.25 Std Dev", Color.GRAY, no);

plot StdDev05L = Round(If (Chart, Set + (SD * -0.5), If (ShowTodayOnly, Double.NaN, Set + (SD * -0.5))) / TickSize(), 0) * TickSize();
StdDev05L.SetDefaultColor(Color.CYAN);
StdDev05L.SetStyle(Curve.SHORT_DASH);
AddChartBubble(bar == HighestAll(bar) and ShowBubbles, StdDev05L, "-0.5 Std Dev", Color.CYAN, no);

plot StdDev1L = Round(If (Chart, Set + (SD * -1), If (ShowTodayOnly, Double.NaN, Set + (SD * -1))) / TickSize(), 0) * TickSize();
StdDev1L.SetDefaultColor(Color.VIOLET);
StdDev1L.SetStyle(Curve.LONG_DASH);
AddChartBubble(bar == HighestAll(bar) and ShowBubbles, StdDev1L, "1 Std Dev", Color.VIOLET, no);

plot StdDev1_5L = Round(If (Chart, Set + (SD * -1.5), If (ShowTodayOnly, Double.NaN, Set + (SD * -1.5))) / TickSize(), 0) * TickSize();
StdDev1_5L.SetDefaultColor(Color.PLUM);
StdDev1_5L.SetStyle(Curve.LONG_DASH);
#AddChartBubble(bar == HighestAll(bar) and ShowBubbles, StdDev1_5L, "-1.5 Std Dev", Color.PLUM, no);

plot StdDev2L = Round(If (Chart, Set + (SD * -2), If (ShowTodayOnly, Double.NaN, Set + (SD * -2))) / TickSize(), 0) * TickSize();
StdDev2L.SetDefaultColor(Color.PLUM);
StdDev2L.SetStyle(Curve.FIRM);
StdDev2L.SetLineWeight(3);
AddChartBubble(bar == HighestAll(bar) and ShowBubbles, StdDev2L, "-2 Std Dev", Color.PLUM, no);

plot StdDev3L = Round(If (Chart, Set + (SD * -3), If (ShowTodayOnly, Double.NaN, Set + (SD * -3))) / TickSize(), 0) * TickSize();
StdDev3L.SetDefaultColor(Color.DARK_RED);
StdDev3L.SetStyle(Curve.FIRM);
StdDev3L.SetLineWeight(3);
AddChartBubble(bar == HighestAll(bar) and ShowBubbles, StdDev3L, "-3 Std Dev", Color.DARK_RED, no);

plot CustDev = Round(If (Chart, Set + (SD * CustomDev), If (ShowTodayOnly, Double.NaN, Set + (SD * CustomDev))) / TickSize(), 0) * TickSize();
CustDev.Hide();
CustDev.SetDefaultColor(Color.YELLOW);
CustDev.SetStyle(Curve.FIRM);
CustDev.SetLineWeight(2);


# =================================
# Volume Profile Definition Section
# =================================

def profiles = 50;
def customRowHeight = 1.0;
def multiplier = 1;
def onExpansion = ShowTodayOnly;
def yyyymmdd = GetYYYYMMDD();
def seconds = SecondsFromTime(0);
def period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
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);
def height = PricePerRow.TICKSIZE;

rec 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];



#============================
# Plot POC VAH VAL Section
#============================

profile tpo = if ProfileType == ProfileType.Volume then VolumeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent)
    else TimeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);


rec PC = if cond == 1 then tpo.GetPointOfControl()[1] else PC[1];
plot POC = Round(If(ValueAreaMode == ValueAreaMode."Auto", PC, if NewDay then PointOfControl else PC) / TickSize(), 0) * TickSize();
POC.SetDefaultColor(Color.DARK_RED);
POC.SetStyle(Curve.FIRM);
POC.SetLineWeight(2);

rec hVA = if cond == 1 then tpo.GetHighestValueArea()[1] else hVA[1];
plot VAH = Round(If(ValueAreaMode == ValueAreaMode."Auto", hVA, if NewDay then ValueAreaHigh else hVA) / TickSize(), 0) * TickSize();
VAH.SetDefaultColor(Color.RED);
VAH.SetStyle(Curve.FIRM);

rec lVA = if cond == 1 then tpo.GetLowestValueArea()[1] else lVA[1];
plot VAL =  Round(If(ValueAreaMode == ValueAreaMode."Auto", lVA, if NewDay then ValueAreaLow else lVA) / TickSize(), 0) * TickSize();
;
VAL.SetDefaultColor(Color.GREEN);
VAL.SetStyle(Curve.FIRM);


#============================
# VWAP Plot
#============================
def VWAP1 = Round(vwap(period = AggregationPeriod.DAY) / TickSize(), 0) * TickSize();
plot VWAP = if ShowVWAP > 0 then VWAP1 else Double.NaN;
VWAP.SetPaintingStrategy(PaintingStrategy.DASHES);
VWAP.SetDefaultColor(Color.DARK_GRAY);


#============================
#Value Area Cloud & Labels
#============================

def VArea  = Between(close, VAL, VAH);
def VAreaAbove  = close > VAH;
def VAreaBelow  = close < VAL;

def Cloudhigh = if ShowCloud then VAH else Double.NaN;
def Cloudlow  = if ShowCloud then VAL else Double.NaN;
AddCloud(CloudHigh, CloudLow, GlobalColor("cloud"), GlobalColor("cloud"));
DefineGlobalColor("cloud", Color.DARK_GRAY);

AddLabel(ShowLabels, Concat("VAH:", Round(VAH)), if close > VAH then Color.GREEN else Color.RED)  ;
AddLabel(ShowLabels, Concat("POC:", Round(POC)), if close > POC then Color.GREEN else Color.RED);
AddLabel(ShowLabels, Concat("VAL:", Round(VAL)), if close > VAL then Color.GREEN else Color.RED);
AddLabel(ShowLabels, Concat("VWAP: ", Round(VWAP1)), Color.LIGHT_ORANGE);
AddLabel(ShowLabels, "IV: " + AsPercent(IVSet), if IsAscending(imp_volatility(period = AggregationPeriod.DAY, priceType = PriceType.LAST)[1]) then Color.RED else if IsDescending(imp_volatility(period = AggregationPeriod.DAY, priceType = PriceType.LAST)[1]) then Color.GREEN else Color.WHITE);
AddLabel(ShowLabels, if VArea then "Inside Value Area" else if VAreaAbove then  "Above Value Area" else "Below Value Area", if VArea then Color.ORANGE else if VAreaAbove then Color.GREEN else Color.RED);


#============================
# Alerts:
#============================
input alerttext = "Entry/Exit Point";
# BLOCK CODE BELOW
input UseAlerts = {false, default true};
input AlertType = {default "BAR", "ONCE", "TICK"};
def at = AlertType;
input AlertSound = {default "Bell", "Chimes", "Ding", "NoSound", "Ring"};
def Signal = (close crosses POC) or (close crosses VAH) or (close crosses VAL) or (close crosses StdDev05H) or (close crosses StdDev1H) or (close crosses StdDev2H) or (close crosses StdDev05L) or (close crosses StdDev1L) or (close crosses StdDev2L);
Alert(UseAlerts and Signal, alerttext, if at == 1 then Alert.ONCE else if at == 2 then Alert.TICK else Alert.BAR, AlertSound);
Hey John, I stumbled across your/this posting after realizing what you mentioned during my weekend review; the think or swim VPOC indicator think script shows that the time period definitions are via aggregate value calculations (this realization started with me noticing that the weekly VPOC on a daily chart (time per profile = week, expansion = no) was different from the weekly VPOC on an intraday chart (expansion = yes, time per profile = chart). Would you happen to have a script that fixes this issue?
 

vgt2101

New member
Did anyone realize that the VPOC for stocks changes based on the time frame chosen. I noticed this while analyzing the VPOC for FUBO from 07/01/21 - 07/23/2021, expansion = yes. The VPOC for the 5 minute time frame is higher than the VPOC for the 15 minute time frame during the same time period. Which one is correct? Does anyone know why this is the case?
 

vgt2101

New member
Thank you, I was referring to the RTH version. What you may be seeing with the #64 code is that did not have an option for
pricePerRowHeightMode rather than just automatic. So if you are comparing that code to a stock volume profile the previous day set at 'custom or tick' rather than automatic, you might see a difference. I have adjusted the script to allow for options for row height.

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);
Hey Sleepy, do you agree that there is an issue with the Week definition in this script since it seems to be based on the past 7 days? I thought it was an issue since I incorrectly thought the weekly VPOC read was for the specific trading week and not inclusive of data from the previous week. Or am I interpreting this incorrectly?
 

SleepyZ

Well-known member
Hey Sleepy, do you agree that there is an issue with the Week definition in this script since it seems to be based on the past 7 days? I thought it was an issue since I incorrectly thought the weekly VPOC read was for the specific trading week and not inclusive of data from the previous week. Or am I interpreting this incorrectly?

The above script is set to display the previous day on the current day for how the user requested it.

See the header -- #VolumeProfile_PreviousDay_displayed_NextDay.

Just use the native TOS volumeprofile set to a week and it will displays Mon-Fri for stocks (other instruments may include more periods when traded, for example, /ES includes Sunday. The above script will plot the previous week's Mon-Fri volume profile on the current week for stocks.
 

vgt2101

New member
Wow thanks for getting back to me so quickly SleepyZ; this is greatly appreciated.

I don't believe the native TOS volume profile set to a week displays the correct VPOC for Mon-Fri for stocks. I've come to this realization by comparing the VPOC readings under two different settings.

The first setting is
Chart time frame = 2 year, Daily
time per profile = Week
on expansion = No

The second setting is
Chart time frame = custom, dates for specific week chosen, aggregation period = any intra day period from 5 to 30 min)
Time per profile = Chart
on expansion = Yes

I believe the VPOC calculation from the second setting criteria is more accurate than the VPOC calculation from the first setting criteria due to the calculation used for the Week case in the thinkscript (which includes information being divided by 7, maybe for 7 days a week?).

But then again, when analyzing VPOC readings according to the second setting criteria while changing the aggregation period between 1, 5, 15, and 30 min and keeping the custom time period (a specific trading week) the same, I noticed that the VPOC readings are not the same.

Yeah; this confuses me - do I need to change a setting detail to fix this you think?
 

SleepyZ

Well-known member
Wow thanks for getting back to me so quickly SleepyZ; this is greatly appreciated.

I don't believe the native TOS volume profile set to a week displays the correct VPOC for Mon-Fri for stocks. I've come to this realization by comparing the VPOC readings under two different settings.

The first setting is
Chart time frame = 2 year, Daily
time per profile = Week
on expansion = No

The second setting is
Chart time frame = custom, dates for specific week chosen, aggregation period = any intra day period from 5 to 30 min)
Time per profile = Chart
on expansion = Yes

I believe the VPOC calculation from the second setting criteria is more accurate than the VPOC calculation from the first setting criteria due to the calculation used for the Week case in the thinkscript (which includes information being divided by 7, maybe for 7 days a week?).

But then again, when analyzing VPOC readings according to the second setting criteria while changing the aggregation period between 1, 5, 15, and 30 min and keeping the custom time period (a specific trading week) the same, I noticed that the VPOC readings are not the same.

Yeah; this confuses me - do I need to change a setting detail to fix this you think?
I noticed the differences as you. I use the prior day levels mostly and find they are very useful even though not entirely matching other site’s exactly. I have therefore not studied it as TOS does not provide enough detail IMO to do so.
 

sparhawk

New member
VIP
I use the Volume Profile a lot in my trading so I'm hoping someone can help me come up with a watchlist column utilizing that indicator. I haven't been able to locate anything like it, and I've been unsuccessful trying to create it on my own.

I'm thinking this should be fairly simple for someone who knows how to code.

I would like to add a watchlist column that does 2 things:

1) Display the current POC based on the timeframe I have selected
2) Color the background of the watchlist column based upon where price is at in relation to the POC, VAHigh & VALow.

I believe the code below (which I have borrowed from the ORB watchlist column and edited should work for that), but I haven't any idea how to put the rest of it together.

CODE FOR CHANGING BACKGROUND COLOR:

Code:
AssignBackgroundColor(if Close>POC and Close<VAHigh then color.green else if Close>POC and Close>VAHigh then color.dark_green else if Close<POC and Close>VALow then color.red else if Close<POC and Close<VALow then color.dark_red else color.black);

Appreciate any help the community can provide! This could be a useful addition for anyone who trades with the volume profile indicator.

Cheers!
 

SleepyZ

Well-known member
I use the Volume Profile a lot in my trading so I'm hoping someone can help me come up with a watchlist column utilizing that indicator. I haven't been able to locate anything like it, and I've been unsuccessful trying to create it on my own.

I'm thinking this should be fairly simple for someone who knows how to code.

I would like to add a watchlist column that does 2 things:

1) Display the current POC based on the timeframe I have selected
2) Color the background of the watchlist column based upon where price is at in relation to the POC, VAHigh & VALow.

I believe the code below (which I have borrowed from the ORB watchlist column and edited should work for that), but I haven't any idea how to put the rest of it together.

CODE FOR CHANGING BACKGROUND COLOR:

Code:
AssignBackgroundColor(if Close>POC and Close<VAHigh then color.green else if Close>POC and Close>VAHigh then color.dark_green else if Close<POC and Close>VALow then color.red else if Close<POC and Close<VALow then color.dark_red else color.black);

Appreciate any help the community can provide! This could be a useful addition for anyone who trades with the volume profile indicator.

Cheers!
Here is the following code in a watchlist

Screenshot-2021-08-10-145757.jpg

Ruby:
def poc = reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no);
def vahigh = reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no).VAHigh;
def valow = reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no).VALow;

AddLabel(1, poc, Color.BLACK);
AssignBackgroundColor(if close > poc and close < vahigh then Color.GREEN else if close > poc and close > vahigh then Color.DARK_GREEN else if close < poc and close > valow then Color.RED else if close < poc and close < valow then Color.DARK_RED else Color.BLACK);
 

sparhawk

New member
VIP
Here is the following code in a watchlist
Thanks @SleepyZ, really appreciate your quick response with providing the code! I'm noticing that the value appearing in the watchlist is not matching up with POC shown on my charts. For example, if I select the 10m time frame for the watchlist and view a 10m chart the POC values are never the same.

Could there be a small discrepancy in the code causing the watchlist to calculate a different value?

Thanks again.
 

SleepyZ

Well-known member
Thanks @SleepyZ, really appreciate your quick response with providing the code! I'm noticing that the value appearing in the watchlist is not matching up with POC shown on my charts. For example, if I select the 10m time frame for the watchlist and view a 10m chart the POC values are never the same.

Could there be a small discrepancy in the code causing the watchlist to calculate a different value?

Thanks again.

Everything matches the same for my test.

Please make sure all settings are the same on the chart, watchlist and volume profiles contained therein. The volume profile in the watchlist is set to ticksize and Day, with the watchlist set to 10min extended hours.

 

sparhawk

New member
VIP
Everything matches the same for my test.

Please make sure all settings are the same on the chart, watchlist and volume profiles contained therein. The volume profile in the watchlist is set to ticksize and Day, with the watchlist set to 10min extended hours.
Thanks, it is matching for me now. It seems that is just in PM or AH that the values are differing, but after 9:30 they are correct. It must have something to do with extended hours which I do have selected on the watchlist, but I don't typically trade premarket so not a huge deal. Appreciate the help.
 

ComfyCouch

New member
@halcyonguy

Hey, I apologize for bumping an old thread and pinging you here, but I was wondering if you ever got around to figuring out OP/your own study? I too am doing something similar to OP's original query - basically wanting to plot levels of significance (high, low, POCs of day bars) dating back from two Sundays ago to current. For example, if today is Monday (8/23), then ideally, the study would be plotting levels up to the second previous Sunday (8/15) on today's chart. However, I'm not quite sure how to even approach this. I started by trying to define the Sunday as an offset to input in the look back of the variable, but quickly learned thats not how it worked. A friend of mine, though not familiar with thinkscript, told me that a fold function might work. I looked into this on ToS' TLC website and from what I can tell, if I define the days as numbers with Sunday being the start, it could loop until the 14th day? I'm not even sure if that makes sense.

If possible, any help and/or advice here is greatly appreciated. Again, sorry to ping and bump this old thread.

Couch.
 

Similar threads

Top