#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
- daysback
then volp else
pc[1];
plot x = if y > HighestAll
- 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
- daysback
then volh else
ph[1];
plot x = if y > HighestAll
- 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
- daysback
then voll else
pl[1];
plot x = if y > HighestAll
- 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"));