Volume Profile Indicator & POCs For ThinkOrSwim

@halcyonguy

Hey, I apologize for bumping an old thread and pinging you here, but I was wondering if you ever got around to figuring out OP/your own study? I too am doing something similar to OP's original query - basically wanting to plot levels of significance (high, low, POCs of day bars) dating back from two Sundays ago to current. For example, if today is Monday (8/23), then ideally, the study would be plotting levels up to the second previous Sunday (8/15) on today's chart. However, I'm not quite sure how to even approach this. I started by trying to define the Sunday as an offset to input in the look back of the variable, but quickly learned thats not how it worked. A friend of mine, though not familiar with thinkscript, told me that a fold function might work. I looked into this on ToS' TLC website and from what I can tell, if I define the days as numbers with Sunday being the start, it could loop until the 14th day? I'm not even sure if that makes sense.

If possible, any help and/or advice here is greatly appreciated. Again, sorry to ping and bump this old thread.

Couch.
here is a study to plot high low levels from the past 5 days, onto just the current day

Code:
# prev5dayslevels_01

# get hi low levels from prev 5 days
# display lines on current day

def na = Double.NaN;
def istoday = if GetLastDay() == GetDay() then 1 else 0;

input timeFrame = AggregationPeriod.DAY;

def hi1 = high(period = timeFrame)[1];
def lo1 = low(period = timeFrame)[1];
def hi2 = high(period = timeFrame)[2];
def lo2 = low(period = timeFrame)[2];
def hi3 = high(period = timeFrame)[3];
def lo3 = low(period = timeFrame)[3];
def hi4 = high(period = timeFrame)[4];
def lo4 = low(period = timeFrame)[4];
def hi5 = high(period = timeFrame)[5];
def lo5 = low(period = timeFrame)[5];

plot hh1 = if istoday then hi1 else na;
plot ll1 = if istoday then lo1 else na;
plot hh2 = if istoday then hi2 else na;
plot ll2 = if istoday then lo2 else na;
plot hh3 = if istoday then hi3 else na;
plot ll3 = if istoday then lo3 else na;
plot hh4 = if istoday then hi4 else na;
plot ll4 = if istoday then lo4 else na;
plot hh5 = if istoday then hi5 else na;
plot ll5 = if istoday then lo5 else na;

hh1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ll1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hh2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ll2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hh3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ll3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hh4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ll4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hh5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ll5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

hh1.SetDefaultColor(Color.light_green);
ll1.SetDefaultColor(Color.light_red);
hh2.SetDefaultColor(Color.light_green);
ll2.SetDefaultColor(Color.light_red);
hh3.SetDefaultColor(Color.light_green);
ll3.SetDefaultColor(Color.light_red);
hh4.SetDefaultColor(Color.light_green);
ll4.SetDefaultColor(Color.light_red);
hh5.SetDefaultColor(Color.light_green);
ll5.SetDefaultColor(Color.light_red);
#
 

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

is this what you are asking ?

do you want to look at an intra day chart,
and only on the current day,
see 28+ lines,
based from high and low levels from the days in the past 14+ days?
i'm ignoring poc for now....

...wanting to plot levels of significance (high, low, POCs of day bars)
...dating back from two Sundays ago to current.
...the study would be plotting levels up to the second previous Sunday (8/15) ,

this will need 28+ plot functions and supportive formulas.

Thanks for the reply halcyonguy. That is pretty much what I'm asking. Just to clarify, that holds true for when it is Sunday. However, once it becomes Monday, the plotted lines would reset to plot horizontal levels (for high/low/POC) up to the second previous Sunday, and as a new day begins, the previous day is added. So for example, if today is Monday, it would plot levels from the second previous Sunday (In total, would include 8 days (excluding saturday and including the two sundays & current Monday). Similarly, if it is now Tuesday, then it would plot levels up to 9 days and so on and so forth.

here is a study to plot high low levels from the past 5 days, onto just the current day

Code:
# prev5dayslevels_01

# get hi low levels from prev 5 days
# display lines on current day

def na = Double.NaN;
def istoday = if GetLastDay() == GetDay() then 1 else 0;

input timeFrame = AggregationPeriod.DAY;

def hi1 = high(period = timeFrame)[1];
def lo1 = low(period = timeFrame)[1];
def hi2 = high(period = timeFrame)[2];
def lo2 = low(period = timeFrame)[2];
def hi3 = high(period = timeFrame)[3];
def lo3 = low(period = timeFrame)[3];
def hi4 = high(period = timeFrame)[4];
def lo4 = low(period = timeFrame)[4];
def hi5 = high(period = timeFrame)[5];
def lo5 = low(period = timeFrame)[5];

plot hh1 = if istoday then hi1 else na;
plot ll1 = if istoday then lo1 else na;
plot hh2 = if istoday then hi2 else na;
plot ll2 = if istoday then lo2 else na;
plot hh3 = if istoday then hi3 else na;
plot ll3 = if istoday then lo3 else na;
plot hh4 = if istoday then hi4 else na;
plot ll4 = if istoday then lo4 else na;
plot hh5 = if istoday then hi5 else na;
plot ll5 = if istoday then lo5 else na;

hh1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ll1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hh2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ll2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hh3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ll3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hh4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ll4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hh5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ll5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

hh1.SetDefaultColor(Color.light_green);
ll1.SetDefaultColor(Color.light_red);
hh2.SetDefaultColor(Color.light_green);
ll2.SetDefaultColor(Color.light_red);
hh3.SetDefaultColor(Color.light_green);
ll3.SetDefaultColor(Color.light_red);
hh4.SetDefaultColor(Color.light_green);
ll4.SetDefaultColor(Color.light_red);
hh5.SetDefaultColor(Color.light_green);
ll5.SetDefaultColor(Color.light_red);
#

I really appreciate your time and help with my query, so I thank you very much. Truly.

I've gone and tried to code what I meant to do above by using your code as a template. However, I'm stuck in a position where if I want to only plot the current day, it lets me, but when I try to bundle it with plotting the previous days, not only does it not show the POCs of the previous days, but it plots the POC line for each previous day as 1.

For example, in the code below, I start with Monday and attempt to plot the previous days POC up to the second Sunday. If I keep
Code:
plot MondayPoc = if TodayIsMonday then TodayMondayPOC else na;
then it correctly plots all Monday POCs in the timeframe. However, if I keep
Code:
plot MondayPoc = if TodayIsMonday then TodayMondayPOC and TodayIsMonSun and TodayisMonFri and TodayisMonThurs and TodayisMonWed and TodayisMonTues and TodayisMonMon and TodayisMonSunSun else na;
,
it plots all Monday POCs as 1 and does not plot any of the previous days POC.

Here's the code; please bare with me, I'm very new to thinkscript and have been trying my best.

Code:
def yyyymmdd = GetYYYYMMDD(); 
def na = Double.Nan;

#Getting POC
def RTHBegin = 930;
def RTHEnd = 1600;
def RTH = SecondsFromTime(RthBegin) >= 0 and SecondsTillTime(RthEnd) >= 0; 
def cond2 = RTH != RTH[1];
profile tpo = TimeProfile("PricePerRow" = PricePerRow.Ticksize, "startNewProfile" = cond2, "onExpansion" = no);

#Defining Days of Week (credit to Mobius)
def DOW2 = getdayOfWeek(getYYYYMMDD());
def Mon = if DOW2 == 1 then 1 else 0;
def Tues = if DOW2 == 2 then 1 else 0;
def Wed = if DOW2 == 3 then 1 else 0;
def Thurs = if DOW2 == 4 then 1 else 0;
def Fri = if DOW2 == 5 then 1 else 0;
def Sat = if DOW2 == 6 then 1 else 0;
def Sun = if DOW2 == 7 then 1 else 0;

def TodayIsMonday = Mon;
def TodayMondayPoc = tpo.GetPointofControl(); #GetMondaysPOC.
def TodayIsMonSun = TodayMondayPoc[1]; #This should be prev Sunday's POC.
def TodayIsMonFri = TodayIsMonSun[1]; #This should be prev Friday's POC.
def TodayIsMonThurs = TodayIsMonFri[1]; #This should be prev Thursday's POC.
def TodayIsMonWed = TodayIsMonThurs[1]; #This should be prev Wednesday's POC.
def TodayisMonTues = TodayIsMonWed[1]; #This should be prev Tuesday's POC.
def TodayisMonMon = TodayIsMonTues[1]; #This should be prev Monday's POC.
def TodayisMonSunSun = TodayIsMonMon[1]; #And lastly, this should be the second prev Sunday's POC.
#plot MondayPoc = if TodayIsMonday then TodayMondayPOC else na; #This only plots Monday's POC.
plot MondayPoc = if TodayIsMonday then TodayMondayPOC and TodayIsMonSun and TodayisMonFri and TodayisMonThurs and TodayisMonWed and TodayisMonTues and TodayisMonMon and TodayisMonSunSun else na; #This should be plotting the POCs of Monday all the way to the second previous sunday.
 
mondayPoc.SetPaintingStrategy(PaintingStrategy.Horizontal);
mondayPoc.SetDefaultColor(Color.Orange);
 
Thanks for the reply halcyonguy. That is pretty much what I'm asking. Just to clarify, that holds true for when it is Sunday. However, once it becomes Monday, the plotted lines would reset to plot horizontal levels (for high/low/POC) up to the second previous Sunday, and as a new day begins, the previous day is added. So for example, if today is Monday, it would plot levels from the second previous Sunday (In total, would include 8 days (excluding saturday and including the two sundays & current Monday). Similarly, if it is now Tuesday, then it would plot levels up to 9 days and so on and so forth.



I really appreciate your time and help with my query, so I thank you very much. Truly.

I've gone and tried to code what I meant to do above by using your code as a template. However, I'm stuck in a position where if I want to only plot the current day, it lets me, but when I try to bundle it with plotting the previous days, not only does it not show the POCs of the previous days, but it plots the POC line for each previous day as 1.

