# How do I take One Point of Linear Regression Slope and Have it divide it by closing price of that candle

#### uunnamed

##### New member
It's my first time trying to write a script but I Just can't figure it out how it works

I am trying to use the default LinearRegressionSlope script on tos
and have it divide by the closing price on the 1minute-time frame

The trouble I face is that the default script is set for a length of time,

And I just need to use that 1minute value to divide by price

Sorry if it is unclear,
Thanks for the help

Solution
hello and welcome.
questions about a code that you don't post, are hard to answer.
don't be bashful, post the code you have.

what 1 minute value you want to read? every bar ? or just the last bar?
the plot of LRS has a value on every bar, in a lower chart.

Code:
``````# LinearRegressionSlope

declare lower;

input price = close;
input length = 14;

Assert(length > 1, "'length' must be greater than one: " + length);

plot LRS = 6 * ( wma(price, length) -  Average(price, length) ) / (length - 1);
plot ZeroLine = 0;

LRS.setDefaultColor(getColor(8));
ZeroLine.setDefaultColor(getColor(5));``````
I think I figured it out lol
I was dividing it by the wrong unit
It's my first time trying to write a script but I Just can't figure it out how it works

I am trying to use the default LinearRegressionSlope script on tos
and have it divide by the closing price on the 1minute-time frame

The trouble I face is that the default script is set for a length of time,

And I just need to use that 1minute value to divide by price

Sorry if it is unclear,
Thanks for the help

hello and welcome.
questions about a code that you don't post, are hard to answer.
don't be bashful, post the code you have.

what 1 minute value you want to read? every bar ? or just the last bar?
the plot of LRS has a value on every bar, in a lower chart.

Code:
``````# LinearRegressionSlope

declare lower;

input price = close;
input length = 14;

Assert(length > 1, "'length' must be greater than one: " + length);

plot LRS = 6 * ( wma(price, length) -  Average(price, length) ) / (length - 1);
plot ZeroLine = 0;

LRS.setDefaultColor(getColor(8));
ZeroLine.setDefaultColor(getColor(5));``````

hello and welcome.
questions about a code that you don't post, are hard to answer.
don't be bashful, post the code you have.

what 1 minute value you want to read? every bar ? or just the last bar?
the plot of LRS has a value on every bar, in a lower chart.

Code:
``````# LinearRegressionSlope

declare lower;

input price = close;
input length = 14;

Assert(length > 1, "'length' must be greater than one: " + length);

plot LRS = 6 * ( wma(price, length) -  Average(price, length) ) / (length - 1);
plot ZeroLine = 0;

LRS.setDefaultColor(getColor(8));
ZeroLine.setDefaultColor(getColor(5));``````
I think I figured it out lol
I was dividing it by the wrong unit

### Not the exact question you're looking for?

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