Volume Profile POC Plotted Forward ThinkOrSwim

germanburrito

Active member
Volume Profile POC Plotted Forward ThinkOrSwim
I like this idea so here is this, I took a code I found in house and I added standard deviations to it, the problem is that is using the deviation from the whole chart not just the previous day, which I think might work better from experience. usually I would look at a weekly chart, for intraday movement, for weekly movement I would look at maybe a 20 day or 30 day that way you have a better idea of how much it has "deviated" thru out the month. let me know if you like this.

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

def dev = StDevall(close);
plot dev1 =  pPOC + dev * 1;
plot dev2 = pPOC - (dev * 1);
plot dev3 = pPOC + (dev * 2);
plot devN1 =  pPOC - dev * 2;
plot devN2 = pPOC + (dev * 3);
plot devN3 = pPOC - (dev * 3);


dev1.SetDefaultColor(Color.WHITE);
dev2.SetDefaultColor(Color.WHITE);
dev3.SetDefaultColor(Color.WHITE);
devN1.SetDefaultColor(Color.WHITE);
devN2.SetDefaultColor(Color.WHITE);
devN3.SetDefaultColor(Color.WHITE);

addcloud(PrevHVA , PrevlVA , color.LIGHT_GRAY);
VcAmbkt.png
 
Last edited by a moderator:
This is really nice. Thanks. I was a programmer a lont time ago, but I can't seem to follow thinkscripts logic, some things are invisible to me.

I've been tryin to get a volume profile to work this way;
Set up a normal volume profile with the following;
Chart is set up with aggregation period of 30 minutes with a 10 day time interval
'time per profile' = Day
'onexpansion' = no
multiplier = 1

This gives me 'almost' what I want. It draws a proflie with POC an value areas every day.
What I want however is that the drawn profile, VAs and POC are calculated for the previous 10 DAYS!
If I put 10 in the multiplier it gives me a profile, VAs and POC every ten days.
I'd just like to intercept that calculation and have it calculate for a time interval of 10 days, but plot every day.

The reason I'd like to do this is I'd like to backtest a strategy based on where the price was compared to the VAs historically, I'm not so much interested in the profile plot as I am the VAs and POC plots.

Could you point me in the right direction, if you could. I'd appreciate it!

Regards,

Edgardo Montero
 
This is really nice. Thanks. I was a programmer a lont time ago, but I can't seem to follow thinkscripts logic, some things are invisible to me.

I've been tryin to get a volume profile to work this way;
Set up a normal volume profile with the following;
Chart is set up with aggregation period of 30 minutes with a 10 day time interval
'time per profile' = Day
'onexpansion' = no
multiplier = 1

This gives me 'almost' what I want. It draws a proflie with POC an value areas every day.
What I want however is that the drawn profile, VAs and POC are calculated for the previous 10 DAYS!
If I put 10 in the multiplier it gives me a profile, VAs and POC every ten days.
I'd just like to intercept that calculation and have it calculate for a time interval of 10 days, but plot every day.

The reason I'd like to do this is I'd like to backtest a strategy based on where the price was compared to the VAs historically, I'm not so much interested in the profile plot as I am the VAs and POC plots.

Could you point me in the right direction, if you could. I'd appreciate it!

Regards,

Edgardo Montero
i think i figuere it out, all you had to do is check where it says timeframe week and see how it was calculating it, because a week is 5 trading days so you adjust the math from 7 to 14, anyways blahblahblah, this plots two weeks back which should 10 trading days, you cant choose where it starts itll just do the half of the month forward i believe.


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 / 14);
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);

def dev = StDevall(close);
plot dev1 =  pPOC + dev * 1;
plot dev2 = pPOC - (dev * 1);
plot dev3 = pPOC + (dev * 2);
plot devN1 =  pPOC - dev * 2;
plot devN2 = pPOC + (dev * 3);
plot devN3 = pPOC - (dev * 3);


dev1.SetDefaultColor(Color.WHITE);
dev2.SetDefaultColor(Color.WHITE);
dev3.SetDefaultColor(Color.WHITE);
devN1.SetDefaultColor(Color.WHITE);
devN2.SetDefaultColor(Color.WHITE);
devN3.SetDefaultColor(Color.WHITE);

addcloud(PrevHVA , PrevlVA , color.LIGHT_GRAY);
 
Is there a way to move forward the actual volume profile (volume profile bars), not only the levels/lines, but have the actually volume from previous day show in todays trading day?
 
Last edited:
Volume Profile POC Plotted Forward ThinkOrSwim
I like this idea so here is this, I took a code I found in house and I added standard deviations to it, the problem is that is using the deviation from the whole chart not just the previous day, which I think might work better from experience. usually I would look at a weekly chart, for intraday movement, for weekly movement I would look at maybe a 20 day or 30 day that way you have a better idea of how much it has "deviated" thru out the month. let me know if you like this.

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

def dev = StDevall(close);
plot dev1 =  pPOC + dev * 1;
plot dev2 = pPOC - (dev * 1);
plot dev3 = pPOC + (dev * 2);
plot devN1 =  pPOC - dev * 2;
plot devN2 = pPOC + (dev * 3);
plot devN3 = pPOC - (dev * 3);


dev1.SetDefaultColor(Color.WHITE);
dev2.SetDefaultColor(Color.WHITE);
dev3.SetDefaultColor(Color.WHITE);
devN1.SetDefaultColor(Color.WHITE);
devN2.SetDefaultColor(Color.WHITE);
devN3.SetDefaultColor(Color.WHITE);

addcloud(PrevHVA , PrevlVA , color.LIGHT_GRAY);
View attachment 11998
Yes, what are those 3 white and red lines?
 
Yes, what are those 3 white and red lines?

The magenta line is the previous point of control
The longest row of the Volume Profile defines the price level at which the highest number of real transactions were made during the specified time period; this level is called Point Of Control (POC).
https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/V-Z/VolumeProfile
The white lines are the standard deviations from POC

The textbook usage: looks for pullbacks to fall below the previous POC before applying your strategy.
 
Last edited:
Thanks to @SleepyZ for writing this script. I use it on daily and weekly time frames and would really appreciate it if he could add a user defined input that I could select to plot only the value area lines for the current period selected in the script (today when daily is selected or this week if weekly is selected) so that my chart can be cleaner.
 
Last edited by a moderator:

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