For example, in the code below, I start with Monday and attempt to plot the previous days POC up to the second Sunday. If I keep
Code:
plot MondayPoc = if TodayIsMonday then TodayMondayPOC else na;
then it correctly plots all Monday POCs in the timeframe. However, if I keep
Code:
plot MondayPoc = if TodayIsMonday then TodayMondayPOC and TodayIsMonSun and TodayisMonFri and TodayisMonThurs and TodayisMonWed and TodayisMonTues and TodayisMonMon and TodayisMonSunSun else na;
,
it plots all Monday POCs as 1 and does not plot any of the previous days POC.

Here's the code; please bare with me, I'm very new to thinkscript and have been trying my best.

Code:
def yyyymmdd = GetYYYYMMDD();
def na = Double.Nan;

#Getting POC
def RTHBegin = 930;
def RTHEnd = 1600;
def RTH = SecondsFromTime(RthBegin) >= 0 and SecondsTillTime(RthEnd) >= 0;
def cond2 = RTH != RTH[1];
profile tpo = TimeProfile("PricePerRow" = PricePerRow.Ticksize, "startNewProfile" = cond2, "onExpansion" = no);

#Defining Days of Week (credit to Mobius)
def DOW2 = getdayOfWeek(getYYYYMMDD());
def Mon = if DOW2 == 1 then 1 else 0;
def Tues = if DOW2 == 2 then 1 else 0;
def Wed = if DOW2 == 3 then 1 else 0;
def Thurs = if DOW2 == 4 then 1 else 0;
def Fri = if DOW2 == 5 then 1 else 0;
def Sat = if DOW2 == 6 then 1 else 0;
def Sun = if DOW2 == 7 then 1 else 0;

def TodayIsMonday = Mon;
def TodayMondayPoc = tpo.GetPointofControl(); #GetMondaysPOC.
def TodayIsMonSun = TodayMondayPoc[1]; #This should be prev Sunday's POC.
def TodayIsMonFri = TodayIsMonSun[1]; #This should be prev Friday's POC.
def TodayIsMonThurs = TodayIsMonFri[1]; #This should be prev Thursday's POC.
def TodayIsMonWed = TodayIsMonThurs[1]; #This should be prev Wednesday's POC.
def TodayisMonTues = TodayIsMonWed[1]; #This should be prev Tuesday's POC.
def TodayisMonMon = TodayIsMonTues[1]; #This should be prev Monday's POC.
def TodayisMonSunSun = TodayIsMonMon[1]; #And lastly, this should be the second prev Sunday's POC.
#plot MondayPoc = if TodayIsMonday then TodayMondayPOC else na; #This only plots Monday's POC.
plot MondayPoc = if TodayIsMonday then TodayMondayPOC and TodayIsMonSun and TodayisMonFri and TodayisMonThurs and TodayisMonWed and TodayisMonTues and TodayisMonMon and TodayisMonSunSun else na; #This should be plotting the POCs of Monday all the way to the second previous sunday.
 
mondayPoc.SetPaintingStrategy(PaintingStrategy.Horizontal);
mondayPoc.SetDefaultColor(Color.Orange);

please reread post #123 , where i said
this will need 28+ plot functions and supportive formulas. ( for 2 lines a day)

for every line you want to see on 1 day, you need a separate plot function.

i don't know know why you want to look for data for saturday and sunday,, .. but i will include them in the max day count.
if you want 3 lines plotted, from up to 14 previous days , that will be 42 plot functions and 42 sets of supporting formulas.
the 42 sets of formulas, can be somewhat simplified with script { }.
 
Last edited:
please reread post #6 , where i said
this will need 28+ plot functions and supportive formulas. ( for 2 lines a day)

for every line you want to see on 1 day, you need a separate plot function.

i don't know know why you want to look for data for saturday and sunday,, .. but i will include them in the max day count.
if you want 3 lines plotted, from up to 14 previous days , that will be 42 plot functions and 42 sets of supporting formulas.
the 42 sets of formulas, can be somewhat simplified with script { }.

Thanks for the reply. I think I understand what you mean now. Instead of this line:

Code:
plot MondayPoc = if TodayIsMonday then TodayMondayPOC and TodayIsMonSun and TodayisMonFri and TodayisMonThurs and TodayisMonWed and TodayisMonTues and TodayisMonMon and TodayisMonSunSun else na;

it should instead be broken into separate plots, as you stated, like:

Code:
plot MondayPoc = if TodayIsMonday then TodayMondayPOC else na;
plot MondaySunPoc = if TodayisMonday then TodayisMonSun else na;
plot MondayFriPoc = if TodayisMonday then TodayIsMonFri else na;

and each other day that I'd like to reference would have its separate plot.

That makes a lot more sense. I just tested it out as well and it works out very nicely. I'd just need to extend the lines over to whatever current day it is.

i don't know know why want to look for data for saturday and sunday

Sorry, I should've clarified above. I mostly trade index futures and sometimes trade on Sunday globex hours, and similarly, use the POC/High/Low of those globex hours in intraday charts. As for Saturday, I agree, I would not want data from that day.
 
Since posting this, I've gone ahead and tried to code a test run for the whole week. The idea is to first, define the current day as Monday. From there, each corresponding previous day is defined as the 1 lookback to the day ahead. Working, it should plot a POC line on each day for the past week from the current day. However, from the chart, it only plots a POC line on each Monday. I've attached an image below.

Test-Code-Img.png


Here's the code below:
Code:
def yyyymmdd = GetYYYYMMDD();
def na = Double.Nan;

#Getting POC
def RTHBegin = 930;
def RTHEnd = 1600;
def RTH = SecondsFromTime(RthBegin) >= 0 and SecondsTillTime(RthEnd) >= 0;
def cond2 = RTH != RTH[1];
profile tpo = TimeProfile("PricePerRow" = PricePerRow.Ticksize, "startNewProfile" = cond2, "onExpansion" = no);

#Defining Days of Week (credit to Mobius)
def DOW2 = getdayOfWeek(getYYYYMMDD());
def Mon = if DOW2 == 1 then 1 else 0;
def Tues = if DOW2 == 2 then 1 else 0;
def Wed = if DOW2 == 3 then 1 else 0;
def Thurs = if DOW2 == 4 then 1 else 0;
def Fri = if DOW2 == 5 then 1 else 0;
def Sat = if DOW2 == 6 then 1 else 0;
def Sun = if DOW2 == 7 then 1 else 0;


def TodayIsMonday = Mon;
def StartingMonday = tpo.GetPointofControl();
def PreviousSunday = StartingMonday[1];
def PreviousFriday = PreviousSunday[1];
def PreviousThursday = PreviousFriday[1];
def PreviousWednesday = PreviousThursday[1];
def PreviousTuesday = PreviousWednesday[1];
def PreviousMonday = PreviousTuesday[1];
def SecondPreviousSunday = PreviousMonday[1];

#Plots for Current Monday.
plot StartingMondayPOC = if TodayIsMonday then StartingMonday else na;
plot PreviousSundayPOC = if TodayIsMonday then PreviousSunday else na;
plot PreviousFridayPOC = if TodayIsMonday then PreviousFriday else na;
plot PreviousThursdayPOC = if TodayIsMonday then PreviousThursday else na;
plot PreviousWednesdayPOC = if TodayIsMonday then PreviousWednesday else na;
plot PreviousTuesdayPOC = if TodayIsMonday then PreviousTuesday else na;
plot PreviousMondayPOC = if TodayIsMonday then PreviousMonday else na;
plot SecondPreviousSundayPOC = if TodayIsMonday then PreviousSunday else na;
StartingMondayPOC.SetPaintingStrategy(PaintingStrategy.Horizontal);
StartingMondayPOC.SetDefaultColor(Color.Orange);
PreviousSundayPOC.SetPaintingStrategy(PaintingStrategy.Horizontal);
PreviousSundayPOC.SetDefaultColor(Color.Orange);
PreviousFridayPOC.SetPaintingStrategy(PaintingStrategy.Horizontal);
PreviousFridayPOC.SetDefaultColor(Color.Orange);
PreviousThursdayPOC.SetPaintingStrategy(PaintingStrategy.Horizontal);
PreviousThursdayPOC.SetDefaultColor(Color.Orange);
PreviousWednesdayPOC.SetPaintingStrategy(PaintingStrategy.Horizontal);
PreviousWednesdayPOC.SetDefaultColor(Color.Orange);
PreviousTuesdayPOC.SetPaintingStrategy(PaintingStrategy.Horizontal);
PreviousTuesdayPOC.SetDefaultColor(Color.Orange);
PreviousMondayPOC.SetPaintingStrategy(PaintingStrategy.Horizontal);
PreviousMondayPOC.SetDefaultColor(Color.Orange);
SecondPreviousSundayPOC.SetPaintingStrategy(PaintingStrategy.Horizontal);
SecondPreviousSundayPOC.SetDefaultColor(Color.Orange);

Do I have to manually define each if statement in the plots as their days? For example, in PreviousFridayPOC, do I have to replace "TodayIsMonday" as "Fri" instead?

It looks as if I do the above, it does work but it also plots it for all Fridays in the timeframe in addition to the Mondays.

Going off your post as number 6, using that same logic, where you plot the past five days from today, would it be possible to define "today" as a specific day? I tried to do
Code:
def istoday = if GetLastDay() == GetDay() then 1 else 0; 
def TodayIsMonday = istoday == Mon;

but that did not work the way I intended to.

As always, thanks for your continued help.
 
i hope this will help get you closer to what you want

referencing your code in post 11

your code only has a line on 1 day of the week
all lines are the same level
it wasn't storing the poc value for 7 days correctly.

this doesnt work with ext hours off.
def RTH = SecondsFromTime(RthBegin) >= 0 and SecondsTillTime(RthEnd) >= 0;
def cond2 = RTH != RTH[1];

--------------------

my changes
changed the mon, tues,wed,... formulas, so they hold a poc value, not true/false.

