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...
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 extended plots of the POC of the Volumeprofile indicator, also included in the script. You can add more extended plots by using the logic used to create the 10 included in the script. You could also change the def volp to be one of the other profile plots available in the box to the right when you click on the reference volumeprofile portion of the def volp.

Capture.jpg
Ruby:
#Extended POCs for x Daysback
#More can be added using the logic below
#Sleepyz - usethinkscript request @yardlay

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 poc = pc;

}

plot v1 =  v(1).poc;
v1.SetDefaultColor(Color.RED);
v1.SetPaintingStrategy(PaintingStrategy.DASHES);
v1.SetLineWeight(2);

plot v2 =  v(2).poc;
v2.SetDefaultColor(Color.RED);
v2.SetPaintingStrategy(PaintingStrategy.DASHES);
v2.SetLineWeight(2);

plot v3 =  v(3).poc;
v3.SetDefaultColor(Color.RED);
v3.SetPaintingStrategy(PaintingStrategy.DASHES);
v3.SetLineWeight(2);

plot v4 =  v(4).poc;
v4.SetDefaultColor(Color.RED);
v4.SetPaintingStrategy(PaintingStrategy.DASHES);
v4.SetLineWeight(2);

plot v5 =  v(5).poc;
v5.SetDefaultColor(Color.RED);
v5.SetPaintingStrategy(PaintingStrategy.DASHES);
v5.SetLineWeight(2);

plot v6 =  v(6).poc;
v6.SetDefaultColor(Color.RED);
v6.SetPaintingStrategy(PaintingStrategy.DASHES);
v6.SetLineWeight(2);

plot v7 =  v(7).poc;
v7.SetDefaultColor(Color.RED);
v7.SetPaintingStrategy(PaintingStrategy.DASHES);
v7.SetLineWeight(2);

plot v8 =  v(8).poc;
v8.SetDefaultColor(Color.RED);
v8.SetPaintingStrategy(PaintingStrategy.DASHES);
v8.SetLineWeight(2);

plot v9 =  v(9).poc;
v9.SetDefaultColor(Color.RED);
v9.SetPaintingStrategy(PaintingStrategy.DASHES);
v9.SetLineWeight(2);

plot v10 =  v(10).poc;
v10.SetDefaultColor(Color.RED);
v10.SetPaintingStrategy(PaintingStrategy.DASHES);
v10.SetLineWeight(2);
;


#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 = 1000;
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);
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

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

Just saw your request.

This script combines x number of extended plots of the POC of the Volumeprofile indicator, also included in the script. You can add more extended plots by using the logic used to create the 10 included in the script. You could also change the def volp to be one of the other profile plots available in the box to the right when you click on the reference volumeprofile portion of the def volp.
Thanks for posting the Extended POC script. Very helpful. Is it possible to write a code that automatically cancels the POC once it is no longer a Virgin POC? Also looking to extend the Value Area Highs & Value Area Lows in the same manner and canceled when touched by price as well.
 
Thanks for posting the Extended POC script. Very helpful. Is it possible to write a code that automatically cancels the POC once it is no longer a Virgin POC? Also looking to extend the Value Area Highs & Value Area Lows in the same manner and canceled when touched by price as well.

Added HVA, LVA plots to POC plots, all extended to the right unless crossed

