Find slope of TTM Lrc

jefepollo

New member
I'm trying to find a way to scan for stocks that have a positive TTM Lrc slope. I've tried using LinearRegressionSlope and copying some scripts I've found during my exhausting search to no avail.
Question: How do go about finding the slope of TTM Lrc?

Thank you for you time,
Mike

Solution
I'm trying to find a way to scan for stocks that have a positive TTM Lrc slope. I've tried using LinearRegressionSlope and copying some scripts I've found during my exhausting search to no avail.
Question: How do go about finding the slope of TTM Lrc?

Thank you for you time,
Mike

The following InertiaLine uses the TOS inertiaall() function. It might help you determine the positive/negative direction as the TTM LRC code is not available to provide this.
The InertiaLine is set to the same close/length as the TTM LRC and is the wide cyan colored line overlaid on the TTM LRC indicator's plots in the image below for comparison.
A label was added to determine the direction of the InertiaLine by comparing the current bar to the...
I'm trying to find a way to scan for stocks that have a positive TTM Lrc slope. I've tried using LinearRegressionSlope and copying some scripts I've found during my exhausting search to no avail.
Question: How do go about finding the slope of TTM Lrc?

Thank you for you time,
Mike

The following InertiaLine uses the TOS inertiaall() function. It might help you determine the positive/negative direction as the TTM LRC code is not available to provide this.
The InertiaLine is set to the same close/length as the TTM LRC and is the wide cyan colored line overlaid on the TTM LRC indicator's plots in the image below for comparison.
A label was added to determine the direction of the InertiaLine by comparing the current bar to the prior bar.

Code:
``````input data   = close;
input length = 38;
plot InertiaLline = inertiaall(data, length);
addlabel(1, if InertiaLline > InertiaLline[1] then "UP" else "DN", if InertiaLline > InertiaLline[1] then color.green else color.red);``````

I'm trying to find a way to scan for stocks that have a positive TTM Lrc slope. I've tried using LinearRegressionSlope and copying some scripts I've found during my exhausting search to no avail.
Question: How do go about finding the slope of TTM Lrc?

Thank you for you time,
Mike

to find a slope, you look for a change in y over a change in x.
(y-y) / (x-x)

a change in price, over x bars.
then reduce it down to a price change over 1 bar.
the space between 2 adjacent bars is 1.
lrc is a straight line, so the change between the last 2 bars will work.

if what you want is to know if a straight line is inclining or declining, then subtract the previous price from the current price.
then check if the number is > 0.

to find a slope, compare 2 values of the LR plot from the TTM_LRC study.
just because the code is hidden, doesn't mean you can't reference the variables.
look up the inputs and plots for the study, to make sure you understand what does what.
https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/T-U/TTM-LRC

here is a simple formula, for reading the LR plot.
you use the study name, () , then a period, and the plot name.
def lrc = TTM_LRC().LR;
i included all the input parameters in my study, so it can be setup as desired.

then compare 2 values,
def lrc_slope = lrc - lrc[1];

this is a lower study for testing. but will work as a scan

Code:
``````#ttm_lrc_slope

#Find slope of TTM Lrc

declare lower;

# TTM_LRC
input price = CLOSE;
input length = 38;
input beginDate = 0;
input beginTime = 0;
input numDevDn1 = -1.0;
input numDevDn2 = -2.0;
input numDevUp1 = 1.0;
input numDevUp2 = 2.0;
input extLeft = No;
input extRight = Yes;

def lrc = TTM_LRC(price, length, beginDate, beginTime, numDevDn1, numDevDn2, numDevUp1, numDevUp2, extLeft, extRight ).LR;

def lrc_slope = lrc - lrc[1];

def isup = if isnan(lrc) then 0 else if lrc_slope > 0 then 1 else 0;

# true if inclining slope.  false if declining
plot z = isup;
#``````

Not the exact question you're looking for?

87k+ Posts
321 Online

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?