# Vertical Line RSI

#### Feniks2020

##### New member
I'm having trouble "finding/correcting the error"...won't accept the last line regardless of what I've tried.
I intend to use the script to track extreme oversold/overbought exhaustion occurrences in my watchlist
Any help would be greatly appreciated!

Code:
``````plot ValueRSUD = RSI()."RSI" + StochRSI()."FullK" + StochasticFull()."FullK";
plot Avg = ValueRSUD / 3;
plot Diff = Avg * 1;
Value.SetDefaultColor(GetColor(1));
Avg.SetDefaultColor(GetColor(8));
Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.RSUD);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.DefineColor("Neutral", Color.BLACK);
Diff.AssignValueColor(if Diff >=83.34 then Diff.Color("Positive and Up")
else if Diff < 83.33 > 76.67 then Diff.Color("Positive and Down")
else if Diff > 23.34 < 76.66 then Diff.Color("Neutral")
else if Diff > 16.67 < 23.34 then Diff.Color("Negative and Down")
else if Diff > 5 < 16.67 then Diff.Color("Negative and Up"));``````

Last edited:
Solution
@Feniks2020 The If/Then/Else statement is incomplete because there is no color definition if Diff is <= 5.
You have to add a final else statement with just the color to use if Diff is <=5.

Also you can't have a compound condition, you have to define them separately and then combine with 'and'

Ruby:
``````Diff.AssignValueColor(if Diff >=83.34 then Diff.Color("Positive and Up")
else if Diff < 83.33 and Diff > 76.67 then Diff.Color("Positive and Down")
else if Diff > 23.34 and Diff < 76.66 then Diff.Color("Neutral")
else if Diff > 16.67 and Diff < 23.34 then Diff.Color("Negative and Down")
else if Diff > 5 and Diff < 16.67 then Diff.Color("Negative and Up")
############################
else <Default Color Here>)...``````
@Feniks2020 The If/Then/Else statement is incomplete because there is no color definition if Diff is <= 5.
You have to add a final else statement with just the color to use if Diff is <=5.

Also you can't have a compound condition, you have to define them separately and then combine with 'and'

Ruby:
``````Diff.AssignValueColor(if Diff >=83.34 then Diff.Color("Positive and Up")
else if Diff < 83.33 and Diff > 76.67 then Diff.Color("Positive and Down")
else if Diff > 23.34 and Diff < 76.66 then Diff.Color("Neutral")
else if Diff > 16.67 and Diff < 23.34 then Diff.Color("Negative and Down")
else if Diff > 5 and Diff < 16.67 then Diff.Color("Negative and Up")
############################
else <Default Color Here>);
############################``````

@Feniks2020 The If/Then/Else statement is incomplete because there is no color definition if Diff is <= 5.
You have to add a final else statement with just the color to use if Diff is <=5.

Also you can't have a compound condition, you have to define them separately and then combine with 'and'