Capture.jpg
Ruby:
#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];
    def 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 VolumeProfile("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];
    def 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 VolumeProfile("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];
    def 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);

plot v1 =  v(1).poc;
v1.SetDefaultColor(Color.RED);
v1.SetPaintingStrategy(PaintingStrategy.DASHES);
v1.SetLineWeight(2);

plot v2 =  v(2).poc;
v2.SetDefaultColor(Color.RED);
v2.SetPaintingStrategy(PaintingStrategy.DASHES);
v2.SetLineWeight(2);

plot v3 =  v(3).poc;
v3.SetDefaultColor(Color.RED);
v3.SetPaintingStrategy(PaintingStrategy.DASHES);
v3.SetLineWeight(2);

plot v4 =  v(4).poc;
v4.SetDefaultColor(Color.RED);
v4.SetPaintingStrategy(PaintingStrategy.DASHES);
v4.SetLineWeight(2);

plot v5 =  v(5).poc;
v5.SetDefaultColor(Color.RED);
v5.SetPaintingStrategy(PaintingStrategy.DASHES);
v5.SetLineWeight(2);

plot v6 =  v(6).poc;
v6.SetDefaultColor(Color.RED);
v6.SetPaintingStrategy(PaintingStrategy.DASHES);
v6.SetLineWeight(2);

plot v7 =  v(7).poc;
v7.SetDefaultColor(Color.RED);
v7.SetPaintingStrategy(PaintingStrategy.DASHES);
v7.SetLineWeight(2);

plot v8 =  v(8).poc;
v8.SetDefaultColor(Color.RED);
v8.SetPaintingStrategy(PaintingStrategy.DASHES);
v8.SetLineWeight(2);

plot v9 =  v(9).poc;
v9.SetDefaultColor(Color.RED);
v9.SetPaintingStrategy(PaintingStrategy.DASHES);
v9.SetLineWeight(2);

plot v10 =  v(10).poc;
v10.SetDefaultColor(Color.RED);
v10.SetPaintingStrategy(PaintingStrategy.DASHES);
v10.SetLineWeight(2);
;


plot vh1 =  vh(1);
vh1.SetDefaultColor(globalColor("H"));
vh1.SetPaintingStrategy(PaintingStrategy.DASHES);
vh1.SetLineWeight(2);

plot vh2 =  vh(2);
vh2.SetDefaultColor(globalColor("H"));
vh2.SetPaintingStrategy(PaintingStrategy.DASHES);
vh2.SetLineWeight(2);

plot vh3 =  vh(3);
v3.SetDefaultColor(globalColor("H"));
v3.SetPaintingStrategy(PaintingStrategy.DASHES);
v3.SetLineWeight(2);

plot vh4 =  vh(4);
vh4.SetDefaultColor(globalColor("H"));
vh4.SetPaintingStrategy(PaintingStrategy.DASHES);
vh4.SetLineWeight(2);

plot vh5 =  vh(5);
vh5.SetDefaultColor(globalColor("H"));
vh5.SetPaintingStrategy(PaintingStrategy.DASHES);
vh5.SetLineWeight(2);

plot vh6 =  vh(6);
vh6.SetDefaultColor(globalColor("H"));
vh6.SetPaintingStrategy(PaintingStrategy.DASHES);
vh6.SetLineWeight(2);

plot vh7 =  vh(7);
vh7.SetDefaultColor(globalColor("H"));
vh7.SetPaintingStrategy(PaintingStrategy.DASHES);
vh7.SetLineWeight(2);

plot vh8 =  vh(8);
vh8.SetDefaultColor(globalColor("H"));
vh8.SetPaintingStrategy(PaintingStrategy.DASHES);
vh8.SetLineWeight(2);

plot vh9 =  vh(9);
vh9.SetDefaultColor(globalColor("H"));
vh9.SetPaintingStrategy(PaintingStrategy.DASHES);
vh9.SetLineWeight(2);

plot vh10 =  vh(10);
vh10.SetDefaultColor(globalColor("H"));
vh10.SetPaintingStrategy(PaintingStrategy.DASHES);
vh10.SetLineWeight(2);
;

plot vl1 =  vl(1);
vl1.SetDefaultColor(globalColor("L"));
vl1.SetPaintingStrategy(PaintingStrategy.DASHES);
vl1.SetLineWeight(2);

plot vl2 =  vl(2);
vl2.SetDefaultColor(globalColor("L"));
vl2.SetPaintingStrategy(PaintingStrategy.DASHES);
vl2.SetLineWeight(2);

plot vl3 =  vl(3);
vl3.SetDefaultColor(globalColor("L"));
vl3.SetPaintingStrategy(PaintingStrategy.DASHES);
vl3.SetLineWeight(2);

plot vl4 =  vl(4);
vl4.SetDefaultColor(globalColor("L"));
vl4.SetPaintingStrategy(PaintingStrategy.DASHES);
vl4.SetLineWeight(2);

plot vl5 =  vl(5);
vl5.SetDefaultColor(globalColor("L"));
vl5.SetPaintingStrategy(PaintingStrategy.DASHES);
vl5.SetLineWeight(2);

plot vl6 =  vl(6);
vl6.SetDefaultColor(globalColor("L"));
vl6.SetPaintingStrategy(PaintingStrategy.DASHES);
vl6.SetLineWeight(2);

plot vl7 =  vl(7);
vl7.SetDefaultColor(globalColor("L"));
vl7.SetPaintingStrategy(PaintingStrategy.DASHES);
vl7.SetLineWeight(2);

plot vl8 =  vl(8);
vl8.SetDefaultColor(globalColor("L"));
vl8.SetPaintingStrategy(PaintingStrategy.DASHES);
vl8.SetLineWeight(2);

plot vl9 =  vl(9);
vl9.SetDefaultColor(globalColor("L"));
vl9.SetPaintingStrategy(PaintingStrategy.DASHES);
vl9.SetLineWeight(2);

plot vl10 =  vl(10);
vl10.SetDefaultColor(globalColor("L"));
vl10.SetPaintingStrategy(PaintingStrategy.DASHES);
vl10.SetLineWeight(2);
;

#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 = 1000;
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);
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();
 
Just saw your request.

This script combines x number of extended plots of the POC of the Volumeprofile indicator, also included in the script. You can add more extended plots by using the logic used to create the 10 included in the script. You could also change the def volp to be one of the other profile plots available in the box to the right when you click on the reference volumeprofile portion of the def volp.
This is amazing what you did here.
Is there any way it can be done to TPO profile instead of VP?
I was trying to play with the code myself but wasn't sure what to do
 
This is amazing what you did here.
Is there any way it can be done to TPO profile instead of VP?
I was trying to play with the code myself but wasn't sure what to do

Sure

Capture.jpg
Ruby:
#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];
    def 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];
    def 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];
    def 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);

plot v1 =  v(1).poc;
v1.SetDefaultColor(Color.RED);
v1.SetPaintingStrategy(PaintingStrategy.DASHES);
v1.SetLineWeight(2);

plot v2 =  v(2).poc;
v2.SetDefaultColor(Color.RED);
v2.SetPaintingStrategy(PaintingStrategy.DASHES);
v2.SetLineWeight(2);

plot v3 =  v(3).poc;
v3.SetDefaultColor(Color.RED);
v3.SetPaintingStrategy(PaintingStrategy.DASHES);
v3.SetLineWeight(2);

plot v4 =  v(4).poc;
v4.SetDefaultColor(Color.RED);
v4.SetPaintingStrategy(PaintingStrategy.DASHES);
v4.SetLineWeight(2);

plot v5 =  v(5).poc;
v5.SetDefaultColor(Color.RED);
v5.SetPaintingStrategy(PaintingStrategy.DASHES);
v5.SetLineWeight(2);

plot v6 =  v(6).poc;
v6.SetDefaultColor(Color.RED);
v6.SetPaintingStrategy(PaintingStrategy.DASHES);
v6.SetLineWeight(2);

