draw a horizontal line indicator request.

METAL

Well-known member
Plus
Is there a way to draw a horizontal line from the top of wick, bottom of wick, top of body, and low of body on a specific TF for a specific length.
For example: on a 4H TF, I would like a line drawn from the mentioned areas across the current days chart. I would like to be able to specify the length back for it to draw the lines from. Thanks in advance.
 
Maybe someone can help. I have been trying to get this to work and cannot figure out what is wrong. I decided to use the Wolf Wave Trend by Mobius/ @BenTen as a base for the line plots. I do not get any errors but I also do not get any plots.
I am wanting line plots from High, Open, Close, and Low of each 4 hour candle as far back as I need for current trading day. I have been using the "RV strategy" for scalping. I am simply looking for a way to speed up the lines needed for possible reversals with this strategy. It will plot a lot of lines and look crazy, but it does work so far.
I would like to be able to change the aggregation to maybe a day or whatever.
Here is what I have so far. Chat GPT was also used.

Code:
# User Inputs
input length = 10;

# Internal Script Reference
script LinePlot {
    input BarID = 0;
    input Value = 0;
    input BarOrigin = 0;
    def ThisBar = HighestAll(BarOrigin);
    def ValueLine = if BarOrigin == ThisBar
                    then Value
                    else Double.NaN;
    plot P = if ThisBar - BarID <= BarOrigin
             then HighestAll(ValueLine)
             else Double.NaN;
}

# Define Aggregation Period
def agg = AggregationPeriod.FOUR_HOURS;

# Calculate High, Open, Close, Low for each 4-hour bar
def high_4H = high(period = agg);
def open_4H = open(period = agg);
def close_4H = close(period = agg);
def low_4H = low(period = agg);
def x = BarNumber();

# Plots
plot HighLine = LinePlot(BarID = x - HighestAll(x),
                         Value = high_4H,
                         BarOrigin = x);
HighLine.SetDefaultColor(Color.GREEN);

plot OpenLine = LinePlot(BarID = x - HighestAll(x),
                         Value = open_4H,
                         BarOrigin = x);
OpenLine.SetDefaultColor(Color.RED);

plot CloseLine = LinePlot(BarID = x - HighestAll(x),
                          Value = close_4H,
                          BarOrigin = x);
CloseLine.SetDefaultColor(Color.BLUE);

plot LowLine = LinePlot(BarID = x - HighestAll(x),
                        Value = low_4H,
                        BarOrigin = x);
LowLine.SetDefaultColor(Color.ORANGE);
 

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

Maybe someone can help. I have been trying to get this to work and cannot figure out what is wrong. I decided to use the Wolf Wave Trend by Mobius/ @BenTen as a base for the line plots. I do not get any errors but I also do not get any plots.
I am wanting line plots from High, Open, Close, and Low of each 4 hour candle as far back as I need for current trading day. I have been using the "RV strategy" for scalping. I am simply looking for a way to speed up the lines needed for possible reversals with this strategy. It will plot a lot of lines and look crazy, but it does work so far.
I would like to be able to change the aggregation to maybe a day or whatever.
Here is what I have so far. Chat GPT was also used.

Code:
# User Inputs
input length = 10;

# Internal Script Reference
script LinePlot {
    input BarID = 0;
    input Value = 0;
    input BarOrigin = 0;
    def ThisBar = HighestAll(BarOrigin);
    def ValueLine = if BarOrigin == ThisBar
                    then Value
                    else Double.NaN;
    plot P = if ThisBar - BarID <= BarOrigin
             then HighestAll(ValueLine)
             else Double.NaN;
}

# Define Aggregation Period
def agg = AggregationPeriod.FOUR_HOURS;

# Calculate High, Open, Close, Low for each 4-hour bar
def high_4H = high(period = agg);
def open_4H = open(period = agg);
def close_4H = close(period = agg);
def low_4H = low(period = agg);
def x = BarNumber();

# Plots
plot HighLine = LinePlot(BarID = x - HighestAll(x),
                         Value = high_4H,
                         BarOrigin = x);
HighLine.SetDefaultColor(Color.GREEN);

