Trendilio Indicator on Tradingview

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #218408 quote
    boonet
    Participant
    Senior

    Can someone please help me convert Trendilio Indicator to PRT? Here is the code

    //@version=5
    indicator('Trendilo', overlay=false)
    src = input(close, title='Source')
    smooth = input.int(1, title='Smoothing', minval=1)
    length = input.int(50, title='Lookback', minval=1)
    offset = input.float(0.85, title='ALMA Offset', step=0.01)
    sigma = input.int(6, title='ALMA Sigma', minval=0)
    bmult = input(1.0, 'Band Multiplier')
    cblen = input(false, 'Custom Band Length ? (Else same as Lookback)')
    blen = input(20, 'Custom Band Length')
    highlight = input(true)
    fill = input(true)
    barcol = input(false, 'Bar Color')
    pch = ta.change(src, smooth) / src * 100
    avpch = ta.alma(pch, length, offset, sigma)
    blength = cblen ? blen : length
    rms = bmult * math.sqrt(math.sum(avpch * avpch, blength) / blength)
    cdir = avpch > rms ? 1 : avpch < -rms ? -1 : 0
    col = cdir == 1 ? color.lime : cdir == -1 ? color.red : color.gray
    fplot = plot(avpch, color=highlight ? col : color.blue, linewidth=2)
    posrms = plot(rms, color=color.new(color.purple, 0))
    negrms = plot(-rms, color=color.new(color.purple, 0))
    fill(fplot, posrms, color=fill and cdir > 0 ? col : na, transp=50)
    fill(fplot, negrms, color=fill and cdir < 0 ? col : na, transp=50)
    barcolor(color=barcol ? col : na)
    hline(0)
    
    
    #218417 quote
    Nicolas
    Keymaster
    Master

    I added the conversion to the list. Thank you for your patience 🙂

    boonet thanked this post
    #218434 quote
    JS
    Participant
    Senior

    Text Trading View:

    The provided code is a custom indicator called “Trendilo” in TradingView. It helps traders identify trends in price data. The indicator calculates the percentage change of the chosen price source and applies smoothing to it. Then, it calculates the Arnaud Legoux Moving Average (ALMA) of the smoothed percentage change. The ALMA is compared to a root mean square (RMS) band, which represents the expected range of the ALMA values. Based on this comparison, the indicator determines whether the trend is up, down, or sideways. The indicator line is plotted in a color corresponding to the trend direction. The indicator also provides the option to fill the area between the indicator line and the RMS band. Additionally, users can choose to color the bars of the chart based on the trend direction. Overall, the “Trendilo” indicator helps traders visually identify trends and potential reversals in the price data.

     
    REM Trendilio Code from Tradingview
    //@version=5
    
    src=close //Source is Close
    smooth=1 //Smoothing (minimum value=1)
    length=50 //ALMA Lookbackperiod (minimum value=1)
    offset=0.85 //ALMA Offset (step=0.01)
    sigma=6 //ALMA Sigma (minimum value=0)
    bmult=1.0 //Band Multiplier
    blen=20 //Custom Band Length
    pch=(src-src[smooth])/(src * 100) //Price change
    m = (Offset * (length - 1))
    s = length/Sigma
    WtdSum = 0
    CumWt  = 0
    for k = 0 to length - 1 do
    Wtd = Exp(-((k-m)*(k-m))/(2*s*s))
    WtdSum = WtdSum + Wtd * pch[length - 1 - k]
    CumWt = CumWt + Wtd
    next
    avpch = WtdSum / CumWt
    //avpch = ta.alma(pch, length, offset, sigma)
    blength = length
    rms = bmult * sqrt(summation[blength](avpch * avpch) / blength)
    If avpch > rms then
    cdir = 1
    ElsIf avpch < -rms then
    cdir = -1
    Else
    cdir=0
    EndIf
    If cdir= 1 then
    R=0
    G=255
    B=0
    ElsIf cdir=-1 then
    R=255
    G=0
    B=0
    Else
    R=128
    G=128
    B=128
    EndIf
    DrawHLine(0)
    Return avpch as "avpch" Coloured(R,G,B), rms as "rms" Coloured("purple"), -rms as "-rms" Coloured("purple")
    boonet and Nicolas thanked this post
    #218439 quote
    phoentzs
    Participant
    Master
    I don’t know if I’m wrong. But now this complex calculation does not necessarily have better results than a simple MACD indicator.
    boonet thanked this post
    #218441 quote
    boonet
    Participant
    Senior
    Thanks a lot phoentzs and Nicolas. You are right, just using ALMA gives better entries than this indicator.
    #218442 quote
    JS
    Participant
    Senior
    It is a request from @Boonet, to use without obligation or not…
    #218443 quote
    phoentzs
    Participant
    Master
    That wasn’t a criticism, just a statement. 😉 Often it is better to fall back on simple things.
    #218444 quote
    JS
    Participant
    Senior
    @phoentzs

    My experience is that there is nothing simple about working with digital signals… 🙂

    #218445 quote
    Nicolas
    Keymaster
    Master
    Thank you @JS, it helps me a lot if you do conversion from time to time 🙂
    #218462 quote
    phoentzs
    Participant
    Master
    @JS Me too. Otherwise we would all be rich by now. 😉 In my experience, standard indicators, used correctly, are no worse than complex programming.
    robertogozzi thanked this post
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.

Trendilio Indicator on Tradingview


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
boonet @boonet Participant
Summary

This topic contains 9 replies,
has 4 voices, and was last updated by phoentzs
2 years, 6 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 07/31/2023
Status: Active
Attachments: 2 files
Logo Logo
Loading...