used this to determine when a new day occurs. it works when ext hours are off.
def gtdy = GetDay();
def diffday = if GtDy[1] <> GetDay() then 1 else 0;

assigned different colors for each day line


Ruby:
# prevweekdata_00b

# plot 5 (or 7 depending on decurity) poc lines , for the past 7 days

# post11
# https://usethinkscript.com/threads/only-show-friday-charts.5588/#post-74389
# https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Profiles/TimeProfile

def yyyymmdd = GetYYYYMMDD();
def na = Double.Nan;
#def istoday = if GetLastDay() == GetDay() then 1 else 0;


#Defining Days of Week (credit to Mobius)
def DOW2 = getdayOfWeek(getYYYYMMDD());

# test data, show day # of week , 1-7
input test_show_days = no;
addchartbubble(test_show_days, high*1.01, dow2, color.light_gray, yes);

# is the current bar on a different day, than prev bar ?  (first bar of day)
# this works with ext hours off
def gtdy = GetDay();
def diffday = if GtDy[1] <> GetDay() then 1 else 0;

input test_show_first_day_bar = no;
addchartbubble( test_show_first_day_bar and diffday, low*0.99, dow2, color.light_gray, no);

# test , plot spikes when diffday is true , first bar of the day. works with ext hours off
#plot g = if diffday then close else (close *0.9);
#g.setDefaultColor(Color.green);


#Getting POC
def RTHBegin = 930;
def RTHEnd = 1600;
# not used
#def RTH = SecondsFromTime(RthBegin) >= 0 and SecondsTillTime(RthEnd) >= 0;
# this doesnt work with ext hours off
#def cond2 = RTH != RTH[1];

#profile tpo = TimeProfile("PricePerRow" = PricePerRow.Ticksize, "startNewProfile" = cond2, "onExpansion" = no);
profile tpo = TimeProfile("PricePerRow" = PricePerRow.Ticksize, "startNewProfile" = diffday, "onExpansion" = no);
def tpopoc =  tpo.GetPointofControl();

# plot spikes when cond2 is true, first bar of the day. does not  work with ext hours off
#plot f = if cond2 then close else ( close *0.9);
#f.setDefaultColor(Color.cyan);


# assign a value for the day, and keep it till the same day next week
def Mon = if DOW2 == 1 then tpopoc else mon[1];
def Tues = if DOW2 == 2 then tpopoc else tues[1];
def Wed = if DOW2 == 3 then tpopoc else wed[1];
def Thur = if DOW2 == 4 then tpopoc else thur[1];
def Fri = if DOW2 == 5 then tpopoc else fri[1];
def Sat = if DOW2 == 6 then tpopoc else sat[1];
def Sun = if DOW2 == 7 then tpopoc else sun[1];

plot monx = mon;
plot tuesx = tues;
plot wedx = wed;
plot thurx = thur;
plot frix = fri;
plot satx = sat;
plot sunx = sun;

monx.SetPaintingStrategy(PaintingStrategy.Horizontal);
tuesx.SetPaintingStrategy(PaintingStrategy.Horizontal);
wedx.SetPaintingStrategy(PaintingStrategy.Horizontal);
thurx.SetPaintingStrategy(PaintingStrategy.Horizontal);
frix.SetPaintingStrategy(PaintingStrategy.Horizontal);
satx.SetPaintingStrategy(PaintingStrategy.Horizontal);
sunx.SetPaintingStrategy(PaintingStrategy.Horizontal);

#monx.setDefaultColor(Color.Orange);
#tuesx.setDefaultColor(Color.Orange);
#wedx.setDefaultColor(Color.Orange);
#thurx.setDefaultColor(Color.Orange);
#frix.setDefaultColor(Color.Orange);
#satx.setDefaultColor(Color.Orange);
#sunx.setDefaultColor(Color.Orange);

monx.setDefaultColor(getcolor(1));
tuesx.setDefaultColor(getcolor(2));
wedx.setDefaultColor(getcolor(3));
thurx.setDefaultColor(getcolor(4));
frix.setDefaultColor(getcolor(5));
satx.setDefaultColor(getcolor(6));
sunx.setDefaultColor(getcolor(7));
#



DsOBkI6.jpg
 
i hope this will help get you closer to what you want

referencing your code in post 11

your code only has a line on 1 day of the week
all lines are the same level
it wasn't storing the poc value for 7 days correctly.

this doesnt work with ext hours off.
def RTH = SecondsFromTime(RthBegin) >= 0 and SecondsTillTime(RthEnd) >= 0;
def cond2 = RTH != RTH[1];

--------------------

my changes
changed the mon, tues,wed,... formulas, so they hold a poc value, not true/false.

used this to determine when a new day occurs. it works when ext hours are off.
def gtdy = GetDay();
def diffday = if GtDy[1] <> GetDay() then 1 else 0;

assigned different colors for each day line


Ruby:
# prevweekdata_00b

# plot 5 (or 7 depending on decurity) poc lines , for the past 7 days

# post11
# https://usethinkscript.com/threads/only-show-friday-charts.5588/#post-74389
# https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Profiles/TimeProfile

def yyyymmdd = GetYYYYMMDD();
def na = Double.Nan;
#def istoday = if GetLastDay() == GetDay() then 1 else 0;


#Defining Days of Week (credit to Mobius)
def DOW2 = getdayOfWeek(getYYYYMMDD());

# test data, show day # of week , 1-7
input test_show_days = no;
addchartbubble(test_show_days, high*1.01, dow2, color.light_gray, yes);

# is the current bar on a different day, than prev bar ?  (first bar of day)
# this works with ext hours off
def gtdy = GetDay();
def diffday = if GtDy[1] <> GetDay() then 1 else 0;

input test_show_first_day_bar = no;
addchartbubble( test_show_first_day_bar and diffday, low*0.99, dow2, color.light_gray, no);

# test , plot spikes when diffday is true , first bar of the day. works with ext hours off
#plot g = if diffday then close else (close *0.9);
#g.setDefaultColor(Color.green);


#Getting POC
def RTHBegin = 930;
def RTHEnd = 1600;
# not used
#def RTH = SecondsFromTime(RthBegin) >= 0 and SecondsTillTime(RthEnd) >= 0;
# this doesnt work with ext hours off
#def cond2 = RTH != RTH[1];

#profile tpo = TimeProfile("PricePerRow" = PricePerRow.Ticksize, "startNewProfile" = cond2, "onExpansion" = no);
profile tpo = TimeProfile("PricePerRow" = PricePerRow.Ticksize, "startNewProfile" = diffday, "onExpansion" = no);
def tpopoc =  tpo.GetPointofControl();

# plot spikes when cond2 is true, first bar of the day. does not  work with ext hours off
#plot f = if cond2 then close else ( close *0.9);
#f.setDefaultColor(Color.cyan);


# assign a value for the day, and keep it till the same day next week
def Mon = if DOW2 == 1 then tpopoc else mon[1];
def Tues = if DOW2 == 2 then tpopoc else tues[1];
def Wed = if DOW2 == 3 then tpopoc else wed[1];
def Thur = if DOW2 == 4 then tpopoc else thur[1];
def Fri = if DOW2 == 5 then tpopoc else fri[1];
def Sat = if DOW2 == 6 then tpopoc else sat[1];
def Sun = if DOW2 == 7 then tpopoc else sun[1];

plot monx = mon;
plot tuesx = tues;
plot wedx = wed;
plot thurx = thur;
plot frix = fri;
plot satx = sat;
plot sunx = sun;

monx.SetPaintingStrategy(PaintingStrategy.Horizontal);
tuesx.SetPaintingStrategy(PaintingStrategy.Horizontal);
wedx.SetPaintingStrategy(PaintingStrategy.Horizontal);
thurx.SetPaintingStrategy(PaintingStrategy.Horizontal);
frix.SetPaintingStrategy(PaintingStrategy.Horizontal);
satx.SetPaintingStrategy(PaintingStrategy.Horizontal);
sunx.SetPaintingStrategy(PaintingStrategy.Horizontal);

#monx.setDefaultColor(Color.Orange);
#tuesx.setDefaultColor(Color.Orange);
#wedx.setDefaultColor(Color.Orange);
#thurx.setDefaultColor(Color.Orange);
#frix.setDefaultColor(Color.Orange);
#satx.setDefaultColor(Color.Orange);
#sunx.setDefaultColor(Color.Orange);

monx.setDefaultColor(getcolor(1));
tuesx.setDefaultColor(getcolor(2));
wedx.setDefaultColor(getcolor(3));
thurx.setDefaultColor(getcolor(4));
frix.setDefaultColor(getcolor(5));
satx.setDefaultColor(getcolor(6));
sunx.setDefaultColor(getcolor(7));
#



DsOBkI6.jpg

halycon, thank you for your help and reply - my apologies for not replying sooner. This did in fact get me closer to what I want and helped me understand certain functions/formulas a lot better that I've tried to incorporate in the study. I'll post the updated study tomorrow, as I have to organize it a little bit better. There are still some things that I've got to fix that I do not quite understand how to do, but I'll be sure to include it tomorrow.

As always, thanks for your continued help.
 
halycon, thank you for your help and reply - my apologies for not replying sooner. This did in fact get me closer to what I want and helped me understand certain functions/formulas a lot better that I've tried to incorporate in the study. I'll post the updated study tomorrow, as I have to organize it a little bit better. There are still some things that I've got to fix that I do not quite understand how to do, but I'll be sure to include it tomorrow.

As always, thanks for your continued help.

@halcyonguy (apologies for misspelling your name above), thank you for getting me closer to what I've been trying to get at. I was successfully able to plot the past five days from a specific/static day with no plots in other previous weeks. I've posted the code and a picture of the corresponding chart below.

One thing, however, I'd like to ask is in regards to repeat days. In the code below, I start from today, 8/31/21, a tuesday, as the 0 day, or starting point. From there, using your previous example, I was able to plot all previous days, monday, friday, thursday and wednesday for a total of five plots (including today). I wanted to try and include the previous week's tuesday as well, and therefore, attempted to plot it by adding