plot OpenLine = LinePlot(BarID = x - HighestAll(x),
                         Value = open_4H,
                         BarOrigin = x);
OpenLine.SetDefaultColor(Color.RED);

plot CloseLine = LinePlot(BarID = x - HighestAll(x),
                          Value = close_4H,
                          BarOrigin = x);
CloseLine.SetDefaultColor(Color.BLUE);

plot LowLine = LinePlot(BarID = x - HighestAll(x),
                        Value = low_4H,
                        BarOrigin = x);
LowLine.SetDefaultColor(Color.ORANGE);

this doesn't plot anything. how can you say it works?

i am confused by this,
each 4 hour candle as far back as I need for current trading day

there are 6.5 hours in a trading day, so 2 4 hour candles. what do you mean go back?
x previous days?
should extended hours be on?
if you want lines from 1 bar to appear on another bar, then you need 2 sets of plots, formulas.
if 3, then 3 sets,...
 
Last edited:
i am confused by this,
each 4 hour candle as far back as I need for current trading day

there are 6.5 hours in a trading day, so 2 4 hour candles. what do you mean go back?
x previous days?
should extended hours be on?
if you want lines from 1 bar to appear on another bar, then you need 2 sets of plots, formulas.
if 3, then 3 sets,...
Sorry for the confusion. When I say as far back as I need, When using this strategy, I need the lines to be in the area/range at current day I am trading. Here is a link to the same exact trading strategy.
.. It would be great if I could pinpoint an area of time that would correlate with the current time so that There isn't too many lines as I believe they may cause lag (correct me if I am wrong about the lag). See Image:
1705160630196.png

1705160969765.png
 
Is there a way to draw a horizontal line from the top of wick, bottom of wick, top of body, and low of body on a specific TF for a specific length.
For example: on a 4H TF, I would like a line drawn from the mentioned areas across the current days chart. I would like to be able to specify the length back for it to draw the lines from. Thanks in advance.


not sure what you are asking for
this finds the 4 hour values of the last candle, then plots 4 lines for those values

Code:
#horz_lines_4hour_01

#https://usethinkscript.com/forums/questions.6/
#draw a horizontal line indicator request.
#METAL   1/12
#1
#Is there a way to draw a horizontal line from the top of wick, bottom of wick, top of body, and low of body on a specific TF for a specific length.
#For example: on a 4H TF, I would like a line drawn from the mentioned areas across the current days chart. I would like to be able to specify the length back for it to draw the lines from. Thanks in advance.


#METAL
#2
#Maybe someone can help. I have been trying to get this to work and cannot figure out what is wrong. I decided to use the Wolf Wave Trend by Mobius/ @BenTen as a base for the line plots. I do not get any errors but I also do not get any plots.
#I am wanting line plots from High, Open, Close, and Low of each 4 hour candle as far back as I need for current trading day. I have been using the "RV strategy" for scalping. I am simply looking for a way to speed up the lines needed for possible reversals with this strategy. It will plot a lot of lines and look crazy, but it does work so far.
#I would like to be able to change the aggregation to maybe a day or whatever.
#Here is what I have so far. Chat GPT was also used.


# User Inputs
input length = 10;

# Internal Script Reference
script LinePlot {
    input BarID = 0;
    input Value = 0;
    input BarOrigin = 0;
    def ThisBar = HighestAll(BarOrigin);
    def ValueLine = if BarOrigin == ThisBar
                    then Value
                    else Double.NaN;
    plot P = if ThisBar - BarID <= BarOrigin
             then HighestAll(ValueLine)
             else Double.NaN;
}

# Define Aggregation Period
def agg = AggregationPeriod.FOUR_HOURS;

# Calculate High, Open, Close, Low for each 4-hour bar
def open_4H = open(period = agg);
def high_4H = high(period = agg);
def low_4H = low(period = agg);
def close_4H = close(period = agg);

def bn = BarNumber();
def na = double.nan;

# find high bar with a price
def lastbn = HighestAll(If(IsNaN(close), 0, bn));
def lastbar = if (bn == lastbn) then 1 else 0;
#def barx = lastbn - bn;