Ruby:
``````Diff.AssignValueColor(if Diff >=83.34 then Diff.Color("Positive and Up")
else if Diff < 83.33 and Diff > 76.67 then Diff.Color("Positive and Down")
else if Diff > 23.34 and Diff < 76.66 then Diff.Color("Neutral")
else if Diff > 16.67 and Diff < 23.34 then Diff.Color("Negative and Down")
else if Diff > 5 and Diff < 16.67 then Diff.Color("Negative and Up")
############################
else <Default Color Here>);
############################``````
Fixed it:
def ValueRSUD = RSI()."RSI" + StochRSI()."FullK" + StochasticFull()."FullK";
def Avg = ValueRSUD/3;
plot Diff = Avg*1;
Diff.DefineColor("RU3", Color.DARK_GREEN);
Diff.DefineColor("RU2", Color.GREEN);
Diff.DefineColor("RU1", Color.LIGHT_GREEN);
Diff.DefineColor("NRML", Color.PINK);
Diff.DefineColor("RD1", Color.RED);
Diff.DefineColor("RD2", Color.DARK_RED);
Diff.DefineColor("RD3", Color.BLACK);
Diff.DefineColor("blk", Color.BLACK);
Diff.DefineColor("wht", Color.WHITE);
Diff.AssignValueColor(if Diff >88.35 then Diff.Color("wht")
else if Diff < 83.33 and Diff > 88.34 then Diff.Color("blk")
else if Diff < 83.32 and Diff > 76.67 then Diff.Color("blk")
else if Diff < 76.66 and Diff > 23.34 then Diff.Color("blk")
else if Diff < 23.33 and Diff > 16.67 then Diff.Color("wht")
else if Diff < 16.66 and Diff > 5 then Diff.Color("wht")
else if Diff < 4.99 and Diff > 0.1 then Diff.Color("wht")
else Color.WHITE);
AssignBackgroundColor(if Diff >=88.35 then Diff.Color("RU3")
else if Diff <= 83.33 and Diff >= 88.34 then Diff.Color("RU2")
else if Diff <= 83.32 and Diff >= 76.67 then Diff.Color("RU1")
else if Diff <= 76.66 and Diff >= 23.34 then Diff.Color("NRML")
else if Diff <= 23.33 and Diff >= 16.67 then Diff.Color("RD1")
else if Diff <= 16.66 and Diff >= 5 then Diff.Color("RD2")
else if Diff <= 4.99 and Diff >= 0.1 then Diff.Color("RD3")
else Color.BLACK);

Fixed it...would it be asking to much to ask you to show me how to add a vertical line on my chart when these conditions are met?????

@Feniks2020 The If/Then/Else statement is incomplete because there is no color definition if Diff is <= 5.
You have to add a final else statement with just the color to use if Diff is <=5.

Also you can't have a compound condition, you have to define them separately and then combine with 'and'

Ruby:
``````Diff.AssignValueColor(if Diff >=83.34 then Diff.Color("Positive and Up")
else if Diff < 83.33 and Diff > 76.67 then Diff.Color("Positive and Down")
else if Diff > 23.34 and Diff < 76.66 then Diff.Color("Neutral")
else if Diff > 16.67 and Diff < 23.34 then Diff.Color("Negative and Down")
else if Diff > 5 and Diff < 16.67 then Diff.Color("Negative and Up")
############################
else <Default Color Here>);
############################``````
#Rev_2

def ValueRSUD = RSI()."RSI" + StochRSI()."FullK" + StochasticFull()."FullK";
def Avg = ValueRSUD/3;
plot Diff = Avg*1;
Diff.DefineColor("RU3", Color.DARK_GREEN);
Diff.DefineColor("RU2", Color.GREEN);
Diff.DefineColor("RU1", Color.LIGHT_GREEN);
Diff.DefineColor("NRML", Color.PINK);
Diff.DefineColor("RD1", Color.RED);
Diff.DefineColor("RD2", Color.DARK_RED);
Diff.DefineColor("RD3", Color.BLACK);
Diff.DefineColor("blk", Color.BLACK);
Diff.DefineColor("wht", Color.WHITE);
Diff.AssignValueColor(if Diff >=88.35 then Diff.Color("wht")
else if Diff <= 88.34 and Diff >= 83.33 then Diff.Color("blk")
else if Diff <= 83.32 and Diff >= 76.67 then Diff.Color("blk")
else if Diff <= 76.66 and Diff >= 23.34 then Diff.Color("blk")
else if Diff <= 23.33 and Diff >= 16.67 then Diff.Color("wht")
else if Diff <= 16.66 and Diff >= 5 then Diff.Color("wht")
else if Diff <= 4.99 and Diff >= 0.1 then Diff.Color("wht")
else Color.WHITE);
AssignBackgroundColor(if Diff >88.35 then Diff.Color("RU3")
else if Diff <= 88.34 and Diff >= 83.33 then Diff.Color("RU2")
else if Diff <= 83.32 and Diff >= 76.67 then Diff.Color("RU1")
else if Diff <= 76.66 and Diff >= 23.34 then Diff.Color("NRML")
else if Diff <= 23.33 and Diff >= 16.67 then Diff.Color("RD1")
else if Diff <= 16.66 and Diff >= 5 then Diff.Color("RD2")
else if Diff <= 4.99 and Diff >= 0.1 then Diff.Color("RD3")
else Color.BLACK);