plot v7 =  v(7).poc;
v7.SetDefaultColor(Color.RED);
v7.SetPaintingStrategy(PaintingStrategy.DASHES);
v7.SetLineWeight(2);

plot v8 =  v(8).poc;
v8.SetDefaultColor(Color.RED);
v8.SetPaintingStrategy(PaintingStrategy.DASHES);
v8.SetLineWeight(2);

plot v9 =  v(9).poc;
v9.SetDefaultColor(Color.RED);
v9.SetPaintingStrategy(PaintingStrategy.DASHES);
v9.SetLineWeight(2);

plot v10 =  v(10).poc;
v10.SetDefaultColor(Color.RED);
v10.SetPaintingStrategy(PaintingStrategy.DASHES);
v10.SetLineWeight(2);
;


plot vh1 =  vh(1);
vh1.SetDefaultColor(globalColor("H"));
vh1.SetPaintingStrategy(PaintingStrategy.DASHES);
vh1.SetLineWeight(2);

plot vh2 =  vh(2);
vh2.SetDefaultColor(globalColor("H"));
vh2.SetPaintingStrategy(PaintingStrategy.DASHES);
vh2.SetLineWeight(2);

plot vh3 =  vh(3);
v3.SetDefaultColor(globalColor("H"));
v3.SetPaintingStrategy(PaintingStrategy.DASHES);
v3.SetLineWeight(2);

plot vh4 =  vh(4);
vh4.SetDefaultColor(globalColor("H"));
vh4.SetPaintingStrategy(PaintingStrategy.DASHES);
vh4.SetLineWeight(2);

plot vh5 =  vh(5);
vh5.SetDefaultColor(globalColor("H"));
vh5.SetPaintingStrategy(PaintingStrategy.DASHES);
vh5.SetLineWeight(2);

plot vh6 =  vh(6);
vh6.SetDefaultColor(globalColor("H"));
vh6.SetPaintingStrategy(PaintingStrategy.DASHES);
vh6.SetLineWeight(2);

plot vh7 =  vh(7);
vh7.SetDefaultColor(globalColor("H"));
vh7.SetPaintingStrategy(PaintingStrategy.DASHES);
vh7.SetLineWeight(2);

plot vh8 =  vh(8);
vh8.SetDefaultColor(globalColor("H"));
vh8.SetPaintingStrategy(PaintingStrategy.DASHES);
vh8.SetLineWeight(2);

plot vh9 =  vh(9);
vh9.SetDefaultColor(globalColor("H"));
vh9.SetPaintingStrategy(PaintingStrategy.DASHES);
vh9.SetLineWeight(2);

plot vh10 =  vh(10);
vh10.SetDefaultColor(globalColor("H"));
vh10.SetPaintingStrategy(PaintingStrategy.DASHES);
vh10.SetLineWeight(2);
;

plot vl1 =  vl(1);
vl1.SetDefaultColor(globalColor("L"));
vl1.SetPaintingStrategy(PaintingStrategy.DASHES);
vl1.SetLineWeight(2);

plot vl2 =  vl(2);
vl2.SetDefaultColor(globalColor("L"));
vl2.SetPaintingStrategy(PaintingStrategy.DASHES);
vl2.SetLineWeight(2);

plot vl3 =  vl(3);
vl3.SetDefaultColor(globalColor("L"));
vl3.SetPaintingStrategy(PaintingStrategy.DASHES);
vl3.SetLineWeight(2);

plot vl4 =  vl(4);
vl4.SetDefaultColor(globalColor("L"));
vl4.SetPaintingStrategy(PaintingStrategy.DASHES);
vl4.SetLineWeight(2);

plot vl5 =  vl(5);
vl5.SetDefaultColor(globalColor("L"));
vl5.SetPaintingStrategy(PaintingStrategy.DASHES);
vl5.SetLineWeight(2);

plot vl6 =  vl(6);
vl6.SetDefaultColor(globalColor("L"));
vl6.SetPaintingStrategy(PaintingStrategy.DASHES);
vl6.SetLineWeight(2);

plot vl7 =  vl(7);
vl7.SetDefaultColor(globalColor("L"));
vl7.SetPaintingStrategy(PaintingStrategy.DASHES);
vl7.SetLineWeight(2);

plot vl8 =  vl(8);
vl8.SetDefaultColor(globalColor("L"));
vl8.SetPaintingStrategy(PaintingStrategy.DASHES);
vl8.SetLineWeight(2);

plot vl9 =  vl(9);
vl9.SetDefaultColor(globalColor("L"));
vl9.SetPaintingStrategy(PaintingStrategy.DASHES);
vl9.SetLineWeight(2);

plot vl10 =  vl(10);
vl10.SetDefaultColor(globalColor("L"));
vl10.SetPaintingStrategy(PaintingStrategy.DASHES);
vl10.SetLineWeight(2);
;

#TPOprofile 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 = 1000;
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 tpo = timeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
def con = compoundValue(1, onExpansion, no);
def pc = if IsNaN(tpo.getPointOfControl()) and con then pc[1] else tpo.getPointOfControl();
def hVA = if IsNaN(tpo.getHighestValueArea()) and con then hVA[1] else tpo.getHighestValueArea();
def lVA = if IsNaN(tpo.getLowestValueArea()) and con then lVA[1] else tpo.getLowestValueArea();

def hProfile = if IsNaN(tpo.getHighest()) and con then hProfile[1] else tpo.getHighest();
def lProfile = if IsNaN(tpo.getLowest()) and con then lProfile[1] else tpo.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));

tpo.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();
 
