Extend Point of Control Line (Volume Profile) For ThinkOrSwim

yardley

New member
Hi,

I need some help redoing the VolumeProfile Indictor that comes with ThinkorSwim. Here's my ask:

I want to present the VolumeProfile indicator on a chart such that the POC of control line extends all the way to the right axis. Here's a pic to demonstrate.
Image

The first image shows a chart that displays the daily Volume Profile with the blue line being the POC. In the second image, I manually drew a line that extends the POC line to the right with the price displayed at the end. Can someone help me replicate this with the existing VolumeProfile indicator that comes with ThinkOrSwim? I'm not very savvy with ThinkOrSwim script. Greatly appreciate any help.
 
Solution
Hi,

I need some help redoing the VolumeProfile Indictor that comes with ThinkorSwim. Here's my ask:

I want to present the VolumeProfile indicator on a chart such that the POC of control line extends all the way to the right axis. Here's a pic to demonstrate.
Image

The first image shows a chart that displays the daily Volume Profile with the blue line being the POC. In the second image, I manually drew a line that extends the POC line to the right with the price displayed at the end. Can someone help me replicate this with the existing VolumeProfile indicator that comes with ThinkOrSwim? I'm not very savvy with ThinkOrSwim script. Greatly appreciate any help.

Just saw your request.

This script combines x number of...
I find that other Volume profile indicators produce different POC values. Some align while some dont, another indicator not at all.
Is there a preference to how POC is calculated, what time frame.. etc. ? Thanks

Personally, I have prior and current day TPO/Volume Profiles (VAH/POC/VAL lines only) set to DAY, on chart and ticksize. They serve valuable support/resistance for me.
 

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

Personally, I have prior and current day TPO/Volume Profiles (VAH/POC/VAL lines only) set to DAY, on chart and ticksize. They serve valuable support/resistance for me.
@SleepyZ , Thank you much for the study. How do I just plot the prior two days & current day's VAH,VAL,POC lines ( Day Profile), on 5/15min charts. I dont want the Value area to change, based on chart timeframe, but reflect the whole session(Day).
Not intereted in the value areas prior to 2 days.
I'd like the prior day's VAH/VAL/POC plotted until the Market open today , irrespective of whether the prices touch/cross them (right now they stop plotting once touched). The VAH,VAL,POC lines from 2 days ago should extend only until the market open yesterday.

hzhokiY.png


Customizable color/format for the the VAH/VAL/POC lines for the three days of interest.

I'm using original your code from #2 post. (no alterations)

Can you pls help? Thanks much
 
@SleepyZ , Thank you much for the study. How do I just plot the prior two days & current day's VAH,VAL,POC lines ( Day Profile), on 5/15min charts. I dont want the Value area to change, based on chart timeframe, but reflect the whole session(Day).
Not intereted in the value areas prior to 2 days.
I'd like the prior day's VAH/VAL/POC plotted until the Market open today , irrespective of whether the prices touch/cross them (right now they stop plotting once touched). The VAH,VAL,POC lines from 2 days ago should extend only until the market open yesterday.

hzhokiY.png


Customizable color/format for the the VAH/VAL/POC lines for the three days of interest.

I'm using original your code from #2 post. (no alterations)

Can you pls help? Thanks much

This might work how you want

Capture.jpg
Ruby:
script v {
    input daysback        = 0;

    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);
    plot thisDay  = (HighestAll(dayCount) - dayCount) ;

    def poc      = if thisDay == daysback then reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no) else poc[1];
    def vahigh   = if thisDay == daysback then reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no).VAHigh else vahigh[1];
    def valow    = if thisDay == daysback then reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no).VALow else valow[1];

    plot poc1    = if thisDay > daysback
               then Double.NaN
               else poc;
    plot vahigh1 = if thisDay > daysback
               then Double.NaN
               else vahigh;
    plot valow1  = if thisDay > daysback
               then Double.NaN
               else valow;

}
input daysback = 2;
input showtodayonly = no;
DefineGlobalColor("P", Color.CYAN);
DefineGlobalColor("H", Color.YELLOW);
DefineGlobalColor("L", Color.YELLOW);

plot p0      = if v() > daysback
               then Double.NaN
               else v().poc;