Last edited:
would it be asking to much to ask you to show me how to add a vertical line on my chart when these conditions are met?????
Or, post a screen shot of your chart and draw where you want the vertical lines.

Or, post a screen shot of your chart and draw where you want the vertical lines.
SRU3
RSI()."RSI" <= 20 and
StochRSI()."FullK" <2.5 and
StochasticFull()."FullK" <2.5
***I want a dark green vertical line to show up on my chart when price action meets these conditions
SRU2
RSI()."RSI" <= 30 and
StochRSI()."FullK"< 3 and
StochasticFull()."FullK" < 3
***I want a green vertical line to show up on my chart when price action meets these conditions
SRU1
RSI()."RSI" <= 30 and
StochRSI()."FullK"< 5 and
StochasticFull()."FullK" < 5
***I want a light green vertical line to show up on my chart when price action meets these conditions

ok.....but my script revision above is for my watchlist.....I'm trying to modify this script so that the colors for RU3, RU2, RU1, RD1, RD2, RD3 will be drawn as a vertical line on my intraday chart in those same colors...the black and white essentially just changed the value colors so I could see them on my watchlist. I want to plot the background colors as vertical lines on my chart

Last edited:
@Feniks2020
Ruby:
``````#SRU3
def VertLine1 = RSI()."RSI" <= 20 and StochRSI()."FullK" <2.5 and StochasticFull()."FullK" <2.5;
#***I want a dark green vertical line to show up on my chart when price action meets these conditions
AddVerticalLine(VertLine1 and !VertLine1[1], "", Color.DARK_GREEN, curve.LONG_DASH);

#SRU2
def VertLine2 = RSI()."RSI" <= 30 and StochRSI()."FullK"< 3 and StochasticFull()."FullK" < 3;
#***I want a green vertical line to show up on my chart when price action meets these conditions
AddVerticalLine(VertLine2 and !VertLine2[1] and !VertLine1, "", Color.GREEN, curve.LONG_DASH);

#SRU1
def VertLine3 = RSI()."RSI" <= 30 and StochRSI()."FullK" < 5 and StochasticFull()."FullK" < 5 ;
#***I want a light green vertical line to show up on my chart when price action meets these conditions
AddVerticalLine(VertLine3 and !VertLine3[1] and !VertLine2 and !VertLine1, "", Color.LIGHT_GREEN, curve.LONG_DASH);``````

ok.....thanks....could you tell me why this doesn't work???? I'm trying to come up with a script that gives my calculations a little "breathing" room

#SRU3_v2
def VertLine1 = (RSI()."RSI" and StochRSI()."FullK" and StochasticFull()."FullK")/3 >=1 and <=8.33;
AddVerticalLine(VertLine1 and !VertLine1[1], "", Color.DARK_GREEN, curve.LONG_DASH);

#SRU2_v2
def VertLine2 = (RSI()."RSI" and StochRSI()."FullK" and StochasticFull()."FullK")/3 >=8.34 and <=10.34;
AddVerticalLine(VertLine2 and !VertLine2[1], "", Color.GREEN, curve.LONG_DASH);

#SRU1_v2
def VertLine3 = (RSI()."RSI" and StochRSI()."FullK" and StochasticFull()."FullK")/3 >=10.35 and <=13.33;
AddVerticalLine(VertLine3 and !VertLine3[1], "", Color.LIGHT_GREEN, curve.LONG_DASH);

Last edited:
@Feniks2020
Ruby:
``````#SRU3
def VertLine1 = RSI()."RSI" <= 20 and StochRSI()."FullK" <2.5 and StochasticFull()."FullK" <2.5;
#***I want a dark green vertical line to show up on my chart when price action meets these conditions
AddVerticalLine(VertLine1 and !VertLine1[1], "", Color.DARK_GREEN, curve.LONG_DASH);