One change that would be enormously helpful is to have UNTOUCHED POCs (extended ones) change to another color (user defined). Is that doable? I have modified thinkscript before and have a little knowledge...but not good enough to tackle this one.
 
One change that would be enormously helpful is to have UNTOUCHED POCs (extended ones) change to another color (user defined). Is that doable? I have modified thinkscript before and have a little knowledge...but not good enough to tackle this one.

You can change the colors at the input screen. Untouched lines are currently Magenta.

Capture.jpg
Ruby:
#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);
;


plot vh1 =  vh(1).hva;
vh1.AssignValueColor(if IsNaN(LowestAll(vh(1).x)) then GlobalColor("NB") else GlobalColor("H"));
vh1.SetPaintingStrategy(PaintingStrategy.DASHES);
vh1.SetLineWeight(2);

plot vh2 =  vh(2).hva;
vh2.AssignValueColor(if IsNaN(LowestAll(vh(2).x)) then GlobalColor("NB") else GlobalColor("H"));
vh2.SetPaintingStrategy(PaintingStrategy.DASHES);
vh2.SetLineWeight(2);

plot vh3 =  vh(3).hva;
v3.AssignValueColor(if IsNaN(LowestAll(vh(3).x)) then GlobalColor("NB") else GlobalColor("H"));
v3.SetPaintingStrategy(PaintingStrategy.DASHES);
v3.SetLineWeight(2);

plot vh4 =  vh(4).hva;
vh4.AssignValueColor(if IsNaN(LowestAll(vh(4).x)) then GlobalColor("NB") else GlobalColor("H"));
vh4.SetPaintingStrategy(PaintingStrategy.DASHES);
vh4.SetLineWeight(2);

plot vh5 =  vh(5).hva;
vh5.AssignValueColor(if IsNaN(LowestAll(vh(5).x)) then GlobalColor("NB") else GlobalColor("H"));
vh5.SetPaintingStrategy(PaintingStrategy.DASHES);
vh5.SetLineWeight(2);

plot vh6 =  vh(6).hva;
vh6.AssignValueColor(if IsNaN(LowestAll(vh(6).x)) then GlobalColor("NB") else GlobalColor("H"));
vh6.SetPaintingStrategy(PaintingStrategy.DASHES);
vh6.SetLineWeight(2);

plot vh7 =  vh(7).hva;
vh7.AssignValueColor(if IsNaN(LowestAll(vh(7).x)) then GlobalColor("NB") else GlobalColor("H"));
vh7.SetPaintingStrategy(PaintingStrategy.DASHES);
vh7.SetLineWeight(2);

plot vh8 =  vh(8).hva;
vh8.AssignValueColor(if IsNaN(LowestAll(vh(8).x)) then GlobalColor("NB") else GlobalColor("H"));
vh8.SetPaintingStrategy(PaintingStrategy.DASHES);
vh8.SetLineWeight(2);

plot vh9 =  vh(9).hva;
vh9.AssignValueColor(if IsNaN(LowestAll(vh(9).x)) then GlobalColor("NB") else GlobalColor("H"));
vh9.SetPaintingStrategy(PaintingStrategy.DASHES);
vh9.SetLineWeight(2);

plot vh10 =  vh(10).hva;
vh10.AssignValueColor(if IsNaN(LowestAll(vh(10).x)) then GlobalColor("NB") else GlobalColor("H"));
vh10.SetPaintingStrategy(PaintingStrategy.DASHES);
vh10.SetLineWeight(2);
;

plot vl1 =  vl(1).val;
vl1.AssignValueColor(if IsNaN(LowestAll(vl(1).x)) then GlobalColor("NB") else GlobalColor("L"));
vl1.SetPaintingStrategy(PaintingStrategy.DASHES);
vl1.SetLineWeight(2);

plot vl2 =  vl(2).val;
vl2.AssignValueColor(if IsNaN(LowestAll(vl(2).x)) then GlobalColor("NB") else GlobalColor("L"));
vl2.SetPaintingStrategy(PaintingStrategy.DASHES);
vl2.SetLineWeight(2);

plot vl3 =  vl(3).val;
vl3.AssignValueColor(if IsNaN(LowestAll(vl(3).x)) then GlobalColor("NB") else GlobalColor("L"));
vl3.SetPaintingStrategy(PaintingStrategy.DASHES);
vl3.SetLineWeight(2);

plot vl4 =  vl(4);
vl4.AssignValueColor(if IsNaN(LowestAll(vl(4).x)) then GlobalColor("NB") else GlobalColor("L"));
vl4.SetPaintingStrategy(PaintingStrategy.DASHES);
vl4.SetLineWeight(2);

plot vl5 =  vl(5).val;
vl5.AssignValueColor(if IsNaN(LowestAll(vl(5).x)) then GlobalColor("NB") else GlobalColor("L"));
vl5.SetPaintingStrategy(PaintingStrategy.DASHES);
vl5.SetLineWeight(2);

plot vl6 =  vl(6).val;
vl6.AssignValueColor(if IsNaN(LowestAll(vl(6).x)) then GlobalColor("NB") else GlobalColor("L"));
vl6.SetPaintingStrategy(PaintingStrategy.DASHES);
vl6.SetLineWeight(2);

plot vl7 =  vl(7).val;
vl7.AssignValueColor(if IsNaN(LowestAll(vl(7).x)) then GlobalColor("NB") else GlobalColor("L"));
vl7.SetPaintingStrategy(PaintingStrategy.DASHES);
vl7.SetLineWeight(2);

plot vl8 =  vl(8).val;
vl8.AssignValueColor(if IsNaN(LowestAll(vl(8).x)) then GlobalColor("NB") else GlobalColor("L"));
vl8.SetPaintingStrategy(PaintingStrategy.DASHES);
vl8.SetLineWeight(2);