plot h0      = if v().thisDay > daysback
               then Double.NaN
               else v().vahigh;
plot l0      = if v().thisDay > daysback
               then Double.NaN
               else v().valow;

p0.SetDefaultColor(GlobalColor("P"));
h0.SetDefaultColor(GlobalColor("H"));
l0.SetDefaultColor(GlobalColor("L"));
p0.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
h0.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
l0.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot p1      = if v(1) > daysback or GetDay() == GetLastDay() and SecondsTillTime(0930) < 0
               then Double.NaN
               else v(1).poc;
plot h1      = if v(1).thisDay > daysback or GetDay() == GetLastDay() and SecondsTillTime(0930) < 0
               then Double.NaN
               else v(1).vahigh;
plot l1      = if v(1).thisDay > daysback or GetDay() == GetLastDay() and SecondsTillTime(0930) < 0
               then Double.NaN
               else v(1).valow;

p1.SetDefaultColor(GlobalColor("P"));
h1.SetDefaultColor(GlobalColor("H"));
l1.SetDefaultColor(GlobalColor("L"));
p1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
h1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
l1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot p2      = if v(2) > daysback or GetDay() == GetLastDay() - 1 and SecondsTillTime(0930) < 0 or GetDay() == GetLastDay()
               then Double.NaN
               else v(2).poc;
plot h2      = if v(2).thisDay > daysback or GetDay() == GetLastDay() - 1 and SecondsTillTime(0930) < 0 or GetDay() == GetLastDay()
               then Double.NaN
               else v(2).vahigh;
plot l2      = if v(2).thisDay > daysback or GetDay() == GetLastDay() - 1 and SecondsTillTime(0930) < 0 or GetDay() == GetLastDay()
               then Double.NaN
               else v(2).valow;

p2.SetDefaultColor(GlobalColor("P"));
h2.SetDefaultColor(GlobalColor("H"));
l2.SetDefaultColor(GlobalColor("L"));
p2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
h2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
l2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

input bubblemover = 3;
def b  = bubblemover;
def b1 = b + 1;
input showbubbles = yes;
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), p0[b1], "POC" , p0.TakeValueColor());
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), h0[b1], "VAH", h0.TakeValueColor());
AddChartBubble(showbubbles and IsNaN(close[b]) and !IsNaN(close[b1]), l0[b1], "VAL", l0.TakeValueColor());

#Volumeprofile script with Defaults to match extended POC plots x daysback
#
# TD Ameritrade IP Company, Inc. (c) 2010-2022
#

