TrendNoTrend Indicator

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.

 

Share this

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. Pepsmile • 09/16/2018 #

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

  2. Jan Wind • 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 ?

    Thanks in advance, Jan

    • FULVIO09 • 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. cfta • 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. cfta • 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. juanj • 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

avatar
Register or

Likes

avatar avatar avatar avatar avatar avatar avatar avatar avatar
Related users ' posts
MaoRai54 dear Ivan, it seems to be very interesting but please clarify what are all the lines I see i...
Iván Hi! you have the answer in the last line of code... MacdMiddle as "histo" style(histogra...
kats Le Top , a utiliser avec le nuage violet et alerte TN pour plus de précision.
roccafragius Hello Ivan, very good job! May I ask you to translate teh script from TradingView named Tre...
Iván Hi! yes. You can ask for it here: https://www.prorealcode.com/free-code-conversion/
roccafragius Thank you so much Ivan! I created this request in english Translate from TradingView Indicat...
Regisnew très bel indicateur merci
Jean2139 Bonjour Yvan, Merci pour ton indicateur que je trouve très intéressant. Je suppose que tu ...
Suffi Hier eine kleine Korrektur: //-----Inputs-----------------------------------------// MALengt...
kats Bonjour, J'ai une question etes vous trader? Je m'explique , j'ai téléchargé tous les indi...
Faisalx Hola Ivan. Thanks for your great job. I would appreciate if you have look at my request http...
roccafragius Thank you for all these useful information!! Very great job Ivan! THank you so much
geroniman Merci Ivan, super travail. On peut toujours compter sur toi pour apporter des innovations su...
Stenozar Ciao mi restituisce errore line 1; forse è perchè utilizzo la versione 11 ? in questo caso d...
Stenozar Ciao IVAN , mi da errore per la riga 49 "print tema low"; puoi suggerirmi la modifica da met...
Iván Avete provato a scaricare il file .itf?
Iván Allora crei un nuovo post. Lo aspetterò.
Stenozar Ciao Ivan, ho inserito il post con la richiesta di traduzione. Se puoi vedere, grazie!
Iván perfect!
kats BONSOIR c bon merci j ai trouve ce weekend merci de votre reponse cdlt
the_giorgio Hi, nice work I would like to understand something about prorealtime code. With your ...
Iván Hello. When you use the drawcandle() instruction then in the configuration window you add ...
Gaspare Ciao Ivan si puo' inserire una strategia su questo indicatore per ottimizzare le variabil...
Iván
7 months ago
Iván Si lo descargas e importas en tu PRT verás que se han creado las variables para luego config...
WhyAskOZ Hi, Ivan As always you are doing great coding. The code works on my PRT, however the issu...
Iván You can delete in the last line (return) the configuration for color. Delete coloured(xx,xx,...
Bernard13 (Je réécris mon commentaire -français- en français car certains mots ne correspondaient pas ...
Iván 1000 indicateurs !!! brutaux
Lean Me parece muy buen indicador, y se complementa muy bien en mi sistema, ¿podrías crear un scr...
Iván Gracias! Para el screener sólo tienes que copiar el indicador y poner como condición de búsq...
Lean Muchas gracias Iván, ya lo he podido crear.
Iván sería así //------------------Inputs------------------------------ linreglength = 11//i...
Doddge Muchísimas gracias Iván, está genial.
superfalcio holaaa, have you run some statistics?
Doddge Hola Iván, ¿sería posible crear un screener que indique cuándo las velas coloreadas del indi...
RTR Ivan thank you for the pro-screener. I a trying to understand how to write the signals from ...
Iván Hi, Lines 62 and 63. These lines define buy and sell conditions.
Iván Hi You should delete from the indicator code all drawing functions and all variables not us...
Iván I've created a screener to show [longcondition or shortcondition]
Chrisinobi Hallo Ivan, Danke das ist Perfekt !! Kannst du bitte in der Screener-Bibliothek die itf. hoc...
MaoRai54 Thanks, now it's OK. in your first code at line 15-16 it's missing.
Madrosat Hello Ivan Did you try a strategy with this indicator
Iván Hi. No I didn't. This is a code translation requested by an user a few days ago.

Top