plot vl9 =  vl(9).val;
vl9.AssignValueColor(if IsNaN(LowestAll(vl(9).x)) then GlobalColor("NB") else GlobalColor("L"));
vl9.SetPaintingStrategy(PaintingStrategy.DASHES);
vl9.SetLineWeight(2);

plot vl10 =  vl(10).val;
vl10.AssignValueColor(if IsNaN(LowestAll(vl(10).x)) then GlobalColor("NB") else GlobalColor("L"));
vl10.SetPaintingStrategy(PaintingStrategy.DASHES);
vl10.SetLineWeight(2);
;

#TPOprofile 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 = 1000;
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 tpo = TimeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
def con = CompoundValue(1, onExpansion, no);
def pc = if IsNaN(tpo.GetPointOfControl()) and con then pc[1] else tpo.GetPointOfControl();
def hVA = if IsNaN(tpo.GetHighestValueArea()) and con then hVA[1] else tpo.GetHighestValueArea();
def lVA = if IsNaN(tpo.GetLowestValueArea()) and con then lVA[1] else tpo.GetLowestValueArea();

def hProfile = if IsNaN(tpo.GetHighest()) and con then hProfile[1] else tpo.GetHighest();
def lProfile = if IsNaN(tpo.GetLowest()) and con then lProfile[1] else tpo.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));

tpo.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();
 
Understood. However, as far as I can tell you can change V1, V2 , V3, etc....to a color but that color is the same for all POCs and that color is extended. Sorry if I'm incorrect. I would like to have one color for POCs in general...and another color for extended POCs....it's great using as is though!
 
Understood. However, as far as I can tell you can change V1, V2 , V3, etc....to a color but that color is the same for all POCs and that color is extended. Sorry if I'm incorrect. I would like to have one color for POCs in general...and another color for extended POCs....it's great using as is though!
Each POC, HVA, and LVA has a separate color. Those colors extend until Touched. All 3 have a Magenta color if Unttouched. All colors can be changed to your liking at the input screen.

The code does what you requested. Pehaps the colors of the POC (dark_red) and Untouched (Magenta) are too close for you to distinguish. So change this part of the code
Code:
DefineGlobalColor("P", Color.DARK_RED);
to
Code:
DefineGlobalColor("P", Color.white);
 
Which plot is the most recent (for scanning purposes)?

Added a Label to the code to display the plot name for the most recent naked POC, VAH and VAL,
[edit: added price to label @user request on 11.11.2022]

Capture.jpg

Ruby:
#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;
#Added Price to Most Recent Naked Labels

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: " + v1 else
if IsNaN(LowestAll(v(2).x)) then "V2: " + v2 else
if IsNaN(LowestAll(v(3).x)) then "V3: " + v3 else
if IsNaN(LowestAll(v(4).x)) then "V4: " + v4 else
if IsNaN(LowestAll(v(5).x)) then "V5: " + v5 else
if IsNaN(LowestAll(v(6).x)) then "V6: " + v6 else
if IsNaN(LowestAll(v(7).x)) then "V7: " + v7 else
if IsNaN(LowestAll(v(8).x)) then "V8: " + v8 else
if IsNaN(LowestAll(v(9).x)) then "V9: " + v9 else
if IsNaN(LowestAll(v(10).x)) then "V10: " + v10 else
"NO V", Color.YELLOW) ;

plot vh1 =  vh(1).hva;
vh1.AssignValueColor(if IsNaN(LowestAll(vh(1).x)) then GlobalColor("NB") else GlobalColor("H"));
vh1.SetPaintingStrategy(PaintingStrategy.DASHES);
vh1.SetLineWeight(2);

plot vh2 =  vh(2).hva;
vh2.AssignValueColor(if IsNaN(LowestAll(vh(2).x)) then GlobalColor("NB") else GlobalColor("H"));
vh2.SetPaintingStrategy(PaintingStrategy.DASHES);
vh2.SetLineWeight(2);

plot vh3 =  vh(3).hva;
v3.AssignValueColor(if IsNaN(LowestAll(vh(3).x)) then GlobalColor("NB") else GlobalColor("H"));
v3.SetPaintingStrategy(PaintingStrategy.DASHES);
v3.SetLineWeight(2);

plot vh4 =  vh(4).hva;
vh4.AssignValueColor(if IsNaN(LowestAll(vh(4).x)) then GlobalColor("NB") else GlobalColor("H"));
vh4.SetPaintingStrategy(PaintingStrategy.DASHES);
vh4.SetLineWeight(2);

plot vh5 =  vh(5).hva;
vh5.AssignValueColor(if IsNaN(LowestAll(vh(5).x)) then GlobalColor("NB") else GlobalColor("H"));
vh5.SetPaintingStrategy(PaintingStrategy.DASHES);
vh5.SetLineWeight(2);

plot vh6 =  vh(6).hva;
vh6.AssignValueColor(if IsNaN(LowestAll(vh(6).x)) then GlobalColor("NB") else GlobalColor("H"));
vh6.SetPaintingStrategy(PaintingStrategy.DASHES);
vh6.SetLineWeight(2);

plot vh7 =  vh(7).hva;
vh7.AssignValueColor(if IsNaN(LowestAll(vh(7).x)) then GlobalColor("NB") else GlobalColor("H"));
vh7.SetPaintingStrategy(PaintingStrategy.DASHES);
vh7.SetLineWeight(2);

