# TrendNoTrend Indicator

The “Linear regression slope” indicates the direction and intensity of the current trend.
In the abstract hypothesis of total absence of trend the slope of the linear regression is equal to zero: the linear regression is a line parallel to the abscissa axis.
A statistical way of establishing that there is no trend, and so we are in a laterality phase of the market, consists in establishing that the slope of our linear regression is statistically equal to zero in the observation period.
To do this in statistics we use the “t-test”.
For all those who love statistical problems I attach the pdf files with the related explanations.
The statistical formula is translated into the following code.
In a normal distribution, 95% of the data is included in a confidence interval of “Average + – 1.96”.
A “t-distribution” with infinitely many degrees of freedom is a normal distribution.
With an approximation we can state that if    t <= 1.96  then our LinearRegressionSlope is equal to zero = there is no trend.

Risk disclosure:

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

ProRealTime ITF files and other attachments : How to import ITF files into ProRealTime platform?

PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials

1. • 09/16/2018 #

Hi FULVI,
Interesting. But seems to take into account only bull trend.

2. • 09/16/2018 #

Dear Fulvio09,

The concept of calculating trend or no trend attracts me much.

First question: the linear regression slope indicator itself gives already the strength of the trend in itself, what does your calculation add to this ?

If I compare the graph of the standard linear regression slope indicator with your indicator, and plotting your defined t-values as indicator, (instead of making them 0 or 1), the t-values seems just a multiplication of the linear regression slope values.
Therefore my second question: could you explain your formula shortly per item, why it is used , and with a consistent number example ? (For example one of the items STD[AA](Barindex) why is this used ?)
Maybe the standard indicator R2 can be used ?

• • 09/16/2018 #