def openline = highestall(if bn == lastbn then open_4h else 0);
def highline = highestall(if bn == lastbn then high_4h else 0);
def lowline = highestall(if bn == lastbn then low_4h else 0);
def closeline = highestall(if bn == lastbn then close_4h else 0);


# Plots
plot zo = if !isnan(close) then openline else na;
plot zh = if !isnan(close) then highline else na;
plot zl = if !isnan(close) then lowline else na;
plot zc = if !isnan(close) then closeline else na;

zo.SetDefaultColor(Color.RED);
zo.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
zh.SetDefaultColor(Color.GREEN);
zh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
zl.SetDefaultColor(Color.ORANGE);
zl.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
zc.SetDefaultColor(Color.BLUE);
zc.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);


AddChartBubble(0, low,
bn + "\n" +
lastbn + "\n" +
open_4H + "\n" +
high_4H + "\n" +
low_4H + "\n" +
close_4H + "\n" +
openline + "\n" 
, Color.YELLOW, no);

#


T hour
fo8rsQm.jpg
 
Sorry for the confusion. When I say as far back as I need, When using this strategy, I need the lines to be in the area/range at current day I am trading. Here is a link to the same exact trading strategy. .. It would be great if I could pinpoint an area of time that would correlate with the current time so that There isn't too many lines as I believe they may cause lag (correct me if I am wrong about the lag). See Image:

sorry, still confused. your choice of words are not describing what has to happen on the chart.
here's some more questions. let's see if we can work this out.

'''I need the lines to be in the area/range at current day I am trading'''
? so you want lines only during the current day?
the current day is always the day that people are trading.


''' It would be great if I could pinpoint an area of time that would correlate with the current time so that There isn't too many lines '''
? do you want lines just during the current day?
or just during the last 4 hour bar ?


throw away your vocabulary and just stare at a chart and imagine what you want to see.
...over which bars do you want to see lines?
.......... current day or all days or ...?
...from which bars do we read OHLC prices?
.......... just the last 4 hour bar ,
.......... the two 4 hour bars of a current day ? or....
 
Maybe someone can help. I have been trying to get this to work and cannot figure out what is wrong. I decided to use the Wolf Wave Trend by Mobius/ @BenTen as a base for the line plots. I do not get any errors but I also do not get any plots.
I am wanting line plots from High, Open, Close, and Low of each 4 hour candle as far back as I need for current trading day. I have been using the "RV strategy" for scalping. I am simply looking for a way to speed up the lines needed for possible reversals with this strategy. It will plot a lot of lines and look crazy, but it does work so far.
I would like to be able to change the aggregation to maybe a day or whatever.
Here is what I have so far. Chat GPT was also used.

Code:
# User Inputs
input length = 10;

# Internal Script Reference
script LinePlot {
    input BarID = 0;
    input Value = 0;
    input BarOrigin = 0;
    def ThisBar = HighestAll(BarOrigin);
    def ValueLine = if BarOrigin == ThisBar
                    then Value
                    else Double.NaN;
    plot P = if ThisBar - BarID <= BarOrigin
             then HighestAll(ValueLine)
             else Double.NaN;
}

# Define Aggregation Period
def agg = AggregationPeriod.FOUR_HOURS;

# Calculate High, Open, Close, Low for each 4-hour bar
def high_4H = high(period = agg);
def open_4H = open(period = agg);
def close_4H = close(period = agg);
def low_4H = low(period = agg);
def x = BarNumber();

# Plots
plot HighLine = LinePlot(BarID = x - HighestAll(x),
                         Value = high_4H,
                         BarOrigin = x);
HighLine.SetDefaultColor(Color.GREEN);

plot OpenLine = LinePlot(BarID = x - HighestAll(x),
                         Value = open_4H,
                         BarOrigin = x);
OpenLine.SetDefaultColor(Color.RED);

plot CloseLine = LinePlot(BarID = x - HighestAll(x),
                          Value = close_4H,
                          BarOrigin = x);
CloseLine.SetDefaultColor(Color.BLUE);

plot LowLine = LinePlot(BarID = x - HighestAll(x),
                        Value = low_4H,
                        BarOrigin = x);