Code:
plot tuesday = if TodayIsXDay then tues[2] else na;
tuesday.SetPaintingStrategy(PaintingStrategy.Horizontal);
tuesday.SetDefaultColor(Color.Orange);

by adding a lookback period of [2]. However, as seen in the chart, the number/plot returned is the same as the currentday (today's POC) value, or specifically, the price: 4526.63. What am I doing wrong here? Would tues[2] not return the second previous Tuesday POC?

As always, thank you for your help and guidance.


Code:
#Plotting past five days of POCs based off specific day.

def yyyymmdd = GetYYYYMMDD();
def na = Double.NaN;


#Getting POC
def RTHBegin = 930;
def RTHEnd = 1600;
def RTH = SecondsFromTime(RTHBegin) >= 0 and SecondsTillTime(RTHEnd) >= 0;
def cond2 = RTH != RTH[1];
def GtDy = GetDay();
def diffday = if GtDy[1] <> GetDay() then 1 else 0;
profile tpo = TimeProfile("PricePerRow" = PricePerRow.TICKSIZE, "startNewProfile" = diffday, "onExpansion" = no);

def tpopoc = tpo.GetPointOfControl();

#Defining Days of Week and their POC's (credit to @halcyonguy and @Mobius)
def DOW2 = GetDayOfWeek(GetYYYYMMDD());
def Mon = if DOW2 == 1 then tpopoc else mon[1];
def Tues = if DOW2 == 2 then  tpopoc else tues[1];
def Wed = if DOW2 == 3 then  tpopoc else wed[1];
def Thurs = if DOW2 == 4 then tpopoc else thurs[1];
def Fri = if DOW2 == 5 then  tpopoc else fri[1];
def Sat = if DOW2 == 6 then  tpopoc else sat[1];
def Sun = if DOW2 == 7 then  tpopoc else sun[1];

#Defining Days
def TodayIsXDay = getday()==getlastday() and dow2 == 2; #Since today is 8/31/21 (Tuesday), TodayisXDay = 2

plot currentday = if TodayIsXDay then tues else na;
currentday.SetPaintingStrategy(PaintingStrategy.Horizontal);
currentday.SetDefaultColor(Color.Orange);

plot monday = if TodayIsXDay then mon else na;
monday.SetPaintingStrategy(PaintingStrategy.Horizontal);
monday.SetDefaultColor(Color.Orange);

plot friday = if TodayIsXDay then fri else na;
friday.SetPaintingStrategy(PaintingStrategy.Horizontal);
friday.SetDefaultColor(Color.Orange);

plot thursday = if TodayIsXDay then thurs else na;
thursday.SetPaintingStrategy(PaintingStrategy.Horizontal);
thursday.SetDefaultColor(Color.Orange);

plot wednesday = if TodayIsXDay  then wed else na;
wednesday.SetPaintingStrategy(PaintingStrategy.Horizontal);
wednesday.SetDefaultColor(Color.Orange);

plot tuesday = if TodayIsXDay then tues[2] else na;
tuesday.SetPaintingStrategy(PaintingStrategy.Horizontal);
tuesday.SetDefaultColor(Color.Orange);

Chart (shows today's POC (tuesday) plotted twice):
Test-Code-Img2.png
 
Code:
def poc = reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no);
def vahigh = reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no).VAHigh;
def valow = reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no).VALow;

Hello, I found this code on here, I was wondering how do I modify it to show the previous day POC, VAH, and VAL. Like I would want for the code to plot on today's chart, the POC, VAH, and Low based on yesterday's volume/price movement
 
Code:
def poc = reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no);
def vahigh = reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no).VAHigh;
def valow = reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no).VALow;

Hello, I found this code on here, I was wondering how do I modify it to show the previous day POC, VAH, and VAL. Like I would want for the code to plot on today's chart, the POC, VAH, and Low based on yesterday's volume/price movement

The following allows you to use that code, choose daysback to plot prior occurrences to right edge, and chart bubbles option. 'Thisday' snippet was used to handle non-trading days, such as the past weekend.

The chart below also includes the display of the volumeprofile study to test the script below.

Capture.jpg
Ruby:
input daysback = 1;

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

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

input bubblemover = 3;
def b  = bubblemover;
def b1 = b + 1;
input showbubbles = yes;
addchartBubble(showbubbles and isnan(close[b]) and !isnan(close[b1]), poc1[b], "POC - " + daysback, color.cyan);
addchartBubble(showbubbles and isnan(close[b]) and !isnan(close[b1]), vahigh1[b], "VAH - " + daysback, color.yellow);
addchartBubble(showbubbles and isnan(close[b]) and !isnan(close[b1]), valow1[b], "VAL - " + daysback, color.yellow);
 
The following allows you to use that code, choose daysback to plot prior occurrences to right edge, and chart bubbles option. 'Thisday' snippet was used to handle non-trading days, such as the past weekend.

The chart below also includes the display of the volumeprofile study to test the script below.
wow thank you so much, this is perfect! I have a question, if I leave this on the chart, what time does the line readjust? would I see the prior value high during the premarket of the next session?
 
wow thank you so much, this is perfect! I have a question, if I leave this on the chart, what time does the line readjust? would I see the prior value high during the premarket of the next session?

It should switch at 0400 on the current day to the day before, extended to the right edge.
 
Hi all, anyone able to write a script to search for stock that crosses the poc. ideally we can set whether for intraday , day or week.

i try to use the script from @markos . It is near to what i want however most of result miss the poc area.



# Mr. Script
def yyyymmdd = GetYYYYMMDD();
def day_number = DaysFromDate(First(yyyymmdd)) + GetDayOfWeek(First(yyyymmdd));
def period = Floor(day_number / 7);
def cond = 0 < period - period[1];
profile vol = VolumeProfile("startNewProfile" = cond, "onExpansion" = no);
vol.Show("va color" = Color.YELLOW);
def b = vol.GetLowestValueArea();
plot c = close <= b and close >= (b*.9);
 
Hi all, anyone able to write a script to search for stock that crosses the poc. ideally we can set whether for intraday , day or week.

i try to use the script from @markos . It is near to what i want however most of result miss the poc area.



# Mr. Script
def yyyymmdd = GetYYYYMMDD();
def day_number = DaysFromDate(First(yyyymmdd)) + GetDayOfWeek(First(yyyymmdd));
def period = Floor(day_number / 7);
def cond = 0 < period - period[1];
profile vol = VolumeProfile("startNewProfile" = cond, "onExpansion" = no);
vol.Show("va color" = Color.YELLOW);
def b = vol.GetLowestValueArea();
plot c = close <= b and close >= (b*.9);

Put this in the scanner. You can also put it in a study and change def b to plot b

Ruby:
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 = no;
input showValueArea = no;
input valueAreaPercent = 70;
input opacity = 0;

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);
#vol.Show("va color" = Color.YELLOW);
def b = vol.GetPointOfControl();
plot c = if close crosses b then 1 else 0;
 
Thanks for your help! It work for the scanner @

SleepyZ


Meanwhile , if i would like to plot the volume profile within a date range. For example between a day range in daily chart.Unlike ninja trader, tos cant select a date range by mouse cursor.
 
Last edited:
Thanks for your help! It work for the scanner @

SleepyZ


Meanwhile , if i would like to plot the volume profile within a date range. For example between a day range in daily chart.Unlike ninja trader, tos cant select a date range by mouse cursor.

We have limited control over manipulating the TOS volumeprofile. Here is a date range modification of the volumeprofile that you may test for usefulness.

Capture.jpg
Ruby:
#VolumeProfile_DateRange

input begindate  = 20210802;
input enddate    = 20210820;
input pricePerRowHeightMode = {default AUTOMATIC, TICKSIZE, CUSTOM};
input customRowHeight = 1.0;
input onExpansion = no;
input profiles = 100;
input showPointOfControl = yes;
input showValueArea = yes;
input valueAreaPercent = 70;
input opacity = 50;

def count =  GetYYYYMMDD()>= (begindate)  and getyyyYMMDD()<=enddate;
def cond = count != count[1];
def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
    height = PricePerRow.AUTOMATIC;
case TICKSIZE:
    height = PricePerRow.TICKSIZE;
case CUSTOM:
    height = customRowHeight;
}

profile vol = VolumeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
def con = CompoundValue(1, onExpansion, no);
def pc = if IsNaN(vol.GetPointOfControl()) and con then pc[1] else vol.GetPointOfControl();
def hVA = if IsNaN(vol.GetHighestValueArea()) and con then hVA[1] else vol.GetHighestValueArea();
def lVA = if IsNaN(vol.GetLowestValueArea()) and con then lVA[1] else vol.GetLowestValueArea();

def hProfile = if IsNaN(vol.GetHighest()) and con then hProfile[1] else vol.GetHighest();
def lProfile = if IsNaN(vol.GetLowest()) and con then lProfile[1] else vol.GetLowest();
def plotsDomain = IsNaN(close) == onExpansion;

plot POC =  if plotsDomain  then pc else Double.NaN;
plot ProfileHigh =  if plotsDomain then hProfile else Double.NaN;
plot ProfileLow =  if plotsDomain then lProfile else Double.NaN;
plot VAHigh =  if plotsDomain  then hVA else Double.NaN;
plot VALow =  if plotsDomain  then  lVA else Double.NaN;

DefineGlobalColor("Profile", GetColor(1));
DefineGlobalColor("Point Of Control", GetColor(5));
DefineGlobalColor("Value Area", GetColor(8));

vol.Show(GlobalColor("Profile"), if showPointOfControl then GlobalColor("Point Of Control") else Color.CURRENT, if showValueArea then GlobalColor("Value Area") else Color.CURRENT, opacity);
POC.SetDefaultColor(GlobalColor("Point Of Control"));
POC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VALow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh.SetDefaultColor(GlobalColor("Value Area"));
VALow.SetDefaultColor(GlobalColor("Value Area"));
ProfileHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileHigh.SetDefaultColor(GetColor(3));
ProfileLow.SetDefaultColor(GetColor(3));
ProfileHigh.hide();
ProfileLow.Hide();