plot vh8 =  vh(8).hva;
vh8.AssignValueColor(if IsNaN(LowestAll(vh(8).x)) then GlobalColor("NB") else GlobalColor("H"));
vh8.SetPaintingStrategy(PaintingStrategy.DASHES);
vh8.SetLineWeight(2);

plot vh9 =  vh(9).hva;
vh9.AssignValueColor(if IsNaN(LowestAll(vh(9).x)) then GlobalColor("NB") else GlobalColor("H"));
vh9.SetPaintingStrategy(PaintingStrategy.DASHES);
vh9.SetLineWeight(2);

plot vh10 =  vh(10).hva;
vh10.AssignValueColor(if IsNaN(LowestAll(vh(10).x)) then GlobalColor("NB") else GlobalColor("H"));
vh10.SetPaintingStrategy(PaintingStrategy.DASHES);
vh10.SetLineWeight(2);
;

AddLabel(1, " VAH: " +
if IsNaN(LowestAll(vh(1).x)) then "VH1: " + vh1 else
if IsNaN(LowestAll(vh(2).x)) then "VH2: " + vh2 else
if IsNaN(LowestAll(vh(3).x)) then "VH3: " + vh3 else
if IsNaN(LowestAll(vh(4).x)) then "VH4: " + vh4 else
if IsNaN(LowestAll(vh(5).x)) then "VH5: " + vh5 else
if IsNaN(LowestAll(vh(6).x)) then "VH6: " + vh6 else
if IsNaN(LowestAll(vh(7).x)) then "VH7: " + vh7 else
if IsNaN(LowestAll(vh(8).x)) then "VH8: " + vh8 else
if IsNaN(LowestAll(vh(9).x)) then "VH9: " + vh9 else
if IsNaN(LowestAll(vh(10).x)) then "VH10: " + vh10 else
"NO VH", Color.WHITE) ;


plot vl1 =  vl(1).val;
vl1.AssignValueColor(if IsNaN(LowestAll(vl(1).x)) then GlobalColor("NB") else GlobalColor("L"));
vl1.SetPaintingStrategy(PaintingStrategy.DASHES);
vl1.SetLineWeight(2);

plot vl2 =  vl(2).val;
vl2.AssignValueColor(if IsNaN(LowestAll(vl(2).x)) then GlobalColor("NB") else GlobalColor("L"));
vl2.SetPaintingStrategy(PaintingStrategy.DASHES);
vl2.SetLineWeight(2);

plot vl3 =  vl(3).val;
vl3.AssignValueColor(if IsNaN(LowestAll(vl(3).x)) then GlobalColor("NB") else GlobalColor("L"));
vl3.SetPaintingStrategy(PaintingStrategy.DASHES);
vl3.SetLineWeight(2);

plot vl4 =  vl(4);
vl4.AssignValueColor(if IsNaN(LowestAll(vl(4).x)) then GlobalColor("NB") else GlobalColor("L"));
vl4.SetPaintingStrategy(PaintingStrategy.DASHES);
vl4.SetLineWeight(2);

plot vl5 =  vl(5).val;
vl5.AssignValueColor(if IsNaN(LowestAll(vl(5).x)) then GlobalColor("NB") else GlobalColor("L"));
vl5.SetPaintingStrategy(PaintingStrategy.DASHES);
vl5.SetLineWeight(2);

plot vl6 =  vl(6).val;
vl6.AssignValueColor(if IsNaN(LowestAll(vl(6).x)) then GlobalColor("NB") else GlobalColor("L"));
vl6.SetPaintingStrategy(PaintingStrategy.DASHES);
vl6.SetLineWeight(2);

plot vl7 =  vl(7).val;
vl7.AssignValueColor(if IsNaN(LowestAll(vl(7).x)) then GlobalColor("NB") else GlobalColor("L"));
vl7.SetPaintingStrategy(PaintingStrategy.DASHES);
vl7.SetLineWeight(2);

plot vl8 =  vl(8).val;
vl8.AssignValueColor(if IsNaN(LowestAll(vl(8).x)) then GlobalColor("NB") else GlobalColor("L"));
vl8.SetPaintingStrategy(PaintingStrategy.DASHES);
vl8.SetLineWeight(2);

plot vl9 =  vl(9).val;
vl9.AssignValueColor(if IsNaN(LowestAll(vl(9).x)) then GlobalColor("NB") else GlobalColor("L"));
vl9.SetPaintingStrategy(PaintingStrategy.DASHES);
vl9.SetLineWeight(2);

plot vl10 =  vl(10).val;
vl10.AssignValueColor(if IsNaN(LowestAll(vl(10).x)) then GlobalColor("NB") else GlobalColor("L"));
vl10.SetPaintingStrategy(PaintingStrategy.DASHES);
vl10.SetLineWeight(2);
;

AddLabel(1, " VAL: " +
if IsNaN(LowestAll(vl(1).x)) then "VL1: " + vl1 else
if IsNaN(LowestAll(vl(2).x)) then "VL2: " + vl2 else
if IsNaN(LowestAll(vl(3).x)) then "VL3: " + vl3 else
if IsNaN(LowestAll(vl(4).x)) then "VL4: " + vl4 else
if IsNaN(LowestAll(vl(5).x)) then "VL5: " + vl5 else
if IsNaN(LowestAll(vl(6).x)) then "VL6: " + vl6 else
if IsNaN(LowestAll(vl(7).x)) then "VL7: " + vl7 else
if IsNaN(LowestAll(vl(8).x)) then "VL8: " + vl8 else
if IsNaN(LowestAll(vl(9).x)) then "VL9: " + vl9 else
if IsNaN(LowestAll(vl(10).x)) then "VL10: " + vl10 else
"NO VL", Color.YELLOW) ;