input pricePerRowHeightMode = {AUTOMATIC, default 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 = 3;
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 cond = count < count[1] + 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" = 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);
 
@SleepyZ Thank you very much for this indicator its awesome, is it possible to plot chart bubbles on the chart at the Naked POC's with the price associated with the Naked Poc's.

Narrowed the naked plots to POCs, one for volumeprofile and another for TPOprofile.

Ruby:
#VolumeProfile_Extended_POCs_HVAs_LVAs_for_x_Daysback_and_Limited_Plots_when_crossed
#More can be added using the logic below
#Sleepyz - usethinkscript request @yardlay
#Added HVA * LVA Lines and Plot limit when crossed for all 3;

script v {
    input daysback = 1;
    def volp = reference VolumeProfile("time per profile" = "DAY", "on expansion" = no, "price per row height mode" = "TICKSIZE");
    def ymd  = GetYYYYMMDD();
    def y    = if ymd != ymd[1] then y[1] + 1 else y[1];
    def pc   = if IsNaN(close)
                  then pc[1] else
               if y == HighestAll(y) - daysback
                  then volp  else
               pc[1];
    plot x    = if y > HighestAll(y) - daysback and Between(pc, low, high)
           then BarNumber() else Double.NaN;

    plot poc = if IsNaN(LowestAll(x))
           then pc
           else if BarNumber() > LowestAll(x)
           then Double.NaN
           else pc;
}

DefineGlobalColor("H", Color.YELLOW);
DefineGlobalColor("L", Color.YELLOW);
DefineGlobalColor("P", Color.DARK_RED);
DefineGlobalColor("NB", Color.WHITE);

plot v1 =  v(1).poc;
v1.AssignValueColor(if IsNaN(LowestAll(v(1).x)) then GlobalColor("NB") else GlobalColor("P"));
v1.SetPaintingStrategy(PaintingStrategy.DASHES);
v1.SetLineWeight(2);

plot v2 =  v(2).poc;
v2.AssignValueColor(if IsNaN(LowestAll(v(2).x)) then GlobalColor("NB") else GlobalColor("P"));
v2.SetPaintingStrategy(PaintingStrategy.DASHES);
v2.SetLineWeight(2);

plot v3 =  v(3).poc;
v3.AssignValueColor(if IsNaN(LowestAll(v(3).x)) then GlobalColor("NB") else GlobalColor("P"));
v3.SetPaintingStrategy(PaintingStrategy.DASHES);
v3.SetLineWeight(2);

plot v4 =  v(4).poc;
v4.AssignValueColor(if IsNaN(LowestAll(v(4).x)) then GlobalColor("NB") else GlobalColor("P"));
v4.SetPaintingStrategy(PaintingStrategy.DASHES);
v4.SetLineWeight(2);

plot v5 =  v(5).poc;
v5.AssignValueColor(if IsNaN(LowestAll(v(5).x)) then GlobalColor("NB") else GlobalColor("P"));
v5.SetPaintingStrategy(PaintingStrategy.DASHES);
v5.SetLineWeight(2);

plot v6 =  v(6).poc;
v6.AssignValueColor(if IsNaN(LowestAll(v(6).x)) then GlobalColor("NB") else GlobalColor("P"));
v6.SetPaintingStrategy(PaintingStrategy.DASHES);
v6.SetLineWeight(2);

plot v7 =  v(7).poc;
v7.AssignValueColor(if IsNaN(LowestAll(v(7).x)) then GlobalColor("NB") else GlobalColor("P"));
v7.SetPaintingStrategy(PaintingStrategy.DASHES);
v7.SetLineWeight(2);

plot v8 =  v(8).poc;
v8.AssignValueColor(if IsNaN(LowestAll(v(8).x)) then GlobalColor("NB") else GlobalColor("P"));
v8.SetPaintingStrategy(PaintingStrategy.DASHES);
v8.SetLineWeight(2);

plot v9 =  v(9).poc;
v9.AssignValueColor(if IsNaN(LowestAll(v(9).x)) then GlobalColor("NB") else GlobalColor("P"));
v9.SetPaintingStrategy(PaintingStrategy.DASHES);
v9.SetLineWeight(2);

plot v10 =  v(10).poc;
v10.AssignValueColor(if IsNaN(LowestAll(v(10).x)) then GlobalColor("NB") else GlobalColor("P"));
v10.SetPaintingStrategy(PaintingStrategy.DASHES);
v10.SetLineWeight(2);
;

AddLabel(1, "Most Recent Naked --> POC: " +
if IsNaN(LowestAll(v(1).x)) then "V1" else
if IsNaN(LowestAll(v(2).x)) then "V2" else
if IsNaN(LowestAll(v(3).x)) then "V3" else
if IsNaN(LowestAll(v(4).x)) then "V4" else
if IsNaN(LowestAll(v(5).x)) then "V5" else
if IsNaN(LowestAll(v(6).x)) then "V6" else
if IsNaN(LowestAll(v(7).x)) then "V7" else
if IsNaN(LowestAll(v(8).x)) then "V8" else
if IsNaN(LowestAll(v(9).x)) then "V9" else
if IsNaN(LowestAll(v(10).x)) then "V10" else
"NO V", GlobalColor("NB")
) ;

input showbubbles_nakedPOC = yes;
AddChartBubble(showbubbles_nakedPOC and !IsNaN(close) and IsNaN(close[-1]), v1, "V1 " + AsText(v1), GlobalColor("NB"));
AddChartBubble(showbubbles_nakedPOC and !IsNaN(close) and IsNaN(close[-1]), v2, "V2 " + AsText(v2), GlobalColor("NB"));
AddChartBubble(showbubbles_nakedPOC and !IsNaN(close) and IsNaN(close[-1]), v3, "V3 " + AsText(v3), GlobalColor("NB"));
AddChartBubble(showbubbles_nakedPOC and !IsNaN(close) and IsNaN(close[-1]), v4, "V4 " + AsText(v4), GlobalColor("NB"));
AddChartBubble(showbubbles_nakedPOC and !IsNaN(close) and IsNaN(close[-1]), v5, "V5 " + AsText(v5), GlobalColor("NB"));
AddChartBubble(showbubbles_nakedPOC and !IsNaN(close) and IsNaN(close[-1]), v6, "V6 " + AsText(v6), GlobalColor("NB"));
AddChartBubble(showbubbles_nakedPOC and !IsNaN(close) and IsNaN(close[-1]), v7, "V7 " + AsText(v7), GlobalColor("NB"));
AddChartBubble(showbubbles_nakedPOC and !IsNaN(close) and IsNaN(close[-1]), v8, "V8 " + AsText(v8), GlobalColor("NB"));
AddChartBubble(showbubbles_nakedPOC and !IsNaN(close) and IsNaN(close[-1]), v9, "V9 " + AsText(v9), GlobalColor("NB"));
AddChartBubble(showbubbles_nakedPOC and !IsNaN(close) and IsNaN(close[-1]), v10, "V10 " + AsText(v10), GlobalColor("NB"));

#TPO_Extended_POCs_HVAs_LVAs_for_x_Daysback_and_Limited_Plots_when_crossed
#More can be added using the logic below
#Sleepyz - usethinkscript request @yardlay
#Added HVA * LVA Lines and Plot limit when crossed for all 3;

script v {
input daysback = 1;
def volp = reference TPOProfile("time per profile" = "DAY", "on expansion" = no, "price per row height mode" = "TICKSIZE");
def ymd = GetYYYYMMDD();
def y = if ymd != ymd[1] then y[1] + 1 else y[1];
def pc = if IsNaN(close)
then pc[1] else
if y == HighestAll(y) - daysback
then volp else
pc[1];
plot x = if y > HighestAll(y) - daysback and Between(pc, low, high)
then BarNumber() else Double.NaN;

plot poc = if IsNaN(LowestAll(x))
then pc
else if BarNumber() > LowestAll(x)
then Double.NaN
else pc;
}
script vh {
input daysback = 1;
def volh = reference TPOProfile("time per profile" = "DAY", "on expansion" = no, "price per row height mode" = "TICKSIZE").VAHigh;
def ymd = GetYYYYMMDD();
def y = if ymd != ymd[1] then y[1] + 1 else y[1];
def ph = if IsNaN(close)
then ph[1] else
if y == HighestAll(y) - daysback
then volh else
ph[1];
plot x = if y > HighestAll(y) - daysback and Between(ph, low, high)
then BarNumber() else Double.NaN;

plot hva = if IsNaN(LowestAll(x))
then ph
else if BarNumber() > LowestAll(x)
then Double.NaN
else ph;
}
script vl {
input daysback = 1;
def voll = reference TPOProfile("time per profile" = "DAY", "on expansion" = no, "price per row height mode" = "TICKSIZE").VALow;
def ymd = GetYYYYMMDD();
def y = if ymd != ymd[1] then y[1] + 1 else y[1];
def pl = if IsNaN(close)
then pl[1] else
if y == HighestAll(y) - daysback
then voll else
pl[1];
plot x = if y > HighestAll(y) - daysback and Between(pl, low, high)
then BarNumber() else Double.NaN;

plot val = if IsNaN(LowestAll(x))
then pl
else if BarNumber() > LowestAll(x)
then Double.NaN
else pl;
}

DefineGlobalColor("H", Color.YELLOW);
DefineGlobalColor("L", Color.YELLOW);
DefineGlobalColor("P", Color.DARK_RED);
DefineGlobalColor("NB", Color.MAGENTA);

plot v1 = v(1).poc;
v1.AssignValueColor(if IsNaN(LowestAll(v(1).x)) then GlobalColor("NB") else GlobalColor("P"));
v1.SetPaintingStrategy(PaintingStrategy.DASHES);
v1.SetLineWeight(2);

plot v2 = v(2).poc;
v2.AssignValueColor(if IsNaN(LowestAll(v(2).x)) then GlobalColor("NB") else GlobalColor("P"));
v2.SetPaintingStrategy(PaintingStrategy.DASHES);
v2.SetLineWeight(2);

plot v3 = v(3).poc;
v3.AssignValueColor(if IsNaN(LowestAll(v(3).x)) then GlobalColor("NB") else GlobalColor("P"));
v3.SetPaintingStrategy(PaintingStrategy.DASHES);
v3.SetLineWeight(2);

plot v4 = v(4).poc;
v4.AssignValueColor(if IsNaN(LowestAll(v(4).x)) then GlobalColor("NB") else GlobalColor("P"));
v4.SetPaintingStrategy(PaintingStrategy.DASHES);
v4.SetLineWeight(2);

plot v5 = v(5).poc;
v5.AssignValueColor(if IsNaN(LowestAll(v(5).x)) then GlobalColor("NB") else GlobalColor("P"));
v5.SetPaintingStrategy(PaintingStrategy.DASHES);
v5.SetLineWeight(2);

plot v6 = v(6).poc;
v6.AssignValueColor(if IsNaN(LowestAll(v(6).x)) then GlobalColor("NB") else GlobalColor("P"));
v6.SetPaintingStrategy(PaintingStrategy.DASHES);
v6.SetLineWeight(2);

plot v7 = v(7).poc;
v7.AssignValueColor(if IsNaN(LowestAll(v(7).x)) then GlobalColor("NB") else GlobalColor("P"));
v7.SetPaintingStrategy(PaintingStrategy.DASHES);
v7.SetLineWeight(2);

plot v8 = v(8).poc;
v8.AssignValueColor(if IsNaN(LowestAll(v(8).x)) then GlobalColor("NB") else GlobalColor("P"));
v8.SetPaintingStrategy(PaintingStrategy.DASHES);
v8.SetLineWeight(2);

plot v9 = v(9).poc;
v9.AssignValueColor(if IsNaN(LowestAll(v(9).x)) then GlobalColor("NB") else GlobalColor("P"));
v9.SetPaintingStrategy(PaintingStrategy.DASHES);
v9.SetLineWeight(2);

plot v10 = v(10).poc;
v10.AssignValueColor(if IsNaN(LowestAll(v(10).x)) then GlobalColor("NB") else GlobalColor("P"));
v10.SetPaintingStrategy(PaintingStrategy.DASHES);
v10.SetLineWeight(2);
;

AddLabel(1, "Most Recent Naked --> POC: " +
if IsNaN(LowestAll(v(1).x)) then "V1" else
if IsNaN(LowestAll(v(2).x)) then "V2" else
if IsNaN(LowestAll(v(3).x)) then "V3" else
if IsNaN(LowestAll(v(4).x)) then "V4" else
if IsNaN(LowestAll(v(5).x)) then "V5" else
if IsNaN(LowestAll(v(6).x)) then "V6" else
if IsNaN(LowestAll(v(7).x)) then "V7" else
if IsNaN(LowestAll(v(8).x)) then "V8" else
if IsNaN(LowestAll(v(9).x)) then "V9" else
if IsNaN(LowestAll(v(10).x)) then "V10" else
"NO V",GlobalColor("NB"));

input showbubbles_nakedPOC = yes;
AddChartBubble(showbubbles_nakedPOC and !IsNaN(close) and isnan(close[-1]), v1, "T1 " + astext(v1), GlobalColor("NB"));
AddChartBubble(showbubbles_nakedPOC and !IsNaN(close) and isnan(close[-1]), v2, "T2 " + astext(v2), GlobalColor("NB"));
AddChartBubble(showbubbles_nakedPOC and !IsNaN(close) and isnan(close[-1]), v3, "T3 " + astext(v3), GlobalColor("NB"));
AddChartBubble(showbubbles_nakedPOC and !IsNaN(close) and isnan(close[-1]), v4, "T4 " + astext(v4), GlobalColor("NB"));
AddChartBubble(showbubbles_nakedPOC and !IsNaN(close) and isnan(close[-1]), v5, "T5 " + astext(v5), GlobalColor("NB"));
AddChartBubble(showbubbles_nakedPOC and !IsNaN(close) and isnan(close[-1]), v6, "T6 " + astext(v6), GlobalColor("NB"));
AddChartBubble(showbubbles_nakedPOC and !IsNaN(close) and isnan(close[-1]), v7, "T7 " + astext(v7), GlobalColor("NB"));
AddChartBubble(showbubbles_nakedPOC and !IsNaN(close) and isnan(close[-1]), v8, "T8 " + astext(v8), GlobalColor("NB"));
AddChartBubble(showbubbles_nakedPOC and !IsNaN(close) and isnan(close[-1]), v9, "T9 " + astext(v9), GlobalColor("NB"));
AddChartBubble(showbubbles_nakedPOC and !IsNaN(close) and isnan(close[-1]), v10, "T10 " + astext(v10), GlobalColor("NB"));
 
Hi,

I need some help redoing the VolumeProfile Indictor that comes with ThinkorSwim. Here's my ask:

I want to present the VolumeProfile indicator on a chart such that the POC of control line extends all the way to the right axis. Here's a pic to demonstrate.
Image

The first image shows a chart that displays the daily Volume Profile with the blue line being the POC. In the second image, I manually drew a line that extends the POC line to the right with the price displayed at the end. Can someone help me replicate this with the existing VolumeProfile indicator that comes with ThinkOrSwim? I'm not very savvy with ThinkOrSwim script. Greatly appreciate any help.
Hi,

I need some help redoing the VolumeProfile Indictor that comes with ThinkorSwim. Here's my ask:

I want to present the VolumeProfile indicator on a chart such that the POC of control line extends all the way to the right axis. Here's a pic to demonstrate.
Image

The first image shows a chart that displays the daily Volume Profile with the blue line being the POC. In the second image, I manually drew a line that extends the POC line to the right with the price displayed at the end. Can someone help me replicate this with the existing VolumeProfile indicator that comes with ThinkOrSwim? I'm not very savvy with ThinkOrSwim script. Greatly appreciate any help.
Here ya go dude, this is the best one Ive found so far....and its adjustable between monthly/weekly/daily, and just 1 line in the code will change the color of the extension. https://tos.mx/28UxbFy
 
Hello,

I copied a script that adds price into the bubble. It works fine when "daysback" is set to 1. When I changed the days back to "0", the price does not show. Instead, it shows "$ N/A." Would love some help with this. Thank you in advance.

Please reference code below.

input daysback = 0;
input showontodayonly = yes;
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) ;