input bubbles = yes;
input n  = 2;
def   n1 = n + 1;
AddChartBubble(bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), VAHigh[n1], "V-VAH", color = Color.YELLOW, yes);
AddChartBubble(bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), VALow[n1], "V-VAL", Color.YELLOW, no);
AddChartBubble(bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), POC[n1], "V-POC", Color.RED, no);
 
Hi Everyone,

Is it possible to script extended horizontal lines only on virgin point of control (VPOC) that price has not touched previously. I am currently drawing the lines manually but I would like to save some time with this process.

Thank you,
 
Hi Everyone,

Is it possible to script extended horizontal lines only on virgin point of control (VPOC) that price has not touched previously. I am currently drawing the lines manually but I would like to save some time with this process.

Thank you,

Here is something I did awhile ago that may help. It isn't the most elegant code, but hopefully does what you are requesting.

Capture.jpg
Ruby:
#Example_Prior Day_POC_Extended_until_Crossed_
#20171027 - BLT... chat request by Tb8... using parts of TOS VolumeProfile study to define POC
#Black lines are extended until POC crossed

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

def height = PricePerRow.TICKSIZE;
input timePerProfile = {CHART, MINUTE, HOUR, default DAY, WEEK, MONTH, "OPT EXP", BAR};
input multiplier = 1;
input profiles = 1000;
input valueAreaPercent = 70;

def period;
def yyyymmdd = GetYYYYMMDD();
def seconds = SecondsFromTime(0);
def month = GetYear() * 12 + GetMonth();
def day_number = DaysFromDate(First(yyyymmdd)) + GetDayOfWeek(First(yyyymmdd));
def dom = GetDayOfMonth(yyyymmdd);
def dow = GetDayOfWeek(yyyymmdd - dom + 1);
def expthismonth = (if dow > 5 then 27 else 20) - dow;
def exp_opt = month + (dom > expthismonth);
switch (timePerProfile) {
case CHART:
    period = 0;
case MINUTE:
    period = Floor(seconds / 60 + day_number * 24 * 60);
case HOUR:
    period = Floor(seconds / 3600 + day_number * 24);
case DAY:
    period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
case WEEK:
    period = Floor(day_number / 7);
case MONTH:
    period = Floor(month - First(month));
case "OPT EXP":
    period = exp_opt - First(exp_opt);
case BAR:
    period = BarNumber() - 1;
}

def count = CompoundValue(1, if period != period[1] then (count[1] + period - period[1]) % multiplier else count[1], 0);
def cond = count < count[1] + period - period[1];
profile vol = VolumeProfile("startNewProfile" = cond, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent, onExpansion = no);

def HVA = if IsNaN(vol.GetHighestValueArea()) then HVA[1] else vol.GetHighestValueArea();
def pHVA = CompoundValue(1, if cond then HVA[1] else pHVA[1], Double.NaN);
def LVA = if IsNaN(vol.GetLowestValueArea()) then LVA[1] else vol.GetLowestValueArea();
def pLVA = CompoundValue(1, if cond then LVA[1] else pLVA[1], Double.NaN);

#Define Prior POC Calc.
def POC = if IsNaN(vol.GetPointOfControl()) and cond then POC[1] else vol.GetPointOfControl();
def pPOC = CompoundValue (1, if cond then POC[1] else pPOC[1], Double.NaN);

def CurHVA = HVA;
def CurLVA = LVA;

def PrevHVA = pHVA;
def PrevLVA = pLVA;

#Plot Prior POC
def xppoc    = if period != period[1] then 1 else if xppoc[1] == 1 and close crosses pPOC then 0 else xppoc[1];

plot PrevPOC = pPOC;

PrevPOC.SetPaintingStrategy(PaintingStrategy.POINTS);
PrevPOC.SetDefaultColor(Color.PLUM);

###
#20171027 - Additional Code for Limited Extended POC plot request by Tb8
input debug = no;
plot xx = if !debug then Double.NaN else period;
xx.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);

input c = close;#change this to some other price if desired

#Extends Plot of pPOC (Point of Control) for each day to the right
def p1a = if period == 90 then pPOC else p1a[1];
def p2a = if period == 89 then pPOC else p2a[1];
def p3a = if period == 88 then pPOC else p3a[1];
def p4a = if period == 87 then pPOC else p4a[1];
def p5a = if period == 86 then pPOC else p5a[1];
def p6a = if period == 85 then pPOC else p6a[1];
def p7a = if period == 84 then pPOC else p7a[1];
def p8a = if period == 83 then pPOC else p8a[1];
def p9a = if period == 82 then pPOC else p9a[1];
def p10a = if period == 81 then pPOC else p10a[1];
def p11a = if period == 80 then pPOC else p11a[1];
def p12a = if period == 79 then pPOC else p12a[1];
def p13a = if period == 78 then pPOC else p13a[1];
def p14a = if period == 77 then pPOC else p14a[1];
def p15a = if period == 76 then pPOC else p15a[1];
def p16a = if period == 75 then pPOC else p16a[1];
def p17a = if period == 74 then pPOC else p17a[1];
def p18a = if period == 73 then pPOC else p18a[1];
def p19a = if period == 72 then pPOC else p19a[1];
def p20a = if period == 71 then pPOC else p20a[1];

def p1b = if period == 70 then pPOC else p1b[1];
def p2b = if period == 69 then pPOC else p2b[1];
def p3b = if period == 68 then pPOC else p3b[1];
def p4b = if period == 67 then pPOC else p4b[1];
def p5b = if period == 66 then pPOC else p5b[1];
def p6b = if period == 65 then pPOC else p6b[1];
def p7b = if period == 64 then pPOC else p7b[1];
def p8b = if period == 63 then pPOC else p8b[1];
def p9b = if period == 62 then pPOC else p9b[1];
def p10b = if period == 61 then pPOC else p10b[1];
def p11b = if period == 60 then pPOC else p11b[1];
def p12b = if period == 59 then pPOC else p12b[1];
def p13b = if period == 58 then pPOC else p13b[1];
def p14b = if period == 57 then pPOC else p14b[1];
def p15b = if period == 56 then pPOC else p15b[1];
def p16b = if period == 55 then pPOC else p16b[1];
def p17b = if period == 54 then pPOC else p17b[1];
def p18b = if period == 53 then pPOC else p18b[1];
def p19b = if period == 52 then pPOC else p19b[1];
def p20b = if period == 51 then pPOC else p20b[1];

def p1c = if period == 50 then pPOC else p1c[1];
def p2c = if period == 49 then pPOC else p2c[1];
def p3c = if period == 48 then pPOC else p3c[1];
def p4c = if period == 47 then pPOC else p4c[1];
def p5c = if period == 46 then pPOC else p5c[1];
def p6c = if period == 45 then pPOC else p6c[1];
def p7c = if period == 44 then pPOC else p7c[1];
def p8c = if period == 43 then pPOC else p8c[1];
def p9c = if period == 42 then pPOC else p9c[1];
def p10c = if period == 41 then pPOC else p10c[1];
def p11c = if period == 40 then pPOC else p11c[1];
def p12c = if period == 39 then pPOC else p12c[1];
def p13c = if period == 38 then pPOC else p13c[1];
def p14c = if period == 37 then pPOC else p14c[1];
def p15c = if period == 36 then pPOC else p15c[1];
def p16c = if period == 35 then pPOC else p16c[1];
def p17c = if period == 34 then pPOC else p17c[1];
def p18c = if period == 33 then pPOC else p18c[1];
def p19c = if period == 32 then pPOC else p19c[1];
def p20c = if period == 31 then pPOC else p20c[1];

def p1d = if period == 30 then pPOC else p1d[1];
def p2d = if period == 29 then pPOC else p2d[1];
def p3d = if period == 28 then pPOC else p3d[1];
def p4d = if period == 27 then pPOC else p4d[1];
def p5d = if period == 26 then pPOC else p5d[1];
def p6d = if period == 25 then pPOC else p6d[1];
def p7d = if period == 24 then pPOC else p7d[1];
def p8d = if period == 23 then pPOC else p8d[1];
def p9d = if period == 22 then pPOC else p9d[1];
def p10d = if period == 21 then pPOC else p10d[1];

def p1 = if period == 20 then pPOC else p1[1];
def p2 = if period == 19 then pPOC else p2[1];
def p3 = if period == 18 then pPOC else p3[1];
def p4 = if period == 17 then pPOC else p4[1];
def p5 = if period == 16 then pPOC else p5[1];
def p6 = if period == 15 then pPOC else p6[1];
def p7 = if period == 14 then pPOC else p7[1];
def p8 = if period == 13 then pPOC else p8[1];
def p9 = if period == 12 then pPOC else p9[1];
def p10 = if period == 11 then pPOC else p10[1];
def p11 = if period == 10 then pPOC else p11[1];
def p12 = if period == 9 then pPOC else p12[1];
def p13 = if period == 8 then pPOC else p13[1];
def p14 = if period == 7 then pPOC else p14[1];
def p15 = if period == 6 then pPOC else p15[1];
def p16 = if period == 5 then pPOC else p16[1];
def p17 = if period == 4 then pPOC else p17[1];
def p18 = if period == 3 then pPOC else p18[1];
def p19 = if period == 2 then pPOC else p19[1];
def p20 = if period == 1 then pPOC else p20[1];