#TPOprofile 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 = 1000;
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 tpo = TimeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
def con = CompoundValue(1, onExpansion, no);
def pc = if IsNaN(tpo.GetPointOfControl()) and con then pc[1] else tpo.GetPointOfControl();
def hVA = if IsNaN(tpo.GetHighestValueArea()) and con then hVA[1] else tpo.GetHighestValueArea();
def lVA = if IsNaN(tpo.GetLowestValueArea()) and con then lVA[1] else tpo.GetLowestValueArea();

def hProfile = if IsNaN(tpo.GetHighest()) and con then hProfile[1] else tpo.GetHighest();
def lProfile = if IsNaN(tpo.GetLowest()) and con then lProfile[1] else tpo.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));

tpo.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();
 
Last edited:
On my study....the V1, V2, etc...extend as programmed, however, POCs do not....I'm currently set to a timeframe of 1h and looking across a timespan of 90 days. The "Time per Profile" is set to WEEK. Any help with this is appreciated.
 
On my study....the V1, V2, etc...extend as programmed, however, POCs do not....I'm currently set to a timeframe of 1h and looking across a timespan of 90 days. The "Time per Profile" is set to WEEK. Any help with this is appreciated.

The all extend unless crossed on this 90d 1h chart of AAL and others tested

Capture.jpg
 
Thanks for the reply! Would you please double check with the profile set to "Week" vs the "Day" as shown?

[Edit: Changed default profile in full TPO to WEEK from DAY. When I originally posted this I had just changed it at the input screen.]

The issue was day vs week. The original code was focused on days and was only looking back 7 days not 7 weeks.

At this time it is easier to create a Week version by referencing the TPO's to Week instead of Day. For clarity sake, I changed daysback to weeksback.

Capture.jpg
Ruby:
#TPO_Extended_POCs_HVAs_LVAs_for_x_Weeksback_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 Weeksback = 1;
    def volp = reference TPOProfile("time per profile" = "WEEK", "on expansion" = no, "price per row height mode" = "TICKSIZE");
    def ymd  = GetWeek();
    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) - Weeksback
                  then volp  else
               pc[1];
    plot x    = if y > HighestAll(y) - Weeksback 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 weeksback = 1;
    def volh = reference TPOProfile("time per profile" = "Week", "on expansion" = no, "price per row height mode" = "TICKSIZE").VAHigh;
    def ymd  = GetWeek();
    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) - weeksback
                  then volh  else
               ph[1];
    plot x    = if y > HighestAll(y) - weeksback 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 weeksback = 1;
    def voll = reference TPOProfile("time per profile" = "Week", "on expansion" = no, "price per row height mode" = "TICKSIZE").VALow;
    def ymd  = GetWeek();
    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) - weeksback
                  then voll  else
               pl[1];
    plot x    = if y > HighestAll(y) - weeksback 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", Color.YELLOW) ;

plot vh1 =  vh(1).hva;
vh1.AssignValueColor(if IsNaN(LowestAll(vh(1).x)) then GlobalColor("NB") else GlobalColor("H"));
vh1.SetPaintingStrategy(PaintingStrategy.DASHES);
vh1.SetLineWeight(2);

plot vh2 =  vh(2).hva;
vh2.AssignValueColor(if IsNaN(LowestAll(vh(2).x)) then GlobalColor("NB") else GlobalColor("H"));
vh2.SetPaintingStrategy(PaintingStrategy.DASHES);
vh2.SetLineWeight(2);

plot vh3 =  vh(3).hva;
v3.AssignValueColor(if IsNaN(LowestAll(vh(3).x)) then GlobalColor("NB") else GlobalColor("H"));
v3.SetPaintingStrategy(PaintingStrategy.DASHES);
v3.SetLineWeight(2);

plot vh4 =  vh(4).hva;
vh4.AssignValueColor(if IsNaN(LowestAll(vh(4).x)) then GlobalColor("NB") else GlobalColor("H"));
vh4.SetPaintingStrategy(PaintingStrategy.DASHES);
vh4.SetLineWeight(2);

plot vh5 =  vh(5).hva;
vh5.AssignValueColor(if IsNaN(LowestAll(vh(5).x)) then GlobalColor("NB") else GlobalColor("H"));
vh5.SetPaintingStrategy(PaintingStrategy.DASHES);
vh5.SetLineWeight(2);

plot vh6 =  vh(6).hva;
vh6.AssignValueColor(if IsNaN(LowestAll(vh(6).x)) then GlobalColor("NB") else GlobalColor("H"));
vh6.SetPaintingStrategy(PaintingStrategy.DASHES);
vh6.SetLineWeight(2);

plot vh7 =  vh(7).hva;
vh7.AssignValueColor(if IsNaN(LowestAll(vh(7).x)) then GlobalColor("NB") else GlobalColor("H"));
vh7.SetPaintingStrategy(PaintingStrategy.DASHES);
vh7.SetLineWeight(2);

plot vh8 =  vh(8).hva;
vh8.AssignValueColor(if IsNaN(LowestAll(vh(8).x)) then GlobalColor("NB") else GlobalColor("H"));
vh8.SetPaintingStrategy(PaintingStrategy.DASHES);
vh8.SetLineWeight(2);

plot vh9 =  vh(9).hva;
vh9.AssignValueColor(if IsNaN(LowestAll(vh(9).x)) then GlobalColor("NB") else GlobalColor("H"));
vh9.SetPaintingStrategy(PaintingStrategy.DASHES);
vh9.SetLineWeight(2);

