TOS Volume Profile to show # of contracts (blue bar)

z32

New member
Been trying to come up w/ a way to modify TOS"s volume profile script to show the # of contracts for each bar (the blue ones on the right) but no luck. Is there anyone here who can help create a script using the existing TOS Volume Profile to show a number on each blue bar representing the # of contracts traded (that determines the thickness / width of the bar)

VolProfile.png
 
Solution
Been trying to come up w/ a way to modify TOS"s volume profile script to show the # of contracts for each bar (the blue ones on the right) but no luck. Is there anyone here who can help create a script using the existing TOS Volume Profile to show a number on each blue bar representing the # of contracts traded (that determines the thickness / width of the bar)

View attachment 21406

1. This is a copy of the TOS Volumeprofile with some adjusttments to the coloring at lines 72-77 in the script , set default to DAY and the opacity to 20.
Code:
DefineGlobalColor("Profile", color.white);
DefineGlobalColor("Point Of Control", GetColor(5));
DefineGlobalColor("Value Area", color.magenta);

vol.show(globalColor("Profile"), if...
Been trying to come up w/ a way to modify TOS"s volume profile script to show the # of contracts for each bar (the blue ones on the right) but no luck. Is there anyone here who can help create a script using the existing TOS Volume Profile to show a number on each blue bar representing the # of contracts traded (that determines the thickness / width of the bar)

View attachment 21406

1. This is a copy of the TOS Volumeprofile with some adjusttments to the coloring at lines 72-77 in the script , set default to DAY and the opacity to 20.
Code:
DefineGlobalColor("Profile", color.white);
DefineGlobalColor("Point Of Control", GetColor(5));
DefineGlobalColor("Value Area", color.magenta);

vol.show(globalColor("Profile"), if showPointOfControl then globalColor("Point Of Control") else color.current, if showValueArea then globalColor("Value Area") else color.current, opacity, "volume color" = Color.white);
POC.SetDefaultColor(globalColor("Point Of Control"));
2. The image (used 1d 1m instead of 1d TODAY) shows the volume in the white numbers on the left side. You need to expand the area to see all of the numbers. In manually adding these, I found that these seem to match the volume for the day.
3. We have very few things that we can do through scripting. Perhaps this might help you.

Screenshot 2024-04-05 151359.png
Code:
#
# TD Ameritrade IP Company, Inc. (c) 2010-2024
#

input pricePerRowHeightMode = {default AUTOMATIC, TICKSIZE, CUSTOM};
input customRowHeight = 1.0;
input timePerProfile = {CHART, MINUTE, HOUR, default 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 = 20;

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", color.white);
DefineGlobalColor("Point Of Control", GetColor(5));
DefineGlobalColor("Value Area", color.magenta);

vol.show(globalColor("Profile"), if showPointOfControl then globalColor("Point Of Control") else color.current, if showValueArea then globalColor("Value Area") else color.current, opacity, "volume color" = Color.white);
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();


#
 
Solution

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

1. This is a copy of the TOS Volumeprofile with some adjusttments to the coloring at lines 72-77 in the script , set default to DAY and the opacity to 20.

2. The image (used 1d 1m instead of 1d TODAY) shows the volume in the white numbers on the left side. You need to expand the area to see all of the numbers. In manually adding these, I found that these seem to match the volume for the day.
3. We have very few things that we can do through scripting. Perhaps this might help you.
Great tool thanks!
 
Thank you @SleepyZ . I got the coloring working but I can't seem to get the volume / contract size showing for each bar (switched to different time frame 'today 1m / 5m / 15m / 30m' or '1 day 1/5/30m' or 'daily'. Can you assist please. The # would show up for stocks though.. but when I tried w/ futures, the # won't show.
 
Last edited:
General questions here. I use the TOS Volume Profile. I am always finding it hard to read the contract quantities on the left axis of the indicator. I know there is now way to change setting so that thenumbers are more visible. It would be great to be able to change the color and contrast and also if the contracts that are moving could display a different color. Does anyone know if a solution is out there for that?
 
General questions here. I use the TOS Volume Profile. I am always finding it hard to read the contract quantities on the left axis of the indicator. I know there is now way to change setting so that thenumbers are more visible. It would be great to be able to change the color and contrast and also if the contracts that are moving could display a different color. Does anyone know if a solution is out there for that?

This a similar question and my reply https://usethinkscript.com/threads/...-show-of-contracts-blue-bar.18276/post-140104
 
@SleepyZ, thank you for the script, been testing it last few trading session but I am having trouble showing the #s (volume / contracts traded) for each histogram ... I am not getting any numbers showing up for any symbols / futures and I toggle to different time frame (1m/today;1m/1day;5m/today;5m/1day;15m / 30m etc). I also tried enlarge the chart size and no # showing neither. I think I am doing something wrong just not sure what....
 
@SleepyZ, thank you for the script, been testing it last few trading session but I am having trouble showing the #s (volume / contracts traded) for each histogram ... I am not getting any numbers showing up for any symbols / futures and I toggle to different time frame (1m/today;1m/1day;5m/today;5m/1day;15m / 30m etc). I also tried enlarge the chart size and no # showing neither. I think I am doing something wrong just not sure what....

Using the code below, make sure you have enough bars as shown in chart settings for the right chart expansion. Zoom out the chart to see even more values

Screenshot 2024-05-10 094444.jpg

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

input pricePerRowHeightMode = {default AUTOMATIC, TICKSIZE, CUSTOM};
input customRowHeight = 1.0;
input timePerProfile = {CHART, MINUTE, HOUR, default 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 = 20;

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", color.white);
DefineGlobalColor("Point Of Control", GetColor(5));
DefineGlobalColor("Value Area", color.magenta);

vol.show(globalColor("Profile"), if showPointOfControl then globalColor("Point Of Control") else color.current, if showValueArea then globalColor("Value Area") else color.current, opacity, "volume color" = Color.white);
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();


#
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
308 Online
Create Post

Similar threads

Similar threads

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