LowLine.SetDefaultColor(Color.ORANGE);

i forgot to show what i found in your code
this fixed ver plots lines, at the right side of chart

here is post #2 code fixed


your thisbar formula will find the barnumber of the bar at the right edge of the chart.
to find the last bar with price data, need to add an if then within the highestall() to presort barnumber data
def ThisBar = HighestAll(if isnan(close) then 0 else BarOrigin);



same with this. your p formula was returning NA. because valueline was sending NA to P formula.
i copied valueline formula and put it within the highestall() , in the p formula and changed non value to 0.

plot P = if ThisBar - BarID <= BarOrigin
then HighestAll(if BarOrigin == ThisBar then Value else 0)
else Double.NaN;


Code:
#horz_lines_4hour_00

#https://usethinkscript.com/forums/questions.6/
#draw a horizontal line indicator request.
#METAL   1/12
#1
#Is there a way to draw a horizontal line from the top of wick, bottom of wick, top of body, and low of body on a specific TF for a specific length.
#For example: on a 4H TF, I would like a line drawn from the mentioned areas across the current days chart. I would like to be able to specify the length back for it to draw the lines from. Thanks in advance.


#METAL
#2
#Maybe someone can help. I have been trying to get this to work and cannot figure out what is wrong. I decided to use the Wolf Wave Trend by Mobius/ @BenTen as a base for the line plots. I do not get any errors but I also do not get any plots.
#I am wanting line plots from High, Open, Close, and Low of each 4 hour candle as far back as I need for current trading day. I have been using the "RV strategy" for scalping. I am simply looking for a way to speed up the lines needed for possible reversals with this strategy. It will plot a lot of lines and look crazy, but it does work so far.
#I would like to be able to change the aggregation to maybe a day or whatever.
#Here is what I have so far. Chat GPT was also used.


# User Inputs
input length = 10;

# Internal Script Reference
script LinePlot {
    input BarID = 0;
    input Value = 0;
    input BarOrigin = 0;
#    def ThisBar = HighestAll(BarOrigin);
    def ThisBar = HighestAll(if isnan(close) then 0 else BarOrigin);


#    def ValueLine = if BarOrigin == ThisBar
#                    then Value
#                    else Double.NaN;
#    plot P = if ThisBar - BarID <= BarOrigin
#             then HighestAll(ValueLine)
#             else Double.NaN;

    plot P = if ThisBar - BarID <= BarOrigin
             then HighestAll(if BarOrigin == ThisBar then Value else 0)
             else Double.NaN;
}

# Define Aggregation Period
def agg = AggregationPeriod.FOUR_HOURS;

# Calculate High, Open, Close, Low for each 4-hour bar
def high_4H = high(period = agg);
def open_4H = open(period = agg);
def close_4H = close(period = agg);
def low_4H = low(period = agg);
def x = BarNumber();

# Plots
plot HighLine = LinePlot(BarID = x - HighestAll(x),
                         Value = high_4H,
                         BarOrigin = x);
HighLine.SetDefaultColor(Color.GREEN);
highline.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot OpenLine = LinePlot(BarID = x - HighestAll(x),
                         Value = open_4H,
                         BarOrigin = x);
OpenLine.SetDefaultColor(Color.RED);
#x.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot CloseLine = LinePlot(BarID = x - HighestAll(x),
                          Value = close_4H,
                          BarOrigin = x);
CloseLine.SetDefaultColor(Color.BLUE);
#x.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot LowLine = LinePlot(BarID = x - HighestAll(x),
                        Value = low_4H,
                        BarOrigin = x);
LowLine.SetDefaultColor(Color.ORANGE);
#x.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);


addchartbubble(0, low,
open_4h + "\n" +
high_4h + "\n" +
low_4h + "\n" +
close_4h + "\n" +
highline + "\n"
, color.yellow, no);
#

TMUS hour
cNgbkig.jpg
 
