# Time Series Projection Trend for ThinkorSwim

#### J007RMC

##### Well-known member
2019 Donor
Mobius: Here's a study that uses an old method of predicting what price is likely to do in the very short term. The study uses linear regression as the forecasting tool. It looks at the current trend over a short period and a period one magnitude higher adds the slope of those trends then differences that with price to plot an oscillator around 0. If both periods agree the probability is trend will continue for one standard deviation of the shorter n period or n * .68. I added the arrows as overlay.
Code:
``````plot Data = close;# Time Series Projection
# Mobius
# V01.2018
# Uses Linear Regression to predict the price direction. Momentum suggests that the path of least resistance is determined by recent price trend. This indicator uses an order of magnitude in differencing a near and longer term projection.
# Use: When both near and long term agree - Probability is in that the trend will maintain current direction for (n * .68) bars.

declare lower;
input n = 5;

def n2 = n * 10;
def c = close;
def LRL = inertia(c, n);
def slope = AbsValue(LRL - LRL[n]) / n;
def SP = LRL + slope * floor(sqrt(n));
def LRL2 = inertia(c, n2);
def slope2 = AbsValue(LRL - LRL[n2]) / n2;
def SP2 = LRL2 + slope2 * floor(sqrt(n2));
plot OSC = (c - SP) / c;
OSC.HideBubble();
OSC.HideTitle();
plot OSC2 = (c - SP2) / c;
OSC2.HideBubble();
OSC2.HideTitle();
plot ZeroLine = 0;
ZeroLine.HideBubble();
ZeroLine.HideTitle();
Addlabel(if (OSC < 0 and OSC2 < 0)
or (OSC > 0 and OSC2 > 0)
then 1
else 0,
"Prob Trend Cont",
if OSC > 0 then color.green else color.red);
# End Code``````

Last edited by a moderator:
• • SparkyFlary and MerryDay

#### KarlWolff

##### Member
Thanks a lot!! This is a great addition to my charts.

• whats up and J007RMC
T

#### Tostechnical

##### Guest
@J007RMC This indicator looks very interesting. Could you explain it a little more? Thanks!

#### J007RMC

##### Well-known member
2019 Donor
Its based on linear regression Ill repost the info I have here
Mobius: Here's a study that uses an old method of predicting what price is likely to do in the very short term. The study uses linear regression as the forecasting tool. It looks at the current trend over a short period and a period one magnitude higher adds the slope of those trends then differences that with price to plot an oscillator around 0. If both periods agree the probability is trend will continue for one standard deviation of the shorter n period or n * .68. I added the arrows as overlay.

T

#### Tostechnical

##### Guest
@J007RMC Let me make sure I understand this correctly. So Osc looks for the current trend in a short period using linear regression of the price. So on a daily chart a few days. While OSC2 is the same as OSC except that it is a longer length and uses the slope of the linear regression, used in OSC. If both are above 0 then a positive trend and if both below zero then its a negative trend. Also not a momentum oscillator. Did i misinterpret anything?

#### Kimberly

##### New member

When I installed the script, the result looks like this. What am I doing wrong? Thank you.

##### Active member
2019 Donor
i tried as well its not working

##### Well-known member
VIP
@Kimberly

Just delete plot Data = close; from your first line of code so that the first line reads # Time Series Projection

#### Kimberly

##### New member
@Kimberly

Just delete plot Data = close; from your first line of code so that the first line reads # Time Series Projection

Thank you so much!

• J007RMC

#### Cribbage

##### Member
I came across a scan recently that had a custom study that was a single line of code: TimeSeriesForecast("price" = hl2)

Can someone explain what effect this study is having in simple terms? My google search had me in the weeds pretty quick.

The TOS definition is:
The Time Series Forecast study is a technical indicator displaying the statistical trend based on linear regression analysis using the least squares method. Time Series Forecast partially eliminates time lagging effect occurring in Moving Average studies as linear regression value is as close as possible to the values being averaged.

This indicator can be used for predicting future price movements (see the bar plus input description). Note that this type of prediction is purely mathematical as all calculations are based on least squares averaging of previous values.

#### MerryDay

Staff member
Staff
VIP
I came across a scan recently that had a custom study that was a single line of code: TimeSeriesForecast("price" = hl2)

Can someone explain what effect this study is having in simple terms? My google search had me in the weeds pretty quick.

The TOS definition is:
The Time Series Forecast study is a technical indicator displaying the statistical trend based on linear regression analysis using the least squares method. Time Series Forecast partially eliminates time lagging effect occurring in Moving Average studies as linear regression value is as close as possible to the values being averaged.

This indicator can be used for predicting future price movements (see the bar plus input description). Note that this type of prediction is purely mathematical as all calculations are based on least squares averaging of previous values.

#### Cribbage

##### Member
Thanks Merry Day - So TimeSeriesForecast("price" = hl2) is acting like the oscillator in this study? Sort of like use a fast and a slow moving avg, and if both are > 1 then higher lows are being made? ## 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?