# Looking For A Dynamic Price Indicator Line

#### dpxpress

##### New member
Hi I was wondering if anyone could quickly help me combine two scripts?
the first tracks price more accurately. I want to use those inputs with the plot options of mobius' code. Here is the first code
----------------
##k_kirill code posted in 2020

input lineLength = 100;

def lastBar = !IsNaN(close) && IsNaN(close[-1]);
def lastClose = if lastBar then close else lastClose[1];

plot PriceIndicatorLine = if IsNaN(close[-lineLength - 1]) then lastClose[-lineLength] else Double.NaN;
PriceIndicatorLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PriceIndicatorLine.SetDefaultColor(Color.CYAN);
----------------

the second has has better options to plot the script. I would like to able to edit the line style (ie. color, weight, style, length) before and after the the current candle.

# Posted from Mobius 1/15/18 - This puts a Horizontal Line at Price to see price level at potential Support / Resistance
# Here is a code Snippet that gives you all you need to limit a line both forward and backward
# Dynamic_Line
# Mobius
# V01.09.2012
input LineLimit = 100;
input OnExpansion = yes;
input OnExpansionLimit = 30;

def c = close; # Replace close with any conditional value that meets your requirement
def barNumber = BarNumber();
def bar = if IsNaN(c) then Double.NaN else BarNumber;
def ThisBar = HighestAll(bar);
def cline = if bar == ThisBar then c else Double.NaN;
def condi = CompoundValue(1, if IsNaN(c) then condi [1] else c, c);
plot P = if ThisBar - LineLimit <= bar then HighestAll (cline) else Double.NaN;
P.SetStyle(Curve.SHORT_DASH);
P.SetLineWeight(1);
P.SetDefaultColor(CreateColor(75, 250, 150));
plot ExpLine = if OnExpansion and barNumber < HighestAll (bar + OnExpansionLimit) and IsNaN(c) then condi else Double.NaN;
ExpLine.SetStyle(Curve.SHORT_DASH);
ExpLine.SetLineWeight(1);
ExpLine.SetDefaultColor(CreateColor(150, 150, 150));
# End Code Dynamic Line Mobius • 8:23 PM

Solution
Hi I was wondering if anyone could quickly help me combine two scripts?
the first tracks price more accurately. I want to use those inputs with the plot options of mobius' code. Here is the first code
----------------
##k_kirill code posted in 2020

input lineLength = 100;

def lastBar = !IsNaN(close) && IsNaN(close[-1]);
def lastClose = if lastBar then close else lastClose[1];

plot PriceIndicatorLine = if IsNaN(close[-lineLength - 1]) then lastClose[-lineLength] else Double.NaN;
PriceIndicatorLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PriceIndicatorLine.SetDefaultColor(Color.CYAN);
----------------

the second has has better options to plot the script. I would like to able to edit the line style (ie. color, weight...

#### SleepyZ

##### Well-known member
VIP
Hi I was wondering if anyone could quickly help me combine two scripts?
the first tracks price more accurately. I want to use those inputs with the plot options of mobius' code. Here is the first code
----------------
##k_kirill code posted in 2020

input lineLength = 100;

def lastBar = !IsNaN(close) && IsNaN(close[-1]);
def lastClose = if lastBar then close else lastClose[1];

plot PriceIndicatorLine = if IsNaN(close[-lineLength - 1]) then lastClose[-lineLength] else Double.NaN;
PriceIndicatorLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PriceIndicatorLine.SetDefaultColor(Color.CYAN);
----------------

the second has has better options to plot the script. I would like to able to edit the line style (ie. color, weight, style, length) before and after the the current candle.

# Posted from Mobius 1/15/18 - This puts a Horizontal Line at Price to see price level at potential Support / Resistance
# Here is a code Snippet that gives you all you need to limit a line both forward and backward
# Dynamic_Line
# Mobius
# V01.09.2012
input LineLimit = 100;
input OnExpansion = yes;
input OnExpansionLimit = 30;

def c = close; # Replace close with any conditional value that meets your requirement
def barNumber = BarNumber();
def bar = if IsNaN(c) then Double.NaN else BarNumber;
def ThisBar = HighestAll(bar);
def cline = if bar == ThisBar then c else Double.NaN;
def condi = CompoundValue(1, if IsNaN(c) then condi [1] else c, c);
plot P = if ThisBar - LineLimit <= bar then HighestAll (cline) else Double.NaN;
P.SetStyle(Curve.SHORT_DASH);
P.SetLineWeight(1);
P.SetDefaultColor(CreateColor(75, 250, 150));
plot ExpLine = if OnExpansion and barNumber < HighestAll (bar + OnExpansionLimit) and IsNaN(c) then condi else Double.NaN;
ExpLine.SetStyle(Curve.SHORT_DASH);
ExpLine.SetLineWeight(1);
ExpLine.SetDefaultColor(CreateColor(150, 150, 150));
# End Code Dynamic Line Mobius • 8:23 PM

Here is the price line before (expansion area) and after (chart). There is no line at the price bar. You can make adjustments to each separately.

Ruby:
``````#Horizontal Price Line without using Highestall

##k_kirill code posted in 2020
input lineLength = 100;

def lastBar   = !IsNaN(close) && IsNaN(close[-1]);
def lastClose = if lastBar then close else lastClose[1];

plot linebefore = if IsNaN(close[0])
then lastClose[0]
else Double.NaN;
linebefore.SetStyle(Curve.SHORT_DASH);
linebefore.SetLineWeight(3);
linebefore.SetDefaultColor(Color.CYAN);

plot lineafter = if IsNaN(close[1]) or lastClose >= lastClose[-lineLength]
then Double.NaN
else lastClose[-lineLength];
lineafter.SetStyle(Curve.LONG_DASH);
lineafter.SetLineWeight(2);
lineafter.SetDefaultColor(Color.WHITE);``````

You indicated 'style' as one of your requests. The following are the 'setstyle()' choices. However, these are not selectable and you will have to input them in the code.

### Curve​

In this section you will find information on the constants used with SetStyle function to define the style of curve to be plotted.

Choose your constant from the list:

The more selectable 'style' is setpaintingstrategy().

#### dpxpress

##### New member
Here is the price line before (expansion area) and after (chart). There is no line at the price bar. You can make adjustments to each separately.

You indicated 'style' as one of your requests. The following are the 'setstyle()' choices. However, these are not selectable and you will have to input them in the code.

The more selectable 'style' is setpaintingstrategy().
Thank you so much!

## 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
• 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?