#SRU2
def VertLine2 = RSI()."RSI" <= 30 and StochRSI()."FullK"< 3 and StochasticFull()."FullK" < 3;
#***I want a green vertical line to show up on my chart when price action meets these conditions
AddVerticalLine(VertLine2 and !VertLine2[1] and !VertLine1, "", Color.GREEN, curve.LONG_DASH);

#SRU1
def VertLine3 = RSI()."RSI" <= 30 and StochRSI()."FullK" < 5 and StochasticFull()."FullK" < 5 ;
#***I want a light green vertical line to show up on my chart when price action meets these conditions
AddVerticalLine(VertLine3 and !VertLine3[1] and !VertLine2 and !VertLine1, "", Color.LIGHT_GREEN, curve.LONG_DASH);``````
Thank you for your input.....this is my finished v1 script

#SRU3
def VertLine1 =
RSI()."RSI" <= 20 and
StochRSI()."FullK" <=2.5 and
StochasticFull()."FullK" <=2.5;
AddVerticalLine(VertLine1 and !VertLine1[1], "", Color.DARK_GREEN, curve.LONG_DASH);

#SRU2
def VertLine2 =
RSI()."RSI" <= 25 and RSI()."RSI" >= 20.01 and
StochRSI()."FullK" >=2.51 and StochRSI()."FullK"<= 3 and
StochasticFull()."FullK" >=2.51 and StochasticFull()."FullK" <=3;
AddVerticalLine(VertLine2 and !VertLine2[1], "", Color.GREEN, curve.LONG_DASH);

#SRU1
def VertLine3 =
RSI()."RSI" <= 30 and RSI()."RSI" >= 25.01 and
StochRSI()."FullK" >=3.01 and StochRSI()."FullK"<= 5 and
StochasticFull()."FullK" >=3.01 and StochasticFull()."FullK" <=5;
AddVerticalLine(VertLine3 and !VertLine3[1], "", Color.LIGHT_GREEN, curve.LONG_DASH);

#This won't work and I don't know why
# I want a DARK GREEN line tp show up when the avg of RSI , StochRSI and Stochastic Full K is less than 8.33 but greater than 1

def VertLine1 = (RSI()."RSI" and StochRSI()."FullK" and StochasticFull()."FullK")/3 >=1 and <=8.33;
AddVerticalLine(VertLine1 and !VertLine1[1], "", Color.DARK_GREEN, curve.LONG_DASH);

#This won't work and I don't know why
# I want a DARK GREEN line tp show up when the avg of RSI , StochRSI and Stochastic Full K is less than 8.33 but greater than 1

def VertLine1 = (RSI()."RSI" and StochRSI()."FullK" and StochasticFull()."FullK")/3 >=1 and <=8.33;
AddVerticalLine(VertLine1 and !VertLine1[1], "", Color.DARK_GREEN, curve.LONG_DASH);

See if this helps

Code:
``````plot x = (RSI()."RSI" + StochRSI()."FullK" + StochasticFull()."FullK") / 3;
def VertLine1 = Between(x, 1, 8.33);
AddVerticalLine(VertLine1 == 1, "", Color.DARK_GREEN, Curve.LONG_DASH);``````

See if this helps
plot x1 = (RSI()."RSI" + StochRSI()."FullK" + StochasticFull()."FullK") / 3;
def VertLine1 = Between(x, 1, 8.33);
AddVerticalLine(VertLine1 == 1, "", Color.DARK_GREEN, Curve.LONG_DASH);

plot x2 = (RSI()."RSI" + StochRSI()."FullK" + StochasticFull()."FullK") / 3;
def VertLine2 = Between(x2, 8.34, 10.33);
AddVerticalLine(VertLine2 == 1, "", Color.GREEN, Curve.LONG_DASH);

plot x3 = (RSI()."RSI" + StochRSI()."FullK" + StochasticFull()."FullK") / 3;
def VertLine3 = Between(x3, 10.34, 13.34);
AddVerticalLine(VertLine3 == 1, "", Color.LIGHT.GREEN, Curve.LONG_DASH);