#Defines Crossing of 'c'(can be defined to be other prices) and a POC at any point after the extended POC line is plotted... initially this is defined as a one.. once crossed it becomes zero
def xp1a = if period[1] == 89 and period == 90 then 1 else if xp1a[1] == 1 and c crosses p1a then 0 else xp1a[1];
def xp2a = if period[1] == 88 and period == 89 then 1 else if xp2a[1] == 1 and c crosses p2a then 0 else xp2a[1];
def xp3a = if period[1] == 87 and period == 88 then 1 else if xp3a[1] == 1 and c crosses p3a then 0 else xp3a[1];
def xp4a = if period[1] == 86 and period == 87 then 1 else if xp4a[1] == 1 and c crosses p4a then 0 else xp4a[1];
def xp5a = if period[1] == 85 and period == 86 then 1 else if xp5a[1] == 1 and c crosses p5a then 0 else xp5a[1];
def xp6a = if period[1] == 84 and period == 85 then 1 else if xp6a[1] == 1 and c crosses p6a then 0 else xp6a[1];
def xp7a = if period[1] == 83 and period == 84 then 1 else if xp7a[1] == 1 and c crosses p7a then 0 else xp7a[1];
def xp8a = if period[1] == 82 and period == 83 then 1 else if xp8a[1] == 1 and c crosses p8a then 0 else xp8a[1];
def xp9a = if period[1] == 81 and period == 82 then 1 else if xp9a[1] == 1 and c crosses p9a then 0 else xp9a[1];
def xp10a = if period[1] == 80 and period == 81 then 1 else if xp10a[1] == 1 and c crosses p10a then 0 else xp10a[1];
def xp11a = if period[1] == 79 and period == 80 then 1 else if xp11a[1] == 1 and c crosses p11a then 0 else xp11a[1];
def xp12a = if period[1] == 78 and period == 79 then 1 else if xp12a[1] == 1 and c crosses p12a then 0 else xp12a[1];
def xp13a = if period[1] == 77 and period == 78 then 1 else if xp13a[1] == 1 and c crosses p13a then 0 else xp13a[1];
def xp14a = if period[1] == 76 and period == 77 then 1 else if xp14a[1] == 1 and c crosses p14a then 0 else xp14a[1];
def xp15a = if period[1] == 75 and period == 76 then 1 else if xp15a[1] == 1 and c crosses p15a then 0 else xp15a[1];
def xp16a = if period[1] == 74 and period == 75 then 1 else if xp16a[1] == 1 and c crosses p16a then 0 else xp16a[1];
def xp17a = if period[1] == 73 and period == 74 then 1 else if xp17a[1] == 1 and c crosses p17a then 0 else xp17a[1];
def xp18a = if period[1] == 72 and period == 73 then 1 else if xp18a[1] == 1 and c crosses p18a then 0 else xp18a[1];
def xp19a = if period[1] == 71 and period == 72 then 1 else if xp19a[1] == 1 and c crosses p19a then 0 else xp19a[1];
def xp20a = if period[1] == 70 and period == 71 then 1 else if xp20a[1] == 1 and c crosses p20a then 0 else xp20a[1];
def xp1b = if period[1] == 69 and period == 70 then 1 else if xp1b[1] == 1 and c crosses p1b then 0 else xp1b[1];
def xp2b = if period[1] == 68 and period == 69 then 1 else if xp2b[1] == 1 and c crosses p2b then 0 else xp2b[1];
def xp3b = if period[1] == 67 and period == 68 then 1 else if xp3b[1] == 1 and c crosses p3b then 0 else xp3b[1];
def xp4b = if period[1] == 66 and period == 67 then 1 else if xp4b[1] == 1 and c crosses p4b then 0 else xp4b[1];
def xp5b = if period[1] == 65 and period == 66 then 1 else if xp5b[1] == 1 and c crosses p5b then 0 else xp5b[1];
def xp6b = if period[1] == 64 and period == 65 then 1 else if xp6b[1] == 1 and c crosses p6b then 0 else xp6b[1];
def xp7b = if period[1] == 63 and period == 64 then 1 else if xp7b[1] == 1 and c crosses p7b then 0 else xp7b[1];
def xp8b = if period[1] == 62 and period == 63 then 1 else if xp8b[1] == 1 and c crosses p8b then 0 else xp8b[1];
def xp9b = if period[1] == 61 and period == 62 then 1 else if xp9b[1] == 1 and c crosses p9b then 0 else xp9b[1];
def xp10b = if period[1] == 60 and period == 61 then 1 else if xp10b[1] == 1 and c crosses p10b then 0 else xp10b[1];
def xp11b = if period[1] == 59 and period == 60 then 1 else if xp11b[1] == 1 and c crosses p11b then 0 else xp11b[1];
def xp12b = if period[1] == 58 and period == 59 then 1 else if xp12b[1] == 1 and c crosses p12b then 0 else xp12b[1];
def xp13b = if period[1] == 57 and period == 58 then 1 else if xp13b[1] == 1 and c crosses p13b then 0 else xp13b[1];
def xp14b = if period[1] == 56 and period == 57 then 1 else if xp14b[1] == 1 and c crosses p14b then 0 else xp14b[1];
def xp15b = if period[1] == 55 and period == 56 then 1 else if xp15b[1] == 1 and c crosses p15b then 0 else xp15b[1];
def xp16b = if period[1] == 54 and period == 55 then 1 else if xp16b[1] == 1 and c crosses p16b then 0 else xp16b[1];
def xp17b = if period[1] == 53 and period == 54 then 1 else if xp17b[1] == 1 and c crosses p17b then 0 else xp17b[1];
def xp18b = if period[1] == 52 and period == 53 then 1 else if xp18b[1] == 1 and c crosses p18b then 0 else xp18b[1];
def xp19b = if period[1] == 51 and period == 52 then 1 else if xp19b[1] == 1 and c crosses p19b then 0 else xp19b[1];
def xp20b = if period[1] == 50 and period == 51 then 1 else if xp20b[1] == 1 and c crosses p20b then 0 else xp20b[1];

def xp1c = if period[1] == 49 and period == 50 then 1 else if xp1c[1] == 1 and c crosses p1c then 0 else xp1c[1];
def xp2c = if period[1] == 48 and period == 49 then 1 else if xp2c[1] == 1 and c crosses p2c then 0 else xp2c[1];
def xp3c = if period[1] == 47 and period == 48 then 1 else if xp3c[1] == 1 and c crosses p3c then 0 else xp3c[1];
def xp4c = if period[1] == 46 and period == 47 then 1 else if xp4c[1] == 1 and c crosses p4c then 0 else xp4c[1];
def xp5c = if period[1] == 45 and period == 46 then 1 else if xp5c[1] == 1 and c crosses p5c then 0 else xp5c[1];
def xp6c = if period[1] == 44 and period == 45 then 1 else if xp6c[1] == 1 and c crosses p6c then 0 else xp6c[1];
def xp7c = if period[1] == 43 and period == 44 then 1 else if xp7c[1] == 1 and c crosses p7c then 0 else xp7c[1];
def xp8c = if period[1] == 42 and period == 43 then 1 else if xp8c[1] == 1 and c crosses p8c then 0 else xp8c[1];
def xp9c = if period[1] == 41 and period == 42 then 1 else if xp9c[1] == 1 and c crosses p9c then 0 else xp9c[1];
def xp10c = if period[1] == 40 and period == 41 then 1 else if xp10c[1] == 1 and c crosses p10c then 0 else xp10c[1];
def xp11c = if period[1] == 39 and period == 40 then 1 else if xp11c[1] == 1 and c crosses p11c then 0 else xp11c[1];
def xp12c = if period[1] == 38 and period == 39 then 1 else if xp12c[1] == 1 and c crosses p12c then 0 else xp12c[1];
def xp13c = if period[1] == 37 and period == 38 then 1 else if xp13c[1] == 1 and c crosses p13c then 0 else xp13c[1];
def xp14c = if period[1] == 36 and period == 37 then 1 else if xp14c[1] == 1 and c crosses p14c then 0 else xp14c[1];
def xp15c = if period[1] == 35 and period == 36 then 1 else if xp15c[1] == 1 and c crosses p15c then 0 else xp15c[1];
def xp16c = if period[1] == 34 and period == 35 then 1 else if xp16c[1] == 1 and c crosses p16c then 0 else xp16c[1];
def xp17c = if period[1] == 33 and period == 34 then 1 else if xp17c[1] == 1 and c crosses p17c then 0 else xp17c[1];
def xp18c = if period[1] == 32 and period == 33 then 1 else if xp18c[1] == 1 and c crosses p18c then 0 else xp18c[1];
def xp19c = if period[1] == 31 and period == 32 then 1 else if xp19c[1] == 1 and c crosses p19c then 0 else xp19c[1];
def xp20c = if period[1] == 30 and period == 31 then 1 else if xp20c[1] == 1 and c crosses p20c then 0 else xp20c[1];

def xp1d = if period[1] == 29 and period == 30 then 1 else if xp1d[1] == 1 and c crosses p1d then 0 else xp1d[1];
def xp2d = if period[1] == 28 and period == 29 then 1 else if xp2d[1] == 1 and c crosses p2d then 0 else xp2d[1];
def xp3d = if period[1] == 27 and period == 28 then 1 else if xp3d[1] == 1 and c crosses p3d then 0 else xp3d[1];
def xp4d = if period[1] == 26 and period == 27 then 1 else if xp4d[1] == 1 and c crosses p4d then 0 else xp4d[1];
def xp5d = if period[1] == 25 and period == 26 then 1 else if xp5d[1] == 1 and c crosses p5d then 0 else xp5d[1];
def xp6d = if period[1] == 24 and period == 25 then 1 else if xp6d[1] == 1 and c crosses p6d then 0 else xp6d[1];
def xp7d = if period[1] == 23 and period == 24 then 1 else if xp7d[1] == 1 and c crosses p7d then 0 else xp7d[1];
def xp8d = if period[1] == 22 and period == 23 then 1 else if xp8d[1] == 1 and c crosses p8d then 0 else xp8d[1];
def xp9d = if period[1] == 21 and period == 22 then 1 else if xp9d[1] == 1 and c crosses p9d then 0 else xp9d[1];
def xp10d = if period[1] == 20 and period == 21 then 1 else if xp10d[1] == 1 and c crosses p10d then 0 else xp10d[1];