Last edited:
@halcyonguy Can you get this to plot all lines for all bars up to the time frame? As shown in the images, The strategy requires all of the bars to be plotted from. Also, Is it at all possible with thinkscript to select a price range at which to draw lines from and omit any others outside that range. Like I tried to show in the 2 images? The only reason for this option is to eliminate lag that MAY occur from all of the lines that would be drawn.
 
@halcyonguy Can you get this to plot all lines for all bars up to the time frame? As shown in the images, The strategy requires all of the bars to be plotted from. Also, Is it at all possible with thinkscript to select a price range at which to draw lines from and omit any others outside that range. Like I tried to show in the 2 images? The only reason for this option is to eliminate lag that MAY occur from all of the lines that would be drawn.

Q. Can you get this to plot all lines for all bars up to the time frame?
no. i don't know what that means.
all of the 2nd agg 4 hour bars on a chart ? that could be dozens, meaning dozens of plots.
go read and answer post 6 questions


Q. select a price range at which to draw lines from and omit any others outside that range.
yes i think so. something like, those within some % of current price ?


i watched some of that video. but gained no knowledge form it. just some guy rambling on for 30 minutes.
i don't watch videos to figure out what someone wants.
that is the job of the person asking the question, to watch a video and then write down a summary of rules that you want applied.
 
Last edited:
Q. Can you get this to plot all lines for all bars up to the time frame?
no. i don't know what that means.
all of the 2nd agg 4 hour bars on a chart ? that could be dozens, meaning dozens of plots.
go read and answer post 6 questions


Q. select a price range at which to draw lines from and omit any others outside that range.
yes i think so. something like, those within some % of current price ?


i watched some of that video. but gained no knowledge form it. just some guy rambling on for 30 minutes.
i don't watch videos to figure out what someone wants.
that is the job of the person asking the question, to watch a video and then write down a summary of rules that you want applied.
 
I am obviously bad at explaining. Sorry about that.
Q. Can you get this to plot all lines for all bars up to the time frame?
Yes. All of the lines from every 4H Candles OHLC that is within a % of the current price range.

I hoped my image would help to explain what I would like to make happen. Let's say that the Price % Range option is doable, then I would like for all of the OHLC lines that are within that range to be plotted. These lines become points of support/resistance for this strategy.
The strategy is a range bound strategy that is determined by a specific ATR range. The ATR range is derived from the last days candle close. So we take the last days ATR value and divide it in half. We take that value and subtract it from Previous days close. This will be low of the range. We then add that half ATR value to the previous days close. This will be the upper range line. I have a code that plots this range for me.
This is the price range area that I would like to plot all of the 4H lines.

I di not think of this before but maybe the ATR range line code can be used to determine the % of price range to plot from.
Here is the ATR range code we use:
Code:
# Half ATR Previous Day

input showlastdayonly = yes;
input length = 14;
input averageType = AverageType.WILDERS;
input agg = AggregationPeriod.DAY;

def ATR = MovingAverage(averageType, TrueRange(high(period = agg), close(period = agg), low(period = agg)), length);
def halfAtr = ATR / 2;

def prevClose = close(period = agg)[1];

def ATR_High = if !IsNaN(prevClose) then prevClose + halfAtr else Double.NaN;
def ATR_Low = if !IsNaN(prevClose) then prevClose - halfAtr else Double.NaN;

plot UpperLine = if GetDay() != GetLastDay() and showlastdayonly then Double.NaN else CompoundValue(1, ATR_High, ATR_High);
UpperLine.SetLineWeight(2);
UpperLine.SetDefaultColor(Color.GREEN);

plot LowerLine = if GetDay() != GetLastDay() and showlastdayonly then Double.NaN else CompoundValue(1, ATR_Low, ATR_Low);
LowerLine.SetLineWeight(2);
LowerLine.SetDefaultColor(Color.RED);

1705201642688.png

1705201925981.png

I hope I have explained it well enough. Thanks for your efforts and patience.
 
I am obviously bad at explaining. Sorry about that.
Q. Can you get this to plot all lines for all bars up to the time frame?
Yes. All of the lines from every 4H Candles OHLC that is within a % of the current price range.