plot x4 = (RSI()."RSI" + StochRSI()."FullK" + StochasticFull()."FullK") / 3;
def VertLine4 = Between(x4, 83.33, 86.65);
AddVerticalLine(VertLine4 == 1, "", Color.PINK, Curve.LONG_DASH);

plot x5 = (RSI()."RSI" + StochRSI()."FullK" + StochasticFull()."FullK") / 3;
def VertLine5 = Between(x5, 86.66, 91.65);
AddVerticalLine(VertLine5 == 1, "", Color.RED, Curve.LONG_DASH);

plot x6 = (RSI()."RSI" + StochRSI()."FullK" + StochasticFull()."FullK") / 3;
def VertLine6 = Between(x6, 91.66, 100);
AddVerticalLine(VertLine6 == 1, "", Color.DARK.RED, Curve.LONG_DASH);

Getting errors when I try to add to the script at VertLine 3 and VertLine 6....am I making this too complicated????
these are the values and colors I'm trying to use:
=1 and <=8.33 DARK.GREEN
=8.34 and <=10.33 GREEN
=10.34 and <=13.33 LIGHT.GREEN
=83.33 and <=86.65 PINK
=86.66 and <=91.65 RED
=91.66 and <=100 DARK.RED
I put greater than symbols at the beginning of each line but they are not showing

Last edited:
plot x1 = (RSI()."RSI" + StochRSI()."FullK" + StochasticFull()."FullK") / 3;
def VertLine1 = Between(x, 1, 8.33);
AddVerticalLine(VertLine1 == 1, "", Color.DARK_GREEN, Curve.LONG_DASH);

plot x2 = (RSI()."RSI" + StochRSI()."FullK" + StochasticFull()."FullK") / 3;
def VertLine2 = Between(x2, 8.34, 10.33);
AddVerticalLine(VertLine2 == 1, "", Color.GREEN, Curve.LONG_DASH);

plot x3 = (RSI()."RSI" + StochRSI()."FullK" + StochasticFull()."FullK") / 3;
def VertLine3 = Between(x3, 10.34, 13.34);
AddVerticalLine(VertLine3 == 1, "", Color.LIGHT.GREEN, Curve.LONG_DASH);

plot x4 = (RSI()."RSI" + StochRSI()."FullK" + StochasticFull()."FullK") / 3;
def VertLine4 = Between(x4, 83.33, 86.65);
AddVerticalLine(VertLine4 == 1, "", Color.PINK, Curve.LONG_DASH);

plot x5 = (RSI()."RSI" + StochRSI()."FullK" + StochasticFull()."FullK") / 3;
def VertLine5 = Between(x5, 86.66, 91.65);
AddVerticalLine(VertLine5 == 1, "", Color.RED, Curve.LONG_DASH);

plot x6 = (RSI()."RSI" + StochRSI()."FullK" + StochasticFull()."FullK") / 3;
def VertLine6 = Between(x6, 91.66, 100);
AddVerticalLine(VertLine6 == 1, "", Color.DARK.RED, Curve.LONG_DASH);

Getting errors when I try to add to the script at VertLine 3 and VertLine 6....am I making this too complicated????
these are the values and colors I'm trying to use:

Correct these lines to fix it.

def VertLine1 = Between(x1, 1, 8.33);

AddVerticalLine(VertLine3 == 1, "", Color.LIGHT_GREEN, Curve.LONG_DASH);

AddVerticalLine(VertLine6 == 1, "", Color.DARK_RED, Curve.LONG_DASH);

Correct these lines to fix it.

def VertLine1 = Between(x1, 1, 8.33);

AddVerticalLine(VertLine3 == 1, "", Color.LIGHT_GREEN, Curve.LONG_DASH);

AddVerticalLine(VertLine6 == 1, "", Color.DARK_RED, Curve.LONG_DASH);
Thank You!!!!

87k+ Posts
342 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?