def poc = if thisDay == daysback then reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no) else poc[1];
def vahigh = if thisDay == daysback then reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no).VAHigh else vahigh[1];
def valow = if thisDay == daysback then reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no).VALow else valow[1];

plot poc1 = if thisDay > daysback or
showontodayonly and getday()!=getlastday()
then Double.NaN
else poc;
plot vahigh1 = if thisDay > daysback or
showontodayonly and getday()!=getlastday()
then Double.NaN
else vahigh;
plot valow1 = if thisDay > daysback or
showontodayonly and getday()!=getlastday()
then Double.NaN
else valow;

poc1.setdefaultColor(color.cyan);
vahigh1.setdefaultColor(color.yellow);
valow1.setdefaultColor(color.yellow);

#Bubble
input showbubble = yes;
input bubblemover = 3;
input showValuesinBubble = yes;
def b = bubblemover;
def bm = bubblemover;
def bm1 = bm + 1;


addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), poc1[bm1],
if showValuesinBubble then "POC $" + poc1 else "POC", Color.PINK, yes);
addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), vahigh1[bm1],
if showValuesinBubble then "VAH $" + vahigh1 else "VAH", Color.GREEN, yes);
addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), valow1[bm1],
if showValuesinBubble then "VAL $" + valow1 else "VAL", Color.RED, yes);
 
