Trend Follower

Trend Follower

It analyses moving averages in a channel and their momentum according to the channel width.

On each bar it creates a channel by highest/lowest point of a MA. highest point is upper point and lowest point is lower point of the MA channel.

It gets highest and lowest point of last 300 bars, (say Price Channel )
If the width of MA channel is greater than certain rate of price channel then it decides there is trend.

After it decided there is trend, it calculates the rate between channel and MA. Bigger result means stronger trend.

According to rate of MA channel and the price channel , bar color becomes lighter/darker. so when you look at the bar color you can see the trend strength.

The darker the colour, the weeker the trend is.

Upon a request from user denmar (https://www.prorealcode.com/topic/help-converting-trend-follower-indicator-from-trading-view/) I converted this indicator written by LonesomeTheBlue.

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. denmar • 09/27/2021 #

    Many thanks. Highly appreciated.

  2. Kanamax • 09/27/2021 #

    Hi Roberto,
    Thanks for this indicator which is very helpful.
    I tried to use this indicator into a very simple strategy based on g > 0 –> BUY and r SELL.
    The strategy runs however entry in call and put position don’t follow the indicator. Unfortunately I can’t put sceenshot to show
    Do you have any idea why?
    FYI I run with PRTV11

    Thank you

    I share only the end of the code + position entries:

    Trend = x * diff / MyChannel
    IF Trend > 0 THEN
    r = 0
    g = 255
    b = 0
    t = 255
    IF Trend Trend[1] THEN
    r = 139
    g = 0
    b = 0
    t = 255
    ENDIF
    ENDIF

    // Conditions pour ouvrir une position acheteuse
    if not onmarket and g = 255 then
    BUY 1 CONTRACTS AT MARKET
    ENDIF

    // Conditions pour fermer une position acheteuse
    if longonmarket and r = 255 then
    SELL AT MARKET
    ENDIF

    // Conditions pour ouvrir une position en vente à découvert
    if not onmarket and r = 255 then
    SELLSHORT 1 CONTRACTS AT MARKET
    ENDIF

    // Conditions pour fermer une position en vente à découvert
    if shortonmarket and g = 255 then
    EXITSHORT AT MARKET
    ENDIF

  3. robertogozzi • 09/27/2021 #

    Don’t use colours as a signal,
    use TREND instead.
    If it’s > 0 it’s a Long signal, otherwise it’s a Short signal.

  4. Kanamax • 09/27/2021 #

    Hi Roberto,
    I did previously but same result.

  5. Kanamax • 09/27/2021 #

    Can you try on your side to check if that works properly for you?

  6. robertogozzi • 09/27/2021 #

    Post the complete code you used.

  7. Kanamax • 09/27/2021 #

    Please find herein after

    / Trend Follower

    //
    MAtype = 1 //1=Ema
    TrendP = 20 //20 periods to check trend
    MAperiods = 20 //20 periods for MA
    TrendRate = 1 //1% trend channel rate
    UseLR = 1 //1=use Linear Regression, 0=do not use LR
    LRperiods = 5 //5 periods for Linear Regression
    RangeP = 1 //300 period for the range
    MAtype = max(0,min(8,MAtype))
    TrendP = max(1,min(999,TrendP))
    MAperiods = max(1,min(999,MAperiods))
    TrendRate = max(0.00001,min(99,TrendRate))
    RangeP = max(1,min(999,RangeP))
    //
    RateMult = TrendRate / 100
    PriceRange= highest[RangeP](high) – lowest[RangeP](low)
    MyChannel = PriceRange * RateMult
    MyMA = average[MAperiods,MAtype](close)
    IF UseLR THEN
    MyMA = LinearRegression[LRperiods](close)
    ENDIF
    hh = highest[TrendP](MyMA)
    ll = lowest[TrendP](MyMA)
    diff = abs(hh – ll)
    x = 0
    IF diff > MyChannel THEN
    IF MyMA > (ll + MyChannel) THEN
    x = 1
    ELSE
    IF MyMA 0 THEN
    r = 0
    g = 255
    b = 0
    t = 255
    IF Trend Trend[1] THEN
    r = 139
    g = 0
    b = 0
    t = 255
    ENDIF
    ENDIF

    // Conditions pour ouvrir une position acheteuse
    if not onmarket and trend > 0 then
    BUY 1 CONTRACTS AT MARKET
    endif

    // Conditions pour fermer une position acheteuse
    if longonmarket and trend < 0 then
    SELL AT MARKET
    ENDIF

    // Conditions pour ouvrir une position en vente à découvert
    if not onmarket and trend 0 then
    EXITSHORT AT MARKET
    ENDIF

  8. Kanamax • 09/27/2021 #

    It seems I had some difficulties to copy paste the complete code correctly.
    The overall code is just your indicator + the following conditions at the end:
    Read trend > 0 instead of g = 255 and trend < 0 instead of r = 255

    // Conditions pour ouvrir une position acheteuse
    if not onmarket and g = 255 then
    BUY 1 CONTRACTS AT MARKET
    ENDIF

    // Conditions pour fermer une position acheteuse
    if longonmarket and r = 255 then
    SELL AT MARKET
    ENDIF

    // Conditions pour ouvrir une position en vente à découvert
    if not onmarket and r = 255 then
    SELLSHORT 1 CONTRACTS AT MARKET
    ENDIF

    // Conditions pour fermer une position en vente à découvert
    if shortonmarket and g = 255 then
    EXITSHORT AT MARKET
    ENDIF

  9. robertogozzi • 09/27/2021 #

    I can’t understand when you want to enter/exit.
    Please start a new topic in ProOrder support and attach the ITF file of your strategy + screenshot (showing also the instrument and timeframe used).

  10. Kanamax • 09/27/2021 #

    Hi Roberto, sorry for my confusing previous posts (forget them). My request is very simple, I just want to enter/exit by using TREND signal from your indicator.
    I want entry long when trend > 0 then exit when trend 0 and exit long is not when trend < 0 (same at the opposite for short signal).
    It's why I wondered if you can test by your own and then share with me the last lines of your ProOrder code?
    Thanks for you help.

    // Trend Follower
    //
    // https://it.tradingview.com/script/o0ZOSVHj-Trend-Follower/
    //
    MAtype = 1 //1=Ema
    TrendP = 20 //20 periods to check trend
    MAperiods = 20 //20 periods for MA
    TrendRate = 1 //1% trend channel rate
    UseLR = 1 //1=use Linear Regression, 0=do not use LR
    LRperiods = 5 //5 periods for Linear Regression
    RangeP = 1 //300 period for the range
    MAtype = max(0,min(8,MAtype))
    TrendP = max(1,min(999,TrendP))
    MAperiods = max(1,min(999,MAperiods))
    TrendRate = max(0.00001,min(99,TrendRate))
    RangeP = max(1,min(999,RangeP))
    //
    RateMult = TrendRate / 100
    PriceRange= highest[RangeP](high) – lowest[RangeP](low)
    MyChannel = PriceRange * RateMult
    MyMA = average[MAperiods,MAtype](close)
    IF UseLR THEN
    MyMA = LinearRegression[LRperiods](close)
    ENDIF
    hh = highest[TrendP](MyMA)
    ll = lowest[TrendP](MyMA)
    diff = abs(hh – ll)
    x = 0
    IF diff > MyChannel THEN
    IF MyMA > (ll + MyChannel) THEN
    x = 1
    ELSE
    IF MyMA < (hh – MyChannel) THEN
    x = -1
    ENDIF
    ENDIF
    ENDIF
    Trend = x * diff / MyChannel
    IF Trend > 0 THEN
    r = 0
    g = 255
    b = 0
    t = 255
    IF Trend < Trend[1] THEN
    g = 128
    t = 180
    ENDIF
    ELSE
    r = 255
    g = 0
    b = 0
    t = 255
    IF Trend > Trend[1] THEN
    r = 139
    g = 0
    b = 0
    t = 255
    ENDIF
    ENDIF

    // Long Entry
    if not onmarket and trend > 0 then
    BUY 1 CONTRACTS AT MARKET
    ENDIF

    // Long Exit
    if longonmarket and trend < 0 then
    SELL AT MARKET
    ENDIF

    // Short Entry
    if not onmarket and trend < 0 then
    SELLSHORT 1 CONTRACTS AT MARKET
    endif

    // Short Exit
    if shortonmarket and trend > 0 then
    EXITSHORT AT MARKET
    ENDIF

  11. robertogozzi • 09/27/2021 #

    Please start a new topic in ProOrder support.

  12. Kanamax • 09/27/2021 #

    OK

avatar
Register or

Likes

avatar avatar avatar avatar avatar avatar avatar
Related users ' posts
Gaspare Ciao Ivan si puo' inserire una strategia su questo indicatore per ottimizzare le variabil...
Iván
2 weeks ago
groelandes Cuando te descargas el fichero itf, en su código no aparece toda la configuración de alertas...
Iván Si lo descargas e importas en tu PRT verás que se han creado las variables para luego config...
P. Marlowe Quite an impressive work, Iván. Extremely useful and accurate. Congratulations. Keep it up¡
lkiklkik i love it !!! thanks.
Stenozar Hi Ivan, can you translate from tradingviwe the EMA TREND METER INDICATOR? It couid be inte...
Iván Hi Yes I can. Please, create a new topic for that I will translate it.
Stenozar Hi Ivan, I've created a new topic about the indicator: https://www.prorealcode.com/topic/ema...
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.
Iván
2 months ago
cjr30 Simplemente modifica las lineas 19 y 21 por las siguientes: drawtext("▲",barindex,low-0.1*a...
groelandes Gracias!!
WhyAskOZ i copied the code into strategy and it gives error on line 21 and 23. it says " Line 1: ...
Iván
2 months ago
Madrosat Hello Ivan You have interesting topics on indicators , smart supertrend, optimised trend t...
Iván Hi! thanks. All of these codes are translations requested in the forum. I've on mind to back...
Raspete01 Buenos días Iván, estoy intentando llevar el código eliminando los colores y pasando un Back...
Iván
3 months ago
ARLEQUIN49 Hello Ivan, Would it be possible to convert the code of this QQE MOD indicator which accomp...
ARLEQUIN49 here is the code: //@version=4 //By Glaz, Modified // study("QQE MOD") RSI_Period = i...
Iván Hi, Yes I can translate it but please, create a new topic for it.
Fgats quelques explications en Français ici : Some explanations in French here : https://www.p...
Nicolas Merci pour cette contribution, j'apprécie ! :)
Fgats Merci Nicolas pour ces encouragements et merci aussi pour le commentaire en Anglais accompa...
Alai-n I really like it when you develop ideas around price movement! I am much less a fan of all t...
elcortijoverde Muy buen trabajo.Intuitivo y claro.Gracias por tu dedicación y aportación.
Nicolas
9 months ago
B-Xtrender
B-Xtrender
8
Indicators
616248 Bonjour Nicolas, Peux tu nous expliquer le principe de fonctionnement ? Ou nous mettre un...
Nicolas Le lien vers l'article IFTA de l'auteur est dans le post déjà :)
P. Marlowe Very poweful indeed. It deserves close attention. I really appreciate very much IFTA backgro...
JS
9 months ago
Trendilo
Trendilo
0
Indicators
Nicolas
9 months ago
Anthony2A Bjr, j ai des erreurs sur la ligne 69, 74, 78 et 80. sur drawcandle drawtext et endif. si ...
Lucas0000 Hello, Congratulations on this programming, it seems incredible to me, I am new to this but ...
plbourse Hello, I am trying to use this singal (in fact I have converted it to an indicateur giving B...
BriceE Bonjour Nicolas, Je suis a la recherche d'indicateurs pour me donner la meilleure indicatio...
Nicolas
11 months ago
Maxime Baudin Well done Nicolas, creative!
Stenozar Hi Nicolas, please can you explain how to read/use this indicator? thanks!

Top