point of control / overnight

DapperDoc

New member
hello everyone!
I'm looking for a volume profile script that begins volume profile on the open (930AM EST) and ends at the end of trading hours (5pm EST,) but starts a new volume profile with after hours (7pmEST) and goes till the next day open, so i can see the overnight range. not sure if it matters but i view my charts on the 1min/5min/15min and would prefer the volume profile chart to be on the right side of the chart like thinkorswim has as the default study. i looked through the forums posted and could not find what im looking for if there has already been a script made can you please send the link. thank you everyone have a blessed day
 
Solution
hello everyone!
I'm looking for a volume profile script that begins volume profile on the open (930AM EST) and ends at the end of trading hours (5pm EST,) but starts a new volume profile with after hours (7pmEST) and goes till the next day open, so i can see the overnight range. not sure if it matters but i view my charts on the 1min/5min/15min and would prefer the volume profile chart to be on the right side of the chart like thinkorswim has as the default study. i looked through the forums posted and could not find what im looking for if there has already been a script made can you please send the link. thank you everyone have a blessed day

This divides the TOS volumeprofile into 3 trading zones defined at user inputs. The...
hello everyone!
I'm looking for a volume profile script that begins volume profile on the open (930AM EST) and ends at the end of trading hours (5pm EST,) but starts a new volume profile with after hours (7pmEST) and goes till the next day open, so i can see the overnight range. not sure if it matters but i view my charts on the 1min/5min/15min and would prefer the volume profile chart to be on the right side of the chart like thinkorswim has as the default study. i looked through the forums posted and could not find what im looking for if there has already been a script made can you please send the link. thank you everyone have a blessed day

This divides the TOS volumeprofile into 3 trading zones defined at user inputs. The default display is 'onexpansion', which can be changed at the input screen.

Capture.jpg
Ruby:
#VolumeProfile_3_TradingZones

input zone1begin  = 0930;
input zone1end    = 1700;
input zone2end    = 1900;

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

# TD Ameritrade IP Company, Inc. (c) 2010-2022
#

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 = 1;
input showPointOfControl = yes;
input showValueArea = yes;
input valueAreaPercent = 70;
input opacity = 50;

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 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();
 
Solution
Can this code be modified to plot only 1 profile during the pre-market hours? What I'm looking for is to plot the VAH, VAL, and POC levels for a specific time frame. For example, the indicator would start plotting at 4 am Eastern and stops at 9:20 am Eastern and the levels would remain on the chart as lines for each level and a cloud for the value area. The current code allows to enter the above example as one of the zones but I don't need to continue to plot the next zones while day-trading the first 2 hours after the market opens. Thanks!
 
Can this code be modified to plot only 1 profile during the pre-market hours? What I'm looking for is to plot the VAH, VAL, and POC levels for a specific time frame. For example, the indicator would start plotting at 4 am Eastern and stops at 9:20 am Eastern and the levels would remain on the chart as lines for each level and a cloud for the value area. The current code allows to enter the above example as one of the zones but I don't need to continue to plot the next zones while day-trading the first 2 hours after the market opens. Thanks!

This will plot the range input from begin to end. The lines will be extended until the time input.
An optional cloud is added between the vah and val lines.
It will only display on the last range on the chart.

Screenshot-2023-05-12-143001.png
Code:
#VolumeProfile_Defined_Time
#Lines extended beyond range (begin - end) til input until time

input begin  = 0400;
input end    = 0920;
input until  = 1130;

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 = no;
input profiles = 2;
input showPointOfControl = yes;