plot vh10 =  vh(10).hva;
vh10.AssignValueColor(if IsNaN(LowestAll(vh(10).x)) then GlobalColor("NB") else GlobalColor("H"));
vh10.SetPaintingStrategy(PaintingStrategy.DASHES);
vh10.SetLineWeight(2);
;

AddLabel(1, " VAH: " +
if IsNaN(LowestAll(vh(1).x)) then "VH1" else
if IsNaN(LowestAll(vh(2).x)) then "VH2" else
if IsNaN(LowestAll(vh(3).x)) then "VH3" else
if IsNaN(LowestAll(vh(4).x)) then "VH4" else
if IsNaN(LowestAll(vh(5).x)) then "VH5" else
if IsNaN(LowestAll(vh(6).x)) then "VH6" else
if IsNaN(LowestAll(vh(7).x)) then "VH7" else
if IsNaN(LowestAll(vh(8).x)) then "VH8" else
if IsNaN(LowestAll(vh(9).x)) then "VH9" else
if IsNaN(LowestAll(vh(10).x)) then "VH10" else
"NO VH", Color.WHITE) ;


plot vl1 =  vl(1).val;
vl1.AssignValueColor(if IsNaN(LowestAll(vl(1).x)) then GlobalColor("NB") else GlobalColor("L"));
vl1.SetPaintingStrategy(PaintingStrategy.DASHES);
vl1.SetLineWeight(2);

plot vl2 =  vl(2).val;
vl2.AssignValueColor(if IsNaN(LowestAll(vl(2).x)) then GlobalColor("NB") else GlobalColor("L"));
vl2.SetPaintingStrategy(PaintingStrategy.DASHES);
vl2.SetLineWeight(2);

plot vl3 =  vl(3).val;
vl3.AssignValueColor(if IsNaN(LowestAll(vl(3).x)) then GlobalColor("NB") else GlobalColor("L"));
vl3.SetPaintingStrategy(PaintingStrategy.DASHES);
vl3.SetLineWeight(2);

plot vl4 =  vl(4);
vl4.AssignValueColor(if IsNaN(LowestAll(vl(4).x)) then GlobalColor("NB") else GlobalColor("L"));
vl4.SetPaintingStrategy(PaintingStrategy.DASHES);
vl4.SetLineWeight(2);

plot vl5 =  vl(5).val;
vl5.AssignValueColor(if IsNaN(LowestAll(vl(5).x)) then GlobalColor("NB") else GlobalColor("L"));
vl5.SetPaintingStrategy(PaintingStrategy.DASHES);
vl5.SetLineWeight(2);

plot vl6 =  vl(6).val;
vl6.AssignValueColor(if IsNaN(LowestAll(vl(6).x)) then GlobalColor("NB") else GlobalColor("L"));
vl6.SetPaintingStrategy(PaintingStrategy.DASHES);
vl6.SetLineWeight(2);

plot vl7 =  vl(7).val;
vl7.AssignValueColor(if IsNaN(LowestAll(vl(7).x)) then GlobalColor("NB") else GlobalColor("L"));
vl7.SetPaintingStrategy(PaintingStrategy.DASHES);
vl7.SetLineWeight(2);

plot vl8 =  vl(8).val;
vl8.AssignValueColor(if IsNaN(LowestAll(vl(8).x)) then GlobalColor("NB") else GlobalColor("L"));
vl8.SetPaintingStrategy(PaintingStrategy.DASHES);
vl8.SetLineWeight(2);

plot vl9 =  vl(9).val;
vl9.AssignValueColor(if IsNaN(LowestAll(vl(9).x)) then GlobalColor("NB") else GlobalColor("L"));
vl9.SetPaintingStrategy(PaintingStrategy.DASHES);
vl9.SetLineWeight(2);

plot vl10 =  vl(10).val;
vl10.AssignValueColor(if IsNaN(LowestAll(vl(10).x)) then GlobalColor("NB") else GlobalColor("L"));
vl10.SetPaintingStrategy(PaintingStrategy.DASHES);
vl10.SetLineWeight(2);
;

AddLabel(1, " VAL: " +
if IsNaN(LowestAll(vl(1).x)) then "VL1" else
if IsNaN(LowestAll(vl(2).x)) then "VL2" else
if IsNaN(LowestAll(vl(3).x)) then "VL3" else
if IsNaN(LowestAll(vl(4).x)) then "VL4" else
if IsNaN(LowestAll(vl(5).x)) then "VL5" else
if IsNaN(LowestAll(vl(6).x)) then "VL6" else
if IsNaN(LowestAll(vl(7).x)) then "VL7" else
if IsNaN(LowestAll(vl(8).x)) then "VL8" else
if IsNaN(LowestAll(vl(9).x)) then "VL9" else
if IsNaN(LowestAll(vl(10).x)) then "VL10" else
"NO VL", Color.YELLOW) ;


#TPOprofile 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, DAY, default WEEK, MONTH, "OPT EXP", BAR};
input multiplier = 1;
input onExpansion = no;
input profiles = 1000;
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 tpo = TimeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
def con = CompoundValue(1, onExpansion, no);
def pc = if IsNaN(tpo.GetPointOfControl()) and con then pc[1] else tpo.GetPointOfControl();
def hVA = if IsNaN(tpo.GetHighestValueArea()) and con then hVA[1] else tpo.GetHighestValueArea();
def lVA = if IsNaN(tpo.GetLowestValueArea()) and con then lVA[1] else tpo.GetLowestValueArea();

def hProfile = if IsNaN(tpo.GetHighest()) and con then hProfile[1] else tpo.GetHighest();
def lProfile = if IsNaN(tpo.GetLowest()) and con then lProfile[1] else tpo.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));

tpo.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();
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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