VolumeProfile: customizing colors for different profiles

mac-d

New member
I'm using the volume profile study to look at the previous day. Is there a way to hide the profile for the current day?

Below is a 15m chart, no ext hours. I added the volume profile study twice. The first instance uses one profile and the second uses two profiles. I changed colors in the first instance to match the chart background and basically cover the profile. Is there anywhere in the code where I can hide or change the colors of the first profile?

wP6AxyP.png
 
Last edited:
I'm using the volume profile study to look at the previous day. Is there a way to hide the profile for the current day?

Below is a 15m chart, no ext hours. I added the volume profile study twice. The first instance uses one profile and the second uses two profiles. I changed colors in the first instance to match the chart background and basically cover the profile. Is there anywhere in the code where I can hide or change the colors of the first profile?

wP6AxyP.png

The plot can be limited to a particular period selected for the lines, but not the valuearea. The valuearea is displayed in vol.show() portion of the code and is set by TOS to not allow variables that are, for example, used to limit the limes. If you can live with just the lines for poc, hva, lva, etc. let me know I will work something up for you.
 
Thanks @SleepyZ! I took your suggestion and just settled for the various levels. The script is working nicely for almost all custom time periods. I'm running into an issue when it comes to extended hours. For some reason, the script won't draw the time from 1800-2400. I'll use the following inputs:

start date: 20220810
end date: 20220811
start time: 1800
end time: 000

start date: 20220810
end date: 20220810
start time: 1800
end time: 1900 or 2000 or 2100 etc.

lqWhYDV.png

6wVA72w.png


----------------------------------------
input pricePerRowHeightMode = {default AUTOMATIC, TICKSIZE, CUSTOM};
input customRowHeight = 1.0;
input startDateYYYYMMDD = 20220801;
input endDateYYYYMMDD = 20220806;
input startTimeEST = 0000;
input endTimeEST = 0000;
input profiles = 2;
input showProfile = no;
input valueAreaPercent = 70;
input opacity = 20;

def fixedrange = if GetYYYYMMDD() < startDateYYYYMMDD then 3 else if GetYYYYMMDD() == startDateYYYYMMDD and SecondsTillTime(startTimeEST) > 0 then 3 else if GetYYYYMMDD() > endDateYYYYMMDD then 2 else if GetYYYYMMDD() == endDateYYYYMMDD and SecondsFromTime(endTimeEST) >= 0 then 2 else 1;
def fr = GetYYYYMMDD() < endDateYYYYMMDD or (GetYYYYMMDD() == endDateYYYYMMDD and SecondsTillTime(endTimeEST) > 0);
def period = fixedrange;
rec count = CompoundValue(1, if period != period[1] then (count[1] + period - period[1]) else count[1], 0);
def cond = 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" = no, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
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 = if showProfile then IsNaN(close) == no else IsNaN(close) == no and fr;

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(3));

vol.show(if showProfile then globalColor("Profile") else color.current, color.current, color.current, opacity);
POC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VALow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileHigh.Hide();
ProfileLow.Hide();
 
Last edited:
Thanks @SleepyZ! I took your suggestion and just settled for the various levels. The script is working nicely for almost all custom time periods. I'm running into an issue when it comes to extended hours. For some reason, the script won't draw the time from 1800-2400. I'll use the following inputs:

start date: 20220810
end date: 20220811
start time: 1800
end time: 000

start date: 20220810
end date: 20220810
start time: 1800
end time: 1900 or 2000 or 2100 etc.

lqWhYDV.png

6wVA72w.png


----------------------------------------
input pricePerRowHeightMode = {default AUTOMATIC, TICKSIZE, CUSTOM};
input customRowHeight = 1.0;
input startDateYYYYMMDD = 20220801;
input endDateYYYYMMDD = 20220806;
input startTimeEST = 0000;
input endTimeEST = 0000;
input profiles = 2;
input showProfile = no;
input valueAreaPercent = 70;
input opacity = 20;

def fixedrange = if GetYYYYMMDD() < startDateYYYYMMDD then 3 else if GetYYYYMMDD() == startDateYYYYMMDD and SecondsTillTime(startTimeEST) > 0 then 3 else if GetYYYYMMDD() > endDateYYYYMMDD then 2 else if GetYYYYMMDD() == endDateYYYYMMDD and SecondsFromTime(endTimeEST) >= 0 then 2 else 1;
def fr = GetYYYYMMDD() < endDateYYYYMMDD or (GetYYYYMMDD() == endDateYYYYMMDD and SecondsTillTime(endTimeEST) > 0);
def period = fixedrange;
rec count = CompoundValue(1, if period != period[1] then (count[1] + period - period[1]) else count[1], 0);
def cond = 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" = no, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
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 = if showProfile then IsNaN(close) == no else IsNaN(close) == no and fr;

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(3));

vol.show(if showProfile then globalColor("Profile") else color.current, color.current, color.current, opacity);
POC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VALow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileHigh.Hide();
ProfileLow.Hide();

This divides the volumeprofile into 3 tradingzones specifically for /ES starting at 1800, 0000 and 0930.

Capture.jpg
Ruby:
#VolumeProfile_3_TradingZones
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) ;

input zone1begin  = 1800;
input zone1end    = 0000;
input zone2end    = 0930;

def tradingzones  = if thisday[1]==1 and thisday==0 and secondsfromTime(zone1begin) >= 0
                    then 1
                    else if SecondsFromTime(zone1end) > 0 and SecondsTillTime(zone2end) > 0
                    then 2
                    else 3;
def cond          = tradingzones[1] != tradingzones;

input showPointOfControl = yes;
input showValueArea = yes;
input valueAreaPercent = 70;
input opacity = 50;

profile vol = VolumeProfile("startNewProfile" = cond, "onExpansion" = no, "numberOfProfiles" = 3, "pricePerRow" = PricePerRow.TICKSIZE, "value area percent" = 70);
def con = CompoundValue(1, yes, 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", 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();
 
Thanks @SleepyZ! Is there any way to combine zones 1 and 2?

This is something I did awhile ago that should work how you want.

Capture.jpg
Ruby:
#VolumeProfile_RTHvOvernight
#BLT
input pricePerRowHeightMode = {default AUTOMATIC, TICKSIZE, CUSTOM};
input customRowHeight = 1.0;
input onExpansion = no;
input profiles = 1000;
input showPointOfControl = yes;
input showValueArea = yes;
input valueAreaPercent = 70;
input opacity = 50;

input rthbegin  = 0930;
input rthend    = 1800;
def count = if secondsfromTime(rthbegin)>=0 and secondstillTime(rthend)>=0 then 1 else 0;
#count.setpaintingStrategy(paintingStrategy.VALUES_BELOW);
def cond = count != count[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);
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();

input bubbles = yes;
input n  = 2;
def   n1 = n + 1;
AddChartBubble(bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), VAHigh[n1], "V-VAH", color = Color.YELLOW, yes);
AddChartBubble(bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), VALow[n1], "V-VAL", Color.YELLOW, no);
AddChartBubble(bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), POC[n1], "V-POC", Color.RED, no);
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
518 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