I hoped my image would help to explain what I would like to make happen. Let's say that the Price % Range option is doable, then I would like for all of the OHLC lines that are within that range to be plotted. These lines become points of support/resistance for this strategy.
The strategy is a range bound strategy that is determined by a specific ATR range. The ATR range is derived from the last days candle close. So we take the last days ATR value and divide it in half. We take that value and subtract it from Previous days close. This will be low of the range. We then add that half ATR value to the previous days close. This will be the upper range line. I have a code that plots this range for me.
This is the price range area that I would like to plot all of the 4H lines.

I di not think of this before but maybe the ATR range line code can be used to determine the % of price range to plot from.
Here is the ATR range code we use:
Code:
# Half ATR Previous Day

input showlastdayonly = yes;
input length = 14;
input averageType = AverageType.WILDERS;
input agg = AggregationPeriod.DAY;

def ATR = MovingAverage(averageType, TrueRange(high(period = agg), close(period = agg), low(period = agg)), length);
def halfAtr = ATR / 2;

def prevClose = close(period = agg)[1];

def ATR_High = if !IsNaN(prevClose) then prevClose + halfAtr else Double.NaN;
def ATR_Low = if !IsNaN(prevClose) then prevClose - halfAtr else Double.NaN;

plot UpperLine = if GetDay() != GetLastDay() and showlastdayonly then Double.NaN else CompoundValue(1, ATR_High, ATR_High);
UpperLine.SetLineWeight(2);
UpperLine.SetDefaultColor(Color.GREEN);

plot LowerLine = if GetDay() != GetLastDay() and showlastdayonly then Double.NaN else CompoundValue(1, ATR_Low, ATR_Low);
LowerLine.SetLineWeight(2);
LowerLine.SetDefaultColor(Color.RED);

View attachment 20703
View attachment 20704
I hope I have explained it well enough. Thanks for your efforts and patience.

Metal, this might help. It is adapting some poc related code to your request.

1.You can change the aggregation, price at the input screen.
The plot range ATR limiter was changed to a Percentage (instead of half).
2. It seems to work on 10D 1m chart you used in your post.
3. The image shows 3 versions (high,close,low) of the following plus a 4hr candle overlay for reference.
The Percentage of ATR was changed within one of the 3 scripts def statement so that it changed
it for all 3.
The 4hr Candle script was added for some visual testing.
Screenshot 2024-01-15 090409.png
Screenshot 2024-01-15 090558.png
Code:
input agg   = AggregationPeriod.FOUR_HOURS;
input price = FundamentalType.HIGH;
def hva = if IsNaN(Fundamental(price, period = agg)) then hva[1] else Fundamental(price, period = agg);
def period  = if !IsNaN(close) and hva != hva[1] then period[1] + 1 else period[1];

######################## Line plot basis limited to Range Between Upperline/Lowerline
# Percentage of ATR Previous Day Added to Prior Day Close

def Percentage = 70;

input showlastdayonly = no;
input length = 14;
input averageType = AverageType.WILDERS;
input aggregationPeriod = AggregationPeriod.DAY;

def ATR = MovingAverage(averageType, TrueRange(high(period = aggregationPeriod), close(period = aggregationPeriod), low(period = aggregationPeriod)), length);
def halfAtr = ATR * percentage / 100;

def prevClose = close(period = aggregationPeriod)[1];

def ATR_High = if !IsNaN(prevClose) then prevClose + halfAtr else Double.NaN;
def ATR_Low = if !IsNaN(prevClose) then prevClose - halfAtr else Double.NaN;

plot UpperLine = #if GetDay() != GetLastDay() and showlastdayonly then Double.NaN else
HighestAll(if GetDay() == GetLastDay() then CompoundValue(1, ATR_High, ATR_High) else Double.NaN);
UpperLine.SetLineWeight(5);
UpperLine.SetDefaultColor(Color.GREEN);

plot LowerLine = #if GetDay() != GetLastDay() and showlastdayonly then Double.NaN else
LowestAll(if GetDay() == GetLastDay() then CompoundValue(1, ATR_Low, ATR_Low) else Double.NaN);
LowerLine.SetLineWeight(5);
LowerLine.SetDefaultColor(Color.RED);
########################