Hello,

I copied a script that adds price into the bubble. It works fine when "daysback" is set to 1. When I changed the days back to "0", the price does not show. Instead, it shows "$ N/A." Would love some help with this. Thank you in advance.

Please reference code below.


def poc = if thisDay == daysback then reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no) else poc[1];
def vahigh = if thisDay == daysback then reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no).VAHigh else vahigh[1];
def valow = if thisDay == daysback then reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no).VALow else valow[1];

plot poc1 = if thisDay > daysback or
showontodayonly and getday()!=getlastday()
then Double.NaN
else poc;
plot vahigh1 = if thisDay > daysback or
showontodayonly and getday()!=getlastday()
then Double.NaN
else vahigh;
plot valow1 = if thisDay > daysback or
showontodayonly and getday()!=getlastday()
then Double.NaN
else valow;

poc1.setdefaultColor(color.cyan);
vahigh1.setdefaultColor(color.yellow);
valow1.setdefaultColor(color.yellow);

#Bubble
input showbubble = yes;
input bubblemover = 3;
input showValuesinBubble = yes;
def b = bubblemover;
def bm = bubblemover;
def bm1 = bm + 1;


addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), poc1[bm1],
if showValuesinBubble then "POC $" + poc1 else "POC", Color.PINK, yes);
addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), vahigh1[bm1],
if showValuesinBubble then "VAH $" + vahigh1 else "VAH", Color.GREEN, yes);
addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), valow1[bm1],
if showValuesinBubble then "VAL $" + valow1 else "VAL", Color.RED, yes);