def xp1 = if period[1] == 19 and period == 20 then 1 else if xp1[1] == 1 and c crosses p1 then 0 else xp1[1];
def xp2 = if period[1] == 18 and period == 19 then 1 else if xp2[1] == 1 and c crosses p2 then 0 else xp2[1];
def xp3 = if period[1] == 17 and period == 18 then 1 else if xp3[1] == 1 and c crosses p3 then 0 else xp3[1];
def xp4 = if period[1] == 16 and period == 17 then 1 else if xp4[1] == 1 and c crosses p4 then 0 else xp4[1];
def xp5 = if period[1] == 15 and period == 16 then 1 else if xp5[1] == 1 and c crosses p5 then 0 else xp5[1];
def xp6 = if period[1] == 14 and period == 15 then 1 else if xp6[1] == 1 and c crosses p6 then 0 else xp6[1];
def xp7 = if period[1] == 13 and period == 14 then 1 else if xp7[1] == 1 and c crosses p7 then 0 else xp7[1];
def xp8 = if period[1] == 12 and period == 13 then 1 else if xp8[1] == 1 and c crosses p8 then 0 else xp8[1];
def xp9 = if period[1] == 11 and period == 12 then 1 else if xp9[1] == 1 and c crosses p9 then 0 else xp9[1];
def xp10 = if period[1] == 10 and period == 11 then 1 else if xp10[1] == 1 and c crosses p10 then 0 else xp10[1];
def xp11 = if period[1] == 9 and period == 10 then 1 else if xp11[1] == 1 and c crosses p11 then 0 else xp11[1];
def xp12 = if period[1] == 8 and period == 9 then 1 else if xp12[1] == 1 and c crosses p12 then 0 else xp12[1];
def xp13 = if period[1] == 7 and period == 8 then 1 else if xp13[1] == 1 and c crosses p13 then 0 else xp13[1];
def xp14 = if period[1] == 6 and period == 7 then 1 else if xp14[1] == 1 and c crosses p14 then 0 else xp14[1];
def xp15 = if period[1] == 5 and period == 6 then 1 else if xp15[1] == 1 and c crosses p15 then 0 else xp15[1];
def xp16 = if period[1] == 4 and period == 5 then 1 else if xp16[1] == 1 and c crosses p16 then 0 else xp16[1];
def xp17 = if period[1] == 3 and period == 4 then 1 else if xp17[1] == 1 and c crosses p17 then 0 else xp17[1];
def xp18 = if period[1] == 2 and period == 3 then 1 else if xp18[1] == 1 and c crosses p18 then 0 else xp18[1];
def xp19 = if period[1] == 1 and period == 2 then 1 else if xp19[1] == 1 and c crosses p19 then 0 else xp19[1];
def xp20 = if period[1] == 0 and period == 1 then 1 else if xp20[1] == 1 and c crosses p20 then 0 else xp20[1];

#Plots of Extended POC for each day until a crossing of it occurs... the 'period < 90' prohibits the plot of the POC for periods prior to the day each POC is generated ... the 'xp1a == 0' stops the plot of each POC from the point the crossing has occurred
plot poc1a = if period < 90 or xp1a == 0 then Double.NaN else p1a;
plot poc2a = if period < 89 or xp2a == 0 then Double.NaN else p2a;
plot poc3a = if period < 88 or xp3a == 0 then Double.NaN else p3a;
plot poc4a = if period < 87 or xp4a == 0 then Double.NaN else p4a;
plot poc5a = if period < 86 or xp5a == 0 then Double.NaN else p5a;
plot poc6a = if period < 85 or xp6a == 0 then Double.NaN else p6a;
plot poc7a = if period < 84 or xp7a == 0 then Double.NaN else p7a;
plot poc8a = if period < 83 or xp8a == 0 then Double.NaN else p8a;
plot poc9a = if period < 82 or xp9a == 0 then Double.NaN else p9a;
plot poc10a = if period < 81 or xp10a == 0 then Double.NaN else p10a;
plot poc11a = if period < 80 or xp11a == 0 then Double.NaN else p11a;
plot poc12a = if period < 79 or xp12a == 0 then Double.NaN else p12a;
plot poc13a = if period < 78 or xp13a == 0 then Double.NaN else p13a;
plot poc14a = if period < 77 or xp14a == 0 then Double.NaN else p14a;
plot poc15a = if period < 76 or xp15a == 0 then Double.NaN else p15a;
plot poc16a = if period < 75 or xp16a == 0 then Double.NaN else p16a;
plot poc17a = if period < 74 or xp17a == 0 then Double.NaN else p17a;
plot poc18a = if period < 73 or xp18a == 0 then Double.NaN else p18a;
plot poc19a = if period < 72 or xp19a == 0 then Double.NaN else p19a;
plot poc20a = if period < 71 or xp20a == 0 then Double.NaN else p20a;

plot poc1b = if period < 70 or xp1b == 0 then Double.NaN else p1b;
plot poc2b = if period < 69 or xp2b == 0 then Double.NaN else p2b;
plot poc3b = if period < 68 or xp3b == 0 then Double.NaN else p3b;
plot poc4b = if period < 67 or xp4b == 0 then Double.NaN else p4b;
plot poc5b = if period < 66 or xp5b == 0 then Double.NaN else p5b;
plot poc6b = if period < 65 or xp6b == 0 then Double.NaN else p6b;
plot poc7b = if period < 64 or xp7b == 0 then Double.NaN else p7b;
plot poc8b = if period < 63 or xp8b == 0 then Double.NaN else p8b;
plot poc9b = if period < 62 or xp9b == 0 then Double.NaN else p9b;
plot poc10b = if period < 61 or xp10b == 0 then Double.NaN else p10b;
plot poc11b = if period < 60 or xp11b == 0 then Double.NaN else p11b;
plot poc12b = if period < 59 or xp12b == 0 then Double.NaN else p12b;
plot poc13b = if period < 58 or xp13b == 0 then Double.NaN else p13b;
plot poc14b = if period < 57 or xp14b == 0 then Double.NaN else p14b;
plot poc15b = if period < 56 or xp15b == 0 then Double.NaN else p15b;
plot poc16b = if period < 55 or xp16b == 0 then Double.NaN else p16b;
plot poc17b = if period < 54 or xp17b == 0 then Double.NaN else p17b;
plot poc18b = if period < 53 or xp18b == 0 then Double.NaN else p18b;
plot poc19b = if period < 52 or xp19b == 0 then Double.NaN else p19b;
plot poc20b = if period < 51 or xp20b == 0 then Double.NaN else p20b;

plot poc1c = if period < 50 or xp1c == 0 then Double.NaN else p1c;
plot poc2c = if period < 49 or xp2c == 0 then Double.NaN else p2c;
plot poc3c = if period < 48 or xp3c == 0 then Double.NaN else p3c;
plot poc4c = if period < 47 or xp4c == 0 then Double.NaN else p4c;
plot poc5c = if period < 46 or xp5c == 0 then Double.NaN else p5c;
plot poc6c = if period < 45 or xp6c == 0 then Double.NaN else p6c;
plot poc7c = if period < 44 or xp7c == 0 then Double.NaN else p7c;
plot poc8c = if period < 43 or xp8c == 0 then Double.NaN else p8c;
plot poc9c = if period < 42 or xp9c == 0 then Double.NaN else p9c;
plot poc10c = if period < 41 or xp10c == 0 then Double.NaN else p10c;
plot poc11c = if period < 40 or xp11c == 0 then Double.NaN else p11c;
plot poc12c = if period < 39 or xp12c == 0 then Double.NaN else p12c;
plot poc13c = if period < 38 or xp13c == 0 then Double.NaN else p13c;
plot poc14c = if period < 37 or xp14c == 0 then Double.NaN else p14c;
plot poc15c = if period < 36 or xp15c == 0 then Double.NaN else p15c;
plot poc16c = if period < 35 or xp16c == 0 then Double.NaN else p16c;
plot poc17c = if period < 34 or xp17c == 0 then Double.NaN else p17c;
plot poc18c = if period < 33 or xp18c == 0 then Double.NaN else p18c;
plot poc19c = if period < 32 or xp19c == 0 then Double.NaN else p19c;
plot poc20c = if period < 31 or xp20c == 0 then Double.NaN else p20c;

plot poc1d = if period < 30 or xp1d == 0 then Double.NaN else p1d;
plot poc2d = if period < 29 or xp2d == 0 then Double.NaN else p2d;
plot poc3d = if period < 28 or xp3d == 0 then Double.NaN else p3d;
plot poc4d = if period < 27 or xp4d == 0 then Double.NaN else p4d;
plot poc5d = if period < 26 or xp5d == 0 then Double.NaN else p5d;
plot poc6d = if period < 25 or xp6d == 0 then Double.NaN else p6d;
plot poc7d = if period < 24 or xp7d == 0 then Double.NaN else p7d;
plot poc8d = if period < 23 or xp8d == 0 then Double.NaN else p8d;
plot poc9d = if period < 22 or xp9d == 0 then Double.NaN else p9d;
plot poc10d = if period < 21 or xp10d == 0 then Double.NaN else p10d;

plot poc1 = if period < 20 or xp1 == 0 then Double.NaN else p1;
plot poc2 = if period < 19 or xp2 == 0 then Double.NaN else p2;
plot poc3 = if period < 18 or xp3 == 0 then Double.NaN else p3;
plot poc4 = if period < 17 or xp4 == 0 then Double.NaN else p4;
plot poc5 = if period < 16 or xp5 == 0 then Double.NaN else p5;
plot poc6 = if period < 15 or xp6 == 0 then Double.NaN else p6;
plot poc7 = if period < 14 or xp7 == 0 then Double.NaN else p7;
plot poc8 = if period < 13 or xp8 == 0 then Double.NaN else p8;
plot poc9 = if period < 12 or xp9 == 0 then Double.NaN else p9;
plot poc10 = if period < 11 or xp10 == 0 then Double.NaN else p10;
plot poc11 = if period < 10 or xp11 == 0 then Double.NaN else p11;
plot poc12 = if period < 9 or xp12 == 0 then Double.NaN else p12;
plot poc13 = if period < 8 or xp13 == 0 then Double.NaN else p13;
plot poc14 = if period < 7 or xp14 == 0 then Double.NaN else p14;
plot poc15 = if period < 6 or xp15 == 0 then Double.NaN else p15;
plot poc16 = if period < 5 or xp16 == 0 then Double.NaN else p16;
plot poc17 = if period < 4 or xp17 == 0 then Double.NaN else p17;
plot poc18 = if period < 3 or xp18 == 0 then Double.NaN else p18;
plot poc19 = if period < 2 or xp19 == 0 then Double.NaN else p19;
plot poc20 = if period < 1 or xp20 == 0 then Double.NaN else p20;