def range = if SecondsFromTime(begin) >= 0 and SecondsTillTime(end) >= 0 then 1 else 0;
def cond  = range != range[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" = 70);
def con = CompoundValue(1, onExpansion, no);
def pc  = if range == 0 then pc[1] else if IsNaN(vol.GetPointOfControl()) and con then pc[1] else vol.GetPointOfControl();
def hVA = if range == 0 then hVA[1] else if IsNaN(vol.GetHighestValueArea()) and con then hVA[1] else vol.GetHighestValueArea();
def lVA = if range == 0 then lVA[1] else if IsNaN(vol.GetLowestValueArea()) and con then lVA[1] else vol.GetLowestValueArea();

def plotsDomain = IsNaN(close) == onExpansion;

plot POC    = if plotsDomain and secondsTillTime(until) > 0 then pc else Double.NaN;
plot VAHigh = if plotsDomain and secondsTillTime(until) > 0 then hVA else Double.NaN;
plot VALow  = if plotsDomain and secondsTillTime(until) > 0 then lVA else Double.NaN;

DefineGlobalColor("Point of Control", Color.RED);
DefineGlobalColor("Value Area", Color.LIGHT_GRAY);

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

input showcloud = yes;
AddCloud(if showcloud then VAHigh else Double.NaN, VALow, GlobalColor("Value Area"), GlobalColor("Value Area") );
 
@SleepyZ This is great, thanks! Would it be possible to have it display this zone for each day based on the selected time frame of the chart? As is it only plots the current day. Much appreciated.

Just noticed that the zone values change based on the time range of the chart (i.e. 5 minute 1 Day vs. 5 minute 20 Day).

Also, can this be used to scan tickers that are inside and near the zone? I would like to add a column to a watchlist that gets highlighted yellow when the ticker is near the zone and red when in the zone. Thanks again for your help!
 
Last edited by a moderator:
@SleepyZ This is great, thanks! Would it be possible to have it display this zone for each day based on the selected time frame of the chart? As is it only plots the current day. Much appreciated.

Just noticed that the zone values change based on the time range of the chart (i.e. 5 minute 1 Day vs. 5 minute 20 Day).

Also, can this be used to scan tickers that are inside and near the zone? I would like to add a column to a watchlist that gets highlighted yellow when the ticker is near the zone and red when in the zone. Thanks again for your help!

You can display more days by increasing the input profiles by a multiple of 2, based upon the need for 2 for each day.

Screenshot 2023-05-27 140301.png


The following code now includes a section you can use to create a watchlist.
It has an input to determine the near_percent and optional plots of the resulting expanded vahighs and valows.
Chartbubbles will allow testing of the color scheme.
A label can help with creating your desired watchlist.

Screenshot 2023-05-27 145207.png
Code:
#VolumeProfile_Defined_Time
#Lines extended beyond range (begin - end) til input until time

input begin  = 0400;
input end    = 0920;
input until  = 1130;

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 = no;
input profiles = 2;
input showPointOfControl = yes;

def range = if SecondsFromTime(begin) >= 0 and SecondsTillTime(end) >= 0 then 1 else 0;
def cond  = range != range[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" = 70);
def con = CompoundValue(1, onExpansion, no);
def pc  = if range == 0 then pc[1] else if IsNaN(vol.GetPointOfControl()) and con then pc[1] else vol.GetPointOfControl();
def hVA = if range == 0 then hVA[1] else if IsNaN(vol.GetHighestValueArea()) and con then hVA[1] else vol.GetHighestValueArea();
def lVA = if range == 0 then lVA[1] else if IsNaN(vol.GetLowestValueArea()) and con then lVA[1] else vol.GetLowestValueArea();

def plotsDomain = IsNaN(close) == onExpansion;

plot POC    = if plotsDomain and SecondsTillTime(until) > 0 then pc else Double.NaN;
plot VAHigh = if plotsDomain and SecondsTillTime(until) > 0 then hVA else Double.NaN;
plot VALow  = if plotsDomain and SecondsTillTime(until) > 0 then lVA else Double.NaN;

DefineGlobalColor("Point of Control", Color.RED);
DefineGlobalColor("Value Area", Color.LIGHT_GRAY);

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

input showcloud = yes;
AddCloud(if showcloud then VAHigh else Double.NaN, VALow, GlobalColor("Value Area"), GlobalColor("Value Area") );


####### Watchlist
def extended_range = if SecondsFromTime(begin) >= 0 and SecondsTillTime(until) >= 0 then 1 else 0;

input near_percent = .3;
input show_expanded_vahigh_valow_lines = no;
plot vahigh_expanded = VAHigh * (1 + near_percent / 100);
plot valow_expanded  = VALow * (1 - near_percent / 100);
vahigh_expanded.SetHiding(!show_expanded_vahigh_valow_lines);
valow_expanded.SetHiding(!show_expanded_vahigh_valow_lines);

def near_cond =
if extended_range
then if Between(close, VAHigh, vahigh_expanded) or Between(close, valow_expanded, VALow)
then 1
else if Between(close, VALow, VAHigh)
then 2
else 3
else Double.NaN;

input show_bubbles = yes;
AddChartBubble(show_bubbles and extended_range, low * .9995, near_cond, if near_cond == 1 then Color.YELLOW else if near_cond == 2 then Color.RED else Color.GRAY, no);

input show_watchlist_label = yes;
AddLabel(show_watchlist_label, near_cond, if near_cond == 1 then Color.YELLOW else if near_cond == 2 then Color.RED else Color.GRAY);
 

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