This fixes it

addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), poc1[bm1],
if showValuesinBubble then "POC $" + poc1[bm1] else "POC", Color.PINK, yes);
addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), vahigh1[bm1],
if showValuesinBubble then "VAH $" + vahigh1[bm1] else "VAH", Color.GREEN, yes);
addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), valow1[bm1],
if showValuesinBubble then "VAL $" + valow1[bm1] else "VAL", Color.RED, yes);
else "VAL", Color.RED, yes);

Ruby:
input daysback = 0;
input showontodayonly = yes;
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) ;

def poc = if thisDay == daysback then reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no) else poc[1];
def vahigh = if thisDay == daysback then reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no).VAHigh else vahigh[1];
def valow = if thisDay == daysback then reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no).VALow else valow[1];

plot poc1 = if thisDay > daysback or
showontodayonly and getday()!=getlastday()
then Double.NaN
else poc;
plot vahigh1 = if thisDay > daysback or
showontodayonly and getday()!=getlastday()
then Double.NaN
else vahigh;
plot valow1 = if thisDay > daysback or
showontodayonly and getday()!=getlastday()
then Double.NaN
else valow;

poc1.setdefaultColor(color.cyan);
vahigh1.setdefaultColor(color.yellow);
valow1.setdefaultColor(color.yellow);

