#VolumeProfile_MidNight_Anchor
input begin = 0000;
input pricePerRowHeightMode = {AUTOMATIC, default TICKSIZE};
def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
height = PricePerRow.AUTOMATIC;
case TICKSIZE:
height = PricePerRow.TICKSIZE;
}
def rth = SecondsFromTime(begin) == 0 and secondsTillTime(begin)==0;
profile vol = VolumeProfile("startNewProfile" = rth, "onExpansion" = no, "numberOfProfiles" = 1000, pricePerRow = height);
def pca = if IsNaN(vol.GetPointOfControl()) then pca[1] else vol.GetPointOfControl();
def hVA = if IsNaN(vol.GetHighestValueArea()) then hVA[1] else vol.GetHighestValueArea();
def lVA = if IsNaN(vol.GetLowestValueArea()) then lVA[1] else vol.GetLowestValueArea();
def poc = if !rth or IsNaN(close) then poc[1] else pca;
def ub = if !rth or IsNaN(close) then ub[1] else hVA;
def lb = if !rth or IsNaN(close) then lb[1] else lVA;
plot VPOC = poc;
plot VAH = ub;
plot VAL = lb;
VPOC.SetDefaultColor(Color.MAGENTA);
VAH.SetDefaultColor(Color.WHITE);
VAL.SetDefaultColor(Color.WHITE);
VPOC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
input showpointofcontrol = yes;
input showvaluearea = yes;
input opacity = 50;
vol.Show(Color.CYAN, if showpointofcontrol then Color.CYAN else Color.CURRENT, if showvaluearea then Color.YELLOW else Color.CURRENT, opacity);
def hProfile = if IsNaN(vol.GetHighest()) then hProfile[1] else vol.GetHighest();
def lProfile = if IsNaN(vol.GetLowest()) then lProfile[1] else vol.GetLowest();
plot ProfileHigh = hprofile;
plot ProfileLow = lprofile;
ProfileHigh.SetDefaultColor(Color.GREEN);
ProfileLow.SetDefaultColor(Color.RED);
ProfileHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Tried it now only shows one not multiples as shown on you screenshot@john3 See if this helps
Code:#VolumeProfile_MidNight_Anchor input begin = 0000; input pricePerRowHeightMode = {AUTOMATIC, default TICKSIZE}; def height; switch (pricePerRowHeightMode) { case AUTOMATIC: height = PricePerRow.AUTOMATIC; case TICKSIZE: height = PricePerRow.TICKSIZE; } def rth = SecondsFromTime(begin) == 0 and secondsTillTime(begin)==0; profile vol = VolumeProfile("startNewProfile" = rth, "onExpansion" = no, "numberOfProfiles" = 1000, pricePerRow = height); def pca = if IsNaN(vol.GetPointOfControl()) then pca[1] else vol.GetPointOfControl(); def hVA = if IsNaN(vol.GetHighestValueArea()) then hVA[1] else vol.GetHighestValueArea(); def lVA = if IsNaN(vol.GetLowestValueArea()) then lVA[1] else vol.GetLowestValueArea(); def poc = if !rth or IsNaN(close) then poc[1] else pca; def ub = if !rth or IsNaN(close) then ub[1] else hVA; def lb = if !rth or IsNaN(close) then lb[1] else lVA; plot VPOC = poc; plot VAH = ub; plot VAL = lb; VPOC.SetDefaultColor(Color.MAGENTA); VAH.SetDefaultColor(Color.WHITE); VAL.SetDefaultColor(Color.WHITE); VPOC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); VAH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); VAL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); input showpointofcontrol = yes; input showvaluearea = yes; input opacity = 50; vol.Show(Color.CYAN, if showpointofcontrol then Color.CYAN else Color.CURRENT, if showvaluearea then Color.YELLOW else Color.CURRENT, opacity); def hProfile = if IsNaN(vol.GetHighest()) then hProfile[1] else vol.GetHighest(); def lProfile = if IsNaN(vol.GetLowest()) then lProfile[1] else vol.GetLowest(); plot ProfileHigh = hprofile; plot ProfileLow = lprofile; ProfileHigh.SetDefaultColor(Color.GREEN); ProfileLow.SetDefaultColor(Color.RED); ProfileHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); ProfileLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
#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 = 1615;
def count = secondsfromTime(rthbegin)>0 and secondstillTime(rthend)>0;
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);
Hi Sleepy,See if this works the way you want> Adjust the rthbegin and rthend to control the split of the volumeprofile.
Code:#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 = 1615; def count = secondsfromTime(rthbegin)>0 and secondstillTime(rthend)>0; 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);
Hi Sleepy,
Quick question.... and it may be user-error on my part...
When I change the RTH in the study to 9:30 to 16:00, here are the starting and ending bars for the RTH and Overnight sessions on my chart....
On a 15-minute chart of the /ES (I'm in the CT so my TOS charts are set to my local time zone/RTH: 8:30-15:00):
RTH:
1st bar is 8:45 (shouldn't this be 8:30?)
Last bar is 14:45 (which is correct)
Overnight (non-RTH):
1st bar is 15:00 (which is correct)
Last bar is 8:30 (shouldn't this be 8:15?)
I've tried tweaking the RTH times in the study but can't seem to get that 8:30 bar to be included in RTH....
Hi Sleepy,See if this helps
Code:#VolumeProfile_PreviousDay_displayed_NextDay #20190426 Sleepyz def height = PricePerRow.AUTOMATIC; 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);
This indicator is a stock TOS indicator and this version is a workaround for a request a number of years ago to separate RTH. So perhaps since it was not designed with an option to do this separation, It may not be accurate. TOS has not provided the criteria behind the profile, so any movement may be the result of that. Personally,Hi Sleepy,
Any idea that you can think of why these lines sometimes change (not always) a little throughout the current day? Sometimes, they don't seem to be "anchored" throughout the current day (a single smooth line from the previous day into & throughout the current day) and move a little bit as the day progresses..... They don't move too much, but enough to make a difference in a few points/ticks...
Hi Sleepy,This indicator is a stock TOS indicator and this version is a workaround for a request a number of years ago to separate RTH. So perhaps since it was not designed with an option to do this separation, It may not be accurate. TOS has not provided the criteria behind the profile, so any movement may be the result of that. Personally,
Hi Sleepy,
Are you referring to my earlier question about a time adjustment for the Volume Profile study for RTH vs non-RTH, your time adjustment suggestion was a perfect fix (Post #82))?
This question is about using the stock TOS Volume Profile study with the "#VolumeProfile_PreviousDay_displayed_NextDay" from Post #64...
#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);
Is there a way to remove the subgraph on the TOS Default VolumeProfile? I just want the POC line.
thanks for the help https%3A//i.imgur.com/PWL52z5.png[/img]']First... How to insert image in a post thread?
Are you sure your chart settings in the upper right corner are set to Auto or Manual on all charts...??? Without seeing what's happening it's hard to be of more help... I don't use Volume Profile but there might be a version that allows you to scale the output by displaying thousands or millions rather than raw volume...
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Start a new thread and receive assistance from our community.
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.
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.