#Color and Line Weight
DefineGlobalColor("POC",Color.BLACK);

poc1.setDefaultColor(globalColor("POC"));
poc2.setDefaultColor(globalColor("POC"));
poc3.setDefaultColor(globalColor("POC"));
poc4.setDefaultColor(globalColor("POC"));
poc5.setDefaultColor(globalColor("POC"));
poc6.setDefaultColor(globalColor("POC"));
poc7.setDefaultColor(globalColor("POC"));
poc8.setDefaultColor(globalColor("POC"));
poc9.setDefaultColor(globalColor("POC"));
poc10.setDefaultColor(globalColor("POC"));
poc11.setDefaultColor(globalColor("POC"));
poc12.setDefaultColor(globalColor("POC"));
poc13.setDefaultColor(globalColor("POC"));
poc14.setDefaultColor(globalColor("POC"));
poc15.setDefaultColor(globalColor("POC"));
poc16.setDefaultColor(globalColor("POC"));
poc17.setDefaultColor(globalColor("POC"));
poc18.setDefaultColor(globalColor("POC"));
poc19.setDefaultColor(globalColor("POC"));
poc20.setDefaultColor(globalColor("POC"));

poc1a.setDefaultColor(globalColor("POC"));
poc2a.setDefaultColor(globalColor("POC"));
poc3a.setDefaultColor(globalColor("POC"));
poc4a.setDefaultColor(globalColor("POC"));
poc5a.setDefaultColor(globalColor("POC"));
poc6a.setDefaultColor(globalColor("POC"));
poc7a.setDefaultColor(globalColor("POC"));
poc8a.setDefaultColor(globalColor("POC"));
poc9a.setDefaultColor(globalColor("POC"));
poc10a.setDefaultColor(globalColor("POC"));
poc11a.setDefaultColor(globalColor("POC"));
poc12a.setDefaultColor(globalColor("POC"));
poc13a.setDefaultColor(globalColor("POC"));
poc14a.setDefaultColor(globalColor("POC"));
poc15a.setDefaultColor(globalColor("POC"));
poc16a.setDefaultColor(globalColor("POC"));
poc17a.setDefaultColor(globalColor("POC"));
poc18a.setDefaultColor(globalColor("POC"));
poc19a.setDefaultColor(globalColor("POC"));
poc20a.setDefaultColor(globalColor("POC"));

poc1b.setDefaultColor(globalColor("POC"));
poc2b.setDefaultColor(globalColor("POC"));
poc3b.setDefaultColor(globalColor("POC"));
poc4b.setDefaultColor(globalColor("POC"));
poc5b.setDefaultColor(globalColor("POC"));
poc6b.setDefaultColor(globalColor("POC"));
poc7b.setDefaultColor(globalColor("POC"));
poc8b.setDefaultColor(globalColor("POC"));
poc9b.setDefaultColor(globalColor("POC"));
poc10b.setDefaultColor(globalColor("POC"));
poc11b.setDefaultColor(globalColor("POC"));
poc12b.setDefaultColor(globalColor("POC"));
poc13b.setDefaultColor(globalColor("POC"));
poc14b.setDefaultColor(globalColor("POC"));
poc15b.setDefaultColor(globalColor("POC"));
poc16b.setDefaultColor(globalColor("POC"));
poc17b.setDefaultColor(globalColor("POC"));
poc18b.setDefaultColor(globalColor("POC"));
poc19b.setDefaultColor(globalColor("POC"));
poc20b.setDefaultColor(globalColor("POC"));

poc1c.setDefaultColor(globalColor("POC"));
poc2c.setDefaultColor(globalColor("POC"));
poc3c.setDefaultColor(globalColor("POC"));
poc4c.setDefaultColor(globalColor("POC"));
poc5c.setDefaultColor(globalColor("POC"));
poc6c.setDefaultColor(globalColor("POC"));
poc7c.setDefaultColor(globalColor("POC"));
poc8c.setDefaultColor(globalColor("POC"));
poc9c.setDefaultColor(globalColor("POC"));
poc10c.setDefaultColor(globalColor("POC"));
poc11c.setDefaultColor(globalColor("POC"));
poc12c.setDefaultColor(globalColor("POC"));
poc13c.setDefaultColor(globalColor("POC"));
poc14c.setDefaultColor(globalColor("POC"));
poc15c.setDefaultColor(globalColor("POC"));
poc16c.setDefaultColor(globalColor("POC"));
poc17c.setDefaultColor(globalColor("POC"));
poc18c.setDefaultColor(globalColor("POC"));
poc19c.setDefaultColor(globalColor("POC"));
poc20c.setDefaultColor(globalColor("POC"));

poc1d.setDefaultColor(globalColor("POC"));
poc2d.setDefaultColor(globalColor("POC"));
poc3d.setDefaultColor(globalColor("POC"));
poc4d.setDefaultColor(globalColor("POC"));
poc5d.setDefaultColor(globalColor("POC"));
poc6d.setDefaultColor(globalColor("POC"));
poc7d.setDefaultColor(globalColor("POC"));
poc8d.setDefaultColor(globalColor("POC"));
poc9d.setDefaultColor(globalColor("POC"));
poc10d.setDefaultColor(globalColor("POC"));

input lineweight = 2;
poc1.setlineWeight(lineweight);
poc2.setlineWeight(lineweight);
poc3.setlineWeight(lineweight);
poc4.setlineWeight(lineweight);
poc5.setlineWeight(lineweight);
poc6.setlineWeight(lineweight);
poc7.setlineWeight(lineweight);
poc8.setlineWeight(lineweight);
poc9.setlineWeight(lineweight);
poc10.setlineWeight(lineweight);
poc11.setlineWeight(lineweight);
poc12.setlineWeight(lineweight);
poc13.setlineWeight(lineweight);
poc14.setlineWeight(lineweight);
poc15.setlineWeight(lineweight);
poc16.setlineWeight(lineweight);
poc17.setlineWeight(lineweight);
poc18.setlineWeight(lineweight);
poc19.setlineWeight(lineweight);
poc20.setlineWeight(lineweight);

poc1a.setlineWeight(lineweight);
poc2a.setlineWeight(lineweight);
poc3a.setlineWeight(lineweight);
poc4a.setlineWeight(lineweight);
poc5a.setlineWeight(lineweight);
poc6a.setlineWeight(lineweight);
poc7a.setlineWeight(lineweight);
poc8a.setlineWeight(lineweight);
poc9a.setlineWeight(lineweight);
poc10a.setlineWeight(lineweight);
poc11a.setlineWeight(lineweight);
poc12a.setlineWeight(lineweight);
poc13a.setlineWeight(lineweight);
poc14a.setlineWeight(lineweight);
poc15a.setlineWeight(lineweight);
poc16a.setlineWeight(lineweight);
poc17a.setlineWeight(lineweight);
poc18a.setlineWeight(lineweight);
poc19a.setlineWeight(lineweight);
poc20a.setlineWeight(lineweight);

poc1b.setlineWeight(lineweight);
poc2b.setlineWeight(lineweight);
poc3b.setlineWeight(lineweight);
poc4b.setlineWeight(lineweight);
poc5b.setlineWeight(lineweight);
poc6b.setlineWeight(lineweight);
poc7b.setlineWeight(lineweight);
poc8b.setlineWeight(lineweight);
poc9b.setlineWeight(lineweight);
poc10b.setlineWeight(lineweight);
poc11b.setlineWeight(lineweight);
poc12b.setlineWeight(lineweight);
poc13b.setlineWeight(lineweight);
poc14b.setlineWeight(lineweight);
poc15b.setlineWeight(lineweight);
poc16b.setlineWeight(lineweight);
poc17b.setlineWeight(lineweight);
poc18b.setlineWeight(lineweight);
poc19b.setlineWeight(lineweight);
poc20b.setlineWeight(lineweight);

poc1c.setlineWeight(lineweight);
poc2c.setlineWeight(lineweight);
poc3c.setlineWeight(lineweight);
poc4c.setlineWeight(lineweight);
poc5c.setlineWeight(lineweight);
poc6c.setlineWeight(lineweight);
poc7c.setlineWeight(lineweight);
poc8c.setlineWeight(lineweight);
poc9c.setlineWeight(lineweight);
poc10c.setlineWeight(lineweight);
poc11c.setlineWeight(lineweight);
poc12c.setlineWeight(lineweight);
poc13c.setlineWeight(lineweight);
poc14c.setlineWeight(lineweight);
poc15c.setlineWeight(lineweight);
poc16c.setlineWeight(lineweight);
poc17c.setlineWeight(lineweight);
poc18c.setlineWeight(lineweight);
poc19c.setlineWeight(lineweight);
poc20c.setlineWeight(lineweight);

poc1d.setlineWeight(lineweight);
poc2d.setlineWeight(lineweight);
poc3d.setlineWeight(lineweight);
poc4d.setlineWeight(lineweight);
poc5d.setlineWeight(lineweight);
poc6d.setlineWeight(lineweight);
poc7d.setlineWeight(lineweight);
poc8d.setlineWeight(lineweight);
poc9d.setlineWeight(lineweight);
poc10d.setlineWeight(lineweight);
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
368 Online
Create Post

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