I try to answer even if, not being a statistic, it is not easy for me to do it, and even more in these few lines.
The “t-test” is used in statistics to compare two groups of data.
Basically it compares the difference between the mean of two groups, considering the desperation of the data (expressed as standard deviation).
The result “t” of the “t-test” is compared to a table of the values of the “t-test” (see: ” https://www.itl.nist.gov/div898/handbook/eda/section3/eda3672.htm ” ).
In the table for each degree of freedom (first column of the table) you will find next to, the values corresponding to the probability you want to check.
If you compare, for example, two groups with 10 data each, the degrees of freedom are 10 + 10 – 2 = 18.
If you compare a large number of data (degrees of freedom> 100 to infinity) (last row of the table) you find that for a value of t <1.96 there is a 95% probability that the two groups of data are equal.

The "t-test" formula applied to the specific case of "slope of a regression line" can be found at the end of the attached "t-test" pdf file.
In essence it compares the difference between the slope of two linear regressions considering the dispersion of data (expressed as "standard error of the slope coefficient").
I suggest you to watch: " https://www.youtube.com/watch?v=j5oPzAJvnVI " you will need to understand why the standard error is also influenced by "STD [AA] (Barindex)".

3. • 09/16/2018 #

Hi Fulvio, many thanks for sharing this clever indicator, much appreciated. As Pepsmile mentioned it seems that it only accounts for bull trend and ignores bear trend, I modified it in order to include the bear trend. 1 = bull trend, 0 = no trend and -1= bear trend. Enjoy!

4. • 09/16/2018 #

Sorry adding the PRT to code didn’t work in the above comment so I guess we will have to settle for regular text format…

// period da ottimizzare
AA = period
t=(LinearRegressionSlope[AA](close)-0)*SQRT(AA-2)/(STE[AA](close)/STD[AA](Barindex))
if t>1.96 then
beta=1
endif

if t<-1.96 then
beta=-1
endif

if t-1.96 then
beta=0
endif

return beta

5. • 09/16/2018 #

Something appears to be wrong with this formula as graphing t shows t to almost never be within the -2 to + 2 range. The only reason I believe the author sees extended periods of beta = 0 is due to the fact that he is including bearish linear regression < -1.96 as beta = 0

Register or

#### Likes

Related users ' posts
Sever
5 months ago
0
Indicators
Sever
6 months ago
2
Indicators
Hi Sever, how can I visualize the coloured areas?
Hi Stenozar, You need to add the color zones yourself , just go to Add Color Zone To set ...
Nicolas
9 months ago
2
Indicators
hi nicolas this indicator have 2 wrong borderline and islalastbarupdate. thank you can you h...
That'"s because you are not using PRT v11? Just remove lines 59 to 62
robertogozzi
9 months ago
12
Indicators
Hi Roberto, sorry for my confusing previous posts (forget them). My request is very simple,...
Please start a new topic in ProOrder support.
OK
robertogozzi
10 months ago
16
Indicators
If MagicTrend <> MagicTrend[1] then it's Green or Red
Buonasera Roberto, ho provato ad usare questo indicatore inserendo l'istruzione di cui sopr...
A really nice indicator. Can easily be used as a strategy. I've tried a few trend indicators...
Quino
10 months ago
v11
0
Indicators
Newbie
1 year ago
0
Indicators
Nicolas
1 year ago
v10.3
12
Indicators
Bonjour, j'ai essayé de faire afficher cet indic en temps 5 mn sur le 1 mn et c'est Hiroshim...
Il suffit d'ajouter l'instruction TIMEFRAME(5 minutes,updateonclose) en tête du code
cordial saludo Nicolas, una pregunta senciLla : Como coloco un STOPS en un maximo o un mini...
Nicolas
1 year ago
v10.3
4
Indicators
change the last line with: return v coloured(r,g,b) style(line,2), v+band coloured(168,168,1...
Thanks ... works as i wanted.
Bonjour Nicolas, comme Paolo.B je souhaiterais utiliser cette indicateur au sein d'un code. ...
Nicolas
1 year ago
2
Indicators
Thanks @Nicolas. I tried to use it as Trend in a proorder system, but don't know why, it doe...
He is right. MT and mavgMT are not defined and causing errors.....
juanj
2 years ago
v10.3
0
Indicators
Nicolas
2 years ago
v10.3
3
Indicators
"style(line,2)" C'è una guida ai parametri che si possono modificare ? Tipo stile della lin...
https://www.prorealcode.com/programming-with-prorealtime/
Tanks
2 years ago
13
Indicators
Écrivez-moi où vous préférez you can easily find me on LinkedIn
C'est payant visiblement sur linkdin je peux pas vous envoyer, discord vous avez ?
Nicolas
2 years ago
v10.3
57
Indicators
C'est dans ce sujet: https://www.prorealcode.com/topic/trendline-une-approche-du-trading/ M...
Bonjour Nicolas, comment est-il possible de backtester cet indicateur? cela fait une erreu...
Oui bien sûr, il doit y avoir pas mal de sujets dans le forum à ce propos.
Nicolas
2 years ago
v10.3
17
Indicators
Bonjour Nicolas, comment coder un indicateur de rsi de Divergence? Merci pour ta réponse
En apprenant la programmation :) Plus sérieusement, il y a quantité d'exemples dans la libra...
Bonjour Nicolas, Très bel indicateur! Bravo!
Nicolas
2 years ago
v10.3
6
Indicators
Il doit s'agir d'un mauvais copier/coller. Je suggère de télécharger le fichier itf contenu ...
Hello @Nicolas, I can get this to display in a separate indicator panel but not on Price as ...
Hi @Nicolas, how can I put the bands on price? Thanks, Stefano
2 years ago
v10.3
7
Indicators
I gave the above message fix ;)
Is it possible to put the itf-file in the right way here in Prorealcode? so the right 'trend...
Thomas
2 years ago
v10.3
0
Indicators
Bard
2 years ago
v10.3
0
Indicators
Jan
2 years ago
v10.3
2
Indicators
Hi man, I installed the indicator and i don't know why but my graph it is so big
sounds interesting I'll take a look

Top