#Bubble
input showbubble = yes;
input bubblemover = 3;
input showValuesinBubble = yes;
def b = bubblemover;
def bm = bubblemover;
def bm1 = bm + 1;


addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), poc1[bm1],
if showValuesinBubble then "POC $" + poc1[bm1] else "POC", Color.PINK, yes);
addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), vahigh1[bm1],
if showValuesinBubble then "VAH $" + vahigh1[bm1] else "VAH", Color.GREEN, yes);
addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), valow1[bm1],
if showValuesinBubble then "VAL $" + valow1[bm1] else "VAL", Color.RED, yes);
 
This fixes it

addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), poc1[bm1],
if showValuesinBubble then "POC $" + poc1[bm1] else "POC", Color.PINK, yes);
addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), vahigh1[bm1],
if showValuesinBubble then "VAH $" + vahigh1[bm1] else "VAH", Color.GREEN, yes);
addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), valow1[bm1],
if showValuesinBubble then "VAL $" + valow1[bm1] else "VAL", Color.RED, yes);
else "VAL", Color.RED, yes);
Hello,

I am looking at the fixes or bold text in black. Can you explain what the error was? I keep staring at the code and I must be blind. I cant tell the difference between the previous code and the corrected one.
 
Hello,

I am looking at the fixes or bold text in black. Can you explain what the error was? I keep staring at the code and I must be blind. I cant tell the difference between the previous code and the corrected one.

Here is the original code portion you posted

addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), poc1[bm1],
if showValuesinBubble then "POC $" + poc1 else "POC", Color.PINK, yes);
addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), vahigh1[bm1],
if showValuesinBubble then "VAH $" + vahigh1 else "VAH", Color.GREEN, yes);
addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), valow1[bm1],
if showValuesinBubble then "VAL $" + valow1 else "VAL", Color.RED, yes);

Here is the revised

addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), poc1[bm1],
if showValuesinBubble then "POC $" + poc1[bm1] else "POC", Color.PINK, yes);
addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), vahigh1[bm1],
if showValuesinBubble then "VAH $" + vahigh1[bm1] else "VAH", Color.GREEN, yes);
addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), valow1[bm1],
if showValuesinBubble then "VAL $" + valow1[bm1] else "VAL", Color.RED, yes);
else "VAL", Color.RED, yes);

1. The revised one's bold [bm1] is part of the bubblemover code I often use.
2. The [bm1] is the way to reference back into the candles by the length input at bubblemover.
3. With a bubblemover of 3, for example, the part of each bubble's isnan(close[bm]) and !isnan(close[bm1]), is saying the if there is not any candles after the last one, go 3 spaces (bm = 3) to the right of the last candle and lookback 4 spaces (bm1 = 3 +1) to the last candle.
4. To find the poc value at the last candle, it needs to go back 4 spaces to get it. Without the [bm1] we probably should have expected a N/A for all of the bubble prices, because it would be looking to get it where there are no candles to reference.

The bubblemover code is an easy way to move all of the bubbles at once with the same code without having to type numbers instead of bm and bm1 as references.
 
This fixes it

addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), poc1[bm1],
if showValuesinBubble then "POC $" + poc1[bm1] else "POC", Color.PINK, yes);
addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), vahigh1[bm1],
if showValuesinBubble then "VAH $" + vahigh1[bm1] else "VAH", Color.GREEN, yes);
addchartBubble(showbubble and isnan(close[bm]) and !isnan(close[bm1]), valow1[bm1],
if showValuesinBubble then "VAL $" + valow1[bm1] else "VAL", Color.RED, yes);
else "VAL", Color.RED, yes);

Hello, Could the horizontal line plot the entire chart and across to the right side of the price on chart?
 
Hello, Could the horizontal line plot the entire chart and across to the right side of the price on chart?

Sure, see input extend_plot

Screenshot-2022-11-05-113844.png
Ruby:
input daysback = 0;
input showontodayonly = yes;
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) ;

def poc = if thisDay == daysback then reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no) else poc[1];
def vahigh = if thisDay == daysback then reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no).VAHigh else vahigh[1];
def valow = if thisDay == daysback then reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no).VALow else valow[1];

input extend_plot = yes;

def p1  = if extend_plot and IsNaN(close) then p1[1]
else if thisDay > daysback or
showontodayonly and GetDay() != GetLastDay()
then Double.NaN
else poc;
plot poc1 = p1;

def vh1 = if extend_plot and IsNaN(close) then vh1[1]
else if thisDay > daysback or
showontodayonly and GetDay() != GetLastDay()
then Double.NaN
else vahigh;
plot vahigh1 = vh1;

def vl1 = if extend_plot and IsNaN(close)
then vl1[1]
else if thisDay > daysback or
showontodayonly and GetDay() != GetLastDay()
then Double.NaN
else valow;
plot valow1 = vl1;

poc1.SetDefaultColor(Color.CYAN);
vahigh1.SetDefaultColor(Color.YELLOW);
valow1.SetDefaultColor(Color.YELLOW);

#Bubble
input showbubble = yes;
input bubblemover = 3;
input showValuesinBubble = yes;
def b = bubblemover;
def bm = bubblemover;
def bm1 = bm + 1;


AddChartBubble(showbubble and IsNaN(close[bm]) and !IsNaN(close[bm1]), poc1[bm1],
if showValuesinBubble then "POC $" + poc1[bm1] else "POC", Color.PINK, yes);
AddChartBubble(showbubble and IsNaN(close[bm]) and !IsNaN(close[bm1]), vahigh1[bm1],
if showValuesinBubble then "VAH $" + vahigh1[bm1] else "VAH", Color.GREEN, yes);
AddChartBubble(showbubble and IsNaN(close[bm]) and !IsNaN(close[bm1]), valow1[bm1],
if showValuesinBubble then "VAL $" + valow1[bm1] else "VAL", Color.RED, yes);
 
God, you are a genius!!!

Now I am able to toggle off horizontal line on chart for a cleaner look. Or visually see across the whole chart. I have a volume profile on the right of the chart and needed the extended line. You killed two birds with one stone. Thank you, thank you.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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