def phva = if Between(hva, LowerLine, UpperLine) then hva else Double.NaN;


#Extends Plot of pHVA (Point of Control) for each day to the right

def p1a = if period == 90 then phva else p1a[1];
def p2a = if period == 89 then phva else p2a[1];
def p3a = if period == 88 then phva else p3a[1];
def p4a = if period == 87 then phva else p4a[1];
def p5a = if period == 86 then phva else p5a[1];
def p6a = if period == 85 then phva else p6a[1];
def p7a = if period == 84 then phva else p7a[1];
def p8a = if period == 83 then phva else p8a[1];
def p9a = if period == 82 then phva else p9a[1];
def p10a = if period == 81 then phva else p10a[1];
def p11a = if period == 80 then phva else p11a[1];
def p12a = if period == 79 then phva else p12a[1];
def p13a = if period == 78 then phva else p13a[1];
def p14a = if period == 77 then phva else p14a[1];
def p15a = if period == 76 then phva else p15a[1];
def p16a = if period == 75 then phva else p16a[1];
def p17a = if period == 74 then phva else p17a[1];
def p18a = if period == 73 then phva else p18a[1];
def p19a = if period == 72 then phva else p19a[1];
def p20a = if period == 71 then phva else p20a[1];

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

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

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

def p1 = if period == 20 then phva else p1[1];
def p2 = if period == 19 then phva else p2[1];
def p3 = if period == 18 then phva else p3[1];
def p4 = if period == 17 then phva else p4[1];
def p5 = if period == 16 then phva else p5[1];
def p6 = if period == 15 then phva else p6[1];
def p7 = if period == 14 then phva else p7[1];
def p8 = if period == 13 then phva else p8[1];
def p9 = if period == 12 then phva else p9[1];
def p10 = if period == 11 then phva else p10[1];
def p11 = if period == 10 then phva else p11[1];
def p12 = if period == 9 then phva else p12[1];
def p13 = if period == 8 then phva else p13[1];
def p14 = if period == 7 then phva else p14[1];
def p15 = if period == 6 then phva else p15[1];
def p16 = if period == 5 then phva else p16[1];
def p17 = if period == 4 then phva else p17[1];
def p18 = if period == 3 then phva else p18[1];
def p19 = if period == 2 then phva else p19[1];
def p20 = if period == 1 then phva else p20[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 then Double.NaN else p1a;
plot poc2a = if period < 89 then Double.NaN else p2a;
plot poc3a = if period < 88 then Double.NaN else p3a;
plot poc4a = if period < 87 then Double.NaN else p4a;
plot poc5a = if period < 86 then Double.NaN else p5a;
plot poc6a = if period < 85 then Double.NaN else p6a;
plot poc7a = if period < 84 then Double.NaN else p7a;
plot poc8a = if period < 83 then Double.NaN else p8a;
plot poc9a = if period < 82 then Double.NaN else p9a;
plot poc10a = if period < 81 then Double.NaN else p10a;
plot poc11a = if period < 80 then Double.NaN else p11a;
plot poc12a = if period < 79 then Double.NaN else p12a;
plot poc13a = if period < 78 then Double.NaN else p13a;
plot poc14a = if period < 77 then Double.NaN else p14a;
plot poc15a = if period < 76 then Double.NaN else p15a;
plot poc16a = if period < 75 then Double.NaN else p16a;
plot poc17a = if period < 74 then Double.NaN else p17a;
plot poc18a = if period < 73 then Double.NaN else p18a;
plot poc19a = if period < 72 then Double.NaN else p19a;
plot poc20a = if period < 71 then Double.NaN else p20a;

plot poc1b = if period < 70 then Double.NaN else p1b;
plot poc2b = if period < 69 then Double.NaN else p2b;
plot poc3b = if period < 68 then Double.NaN else p3b;
plot poc4b = if period < 67 then Double.NaN else p4b;
plot poc5b = if period < 66 then Double.NaN else p5b;
plot poc6b = if period < 65 then Double.NaN else p6b;
plot poc7b = if period < 64 then Double.NaN else p7b;
plot poc8b = if period < 63 then Double.NaN else p8b;
plot poc9b = if period < 62 then Double.NaN else p9b;
plot poc10b = if period < 61 then Double.NaN else p10b;
plot poc11b = if period < 60 then Double.NaN else p11b;
plot poc12b = if period < 59 then Double.NaN else p12b;
plot poc13b = if period < 58 then Double.NaN else p13b;
plot poc14b = if period < 57 then Double.NaN else p14b;
plot poc15b = if period < 56 then Double.NaN else p15b;
plot poc16b = if period < 55 then Double.NaN else p16b;
plot poc17b = if period < 54 then Double.NaN else p17b;
plot poc18b = if period < 53 then Double.NaN else p18b;
plot poc19b = if period < 52 then Double.NaN else p19b;
plot poc20b = if period < 51 then Double.NaN else p20b;

plot poc1c = if period < 50 then Double.NaN else p1c;
plot poc2c = if period < 49 then Double.NaN else p2c;
plot poc3c = if period < 48 then Double.NaN else p3c;
plot poc4c = if period < 47 then Double.NaN else p4c;
plot poc5c = if period < 46 then Double.NaN else p5c;
plot poc6c = if period < 45 then Double.NaN else p6c;
plot poc7c = if period < 44 then Double.NaN else p7c;
plot poc8c = if period < 43 then Double.NaN else p8c;
plot poc9c = if period < 42 then Double.NaN else p9c;
plot poc10c = if period < 41 then Double.NaN else p10c;
plot poc11c = if period < 40 then Double.NaN else p11c;
plot poc12c = if period < 39 then Double.NaN else p12c;
plot poc13c = if period < 38 then Double.NaN else p13c;
plot poc14c = if period < 37 then Double.NaN else p14c;
plot poc15c = if period < 36 then Double.NaN else p15c;
plot poc16c = if period < 35 then Double.NaN else p16c;
plot poc17c = if period < 34 then Double.NaN else p17c;
plot poc18c = if period < 33 then Double.NaN else p18c;
plot poc19c = if period < 32 then Double.NaN else p19c;
plot poc20c = if period < 31 then Double.NaN else p20c;

plot poc1d = if period < 30 then Double.NaN else p1d;
plot poc2d = if period < 29 then Double.NaN else p2d;
plot poc3d = if period < 28 then Double.NaN else p3d;
plot poc4d = if period < 27 then Double.NaN else p4d;
plot poc5d = if period < 26 then Double.NaN else p5d;
plot poc6d = if period < 25 then Double.NaN else p6d;
plot poc7d = if period < 24 then Double.NaN else p7d;
plot poc8d = if period < 23 then Double.NaN else p8d;
plot poc9d = if period < 22 then Double.NaN else p9d;
plot poc10d = if period < 21 then Double.NaN else p10d;

plot poc1 = if period < 20 then Double.NaN else p1;
plot poc2 = if period < 19 then Double.NaN else p2;
plot poc3 = if period < 18 then Double.NaN else p3;
plot poc4 = if period < 17 then Double.NaN else p4;
plot poc5 = if period < 16 then Double.NaN else p5;
plot poc6 = if period < 15 then Double.NaN else p6;
plot poc7 = if period < 14 then Double.NaN else p7;
plot poc8 = if period < 13 then Double.NaN else p8;
plot poc9 = if period < 12 then Double.NaN else p9;
plot poc10 = if period < 11 then Double.NaN else p10;
plot poc11 = if period < 10 then Double.NaN else p11;
plot poc12 = if period < 9 then Double.NaN else p12;
plot poc13 = if period < 8 then Double.NaN else p13;
plot poc14 = if period < 7 then Double.NaN else p14;
plot poc15 = if period < 6 then Double.NaN else p15;
plot poc16 = if period < 5 then Double.NaN else p16;
plot poc17 = if period < 4 then Double.NaN else p17;
plot poc18 = if period < 3 then Double.NaN else p18;
plot poc19 = if period < 2 then Double.NaN else p19;
plot poc20 = if period < 1 then Double.NaN else p20;


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

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 = 1;
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);
 
Last edited:

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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