2 Day Volume Profile

yman

Member
Looking to modify the Volume profile to show 2 days of volume _ Today and Yesterday only
thanks
 
Looking to modify the Volume profile to show 2 days of volume _ Today and Yesterday only
thanks

Try this. You can choose the number of days, including today, at the input to combine volume profiles.

Capture.jpg

Code:
#VolumeProfile_xNumberofDays_IncludingToday
#UseThinkscript request
#20210615
#
# TD Ameritrade IP Company, Inc. (c) 2010-2021
#

input number_of_days_profiles = 2;
def ymd      = GetYYYYMMDD();
def ok       = !IsNaN(close);
def capture  = ok and ymd != ymd[1];
def dayCount = CompoundValue(1, if capture
                                then dayCount[1] + 1
                                else dayCount[1], 0);
def thisDay  = (HighestAll(dayCount) - dayCount) + 1;

input pricePerRowHeightMode = {default AUTOMATIC, TICKSIZE, CUSTOM};
input customRowHeight = 1.0;
input onExpansion = no;
def profiles = number_of_days_profiles;
input showPointOfControl = yes;
input showValueArea = yes;
input valueAreaPercent = 70;
input opacity = 50;

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);
def cond =thisday>number_of_days_profiles;

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();
 
You don't need to touch any code to do this. In the VolumeProfile study's settings, set time per profile to DAY and multiplier to 2. Set profiles to 1 if you only want to see the current profile.
 
You don't need to touch any code to do this. In the VolumeProfile study's settings, set time per profile to DAY and multiplier to 2. Set profiles to 1 if you only want to see the current profile.

Slippage, the request as I understood it was for a 2 day volume profile, including the one developing today and the prior day. The following charts show what you suggested on the upper chart and what I coded below. The do not appear to be the same. Please show how to make them the same without coding.

 
Wow, that's hilarious on TOS's part. What I described appears to be how TOS developers intended this need to be met but the result isn't a rolling two days as we'd expect. TOS splits the chart into two-day periods starting at the beginning. The way their multiplier works doesn't seem useful at all.

https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/V-Z/VolumeProfile

time per profile Defines time interval to compile the volume data for the histogram. Setting this parameter to "CHART" involves the entire price plot into calculation. Values "BAR", "MINUTE", "HOUR", "DAY", "WEEK", "MONTH", and "OPT EXP" allow you to set aggregation manually, specifying number of these periods within the "multiplier" input.
 
If doing swings using a daily chart what should i set the colume profile too, WEEK?

how about for a weekly chart, MONTH?

i used a 1Y1D chart and using CHART i think the profile is kinda too wide
 
If doing swings using a daily chart what should i set the colume profile too, WEEK?

how about for a weekly chart, MONTH?

i used a 1Y1D chart and using CHART i think the profile is kinda too wide
I only use the volumeprofile set to day for intraday charts. I look for symbols where the underlying reacts positively to the profiles value areas and poc. I would recommend you use that criteria to determine the best profile settings at daily and higher charts.
 
I have to apply a disclaimer to anything I say about this. I have used volume profile as a strategy, not a lot, in day trading. I do sometimes put it on my charts for swings but it's not really part of my strategy. It's just contextual information.

In my opinion, for a daily chart, setting volume profile to a week isn't enough. Month maybe is enough. You can set the multiplier setting above 1 to get a wider profile timeframe -- multiple weeks or multiple months.

What I eventually ended up doing was moving the profile to the expansion area, setting the time to Chart, setting the height mode to tick size and turning off the plots for point of control and the value area top/bottom. I just use the shape of the profile to decide where important levels are near price. This also prevents the profile starting over as a blank slate every week or month. And it adapts itself to any timeframe you set the chart to.
 

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