Help converting “Trend Follower” Indicator from Trading View

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #170733 quote
    denmar
    Participant
    Veteran

    Hello

    I would appreciate it if the following indicator could be converted to ProRealTime (fig. 1).

    It allows one to determine both trend direction and strength based on a novel concept (see fig. 2).

    By adjusting the parameters one can also filter out congestion areas (fig. 3).

    Thank you

    Denmar

    // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
    // © LonesomeTheBlue
    
    //@version=4
    study("Trend Follower", precision=0)
    matype= input('EMA', title = "MA Type", options =['EMA', 'SMA', 'RMA', 'WMA', 'VWMA'])
    prd = input(20, title = "Period to Check Trend", minval = 5)
    maprd = input(20, title = "MA Period", minval = 2)
    rateinp = input(1, title = "Trend Channel Rate %", minval = 0.1, step = 0.1)
    ulinreg = input(true, title = "Use Linear Regression")
    linprd = input(5, title = "Linear Regression Period", minval = 2)
    
    rate = rateinp / 100
    pricerange = highest(300) - lowest(300)
    chan = pricerange * rate
        
    gettrend(len)=>
        masrc = matype == 'EMA' ? ema(close, len) : matype == 'RMA' ? rma(close, len) : matype == 'VWMA' ? vwma(close, len) : matype == 'WMA' ? wma(close, len) : sma(close, len)
        ma = ulinreg ? linreg(masrc, linprd, 0) : masrc
        
        hh = highest(ma, prd)
        ll = lowest(ma, prd)
        diff = abs(hh - ll)
        
        trend = iff(diff > chan, iff(ma > ll + chan, 1, iff(ma < hh - chan, -1, 0)), 0)
        _ret = trend * diff / chan
        _ret
    
    trend = gettrend(maprd)
    
    tcol =  trend > 0 ? change(trend) > 0 ? #00FF00ff : change(trend) <= 0 ? #00FF006f : #00FF00af :
       trend < 0 ? change(trend) < 0 ? #FF0000ff: change(trend) >= 0 ? #FF00006f : #FF0000af : na
    
    plot(trend, color = tcol, style = plot.style_columns)
    
    alertcondition(trend > 0, title = 'Trend is UP', message = 'Trend is UP')
    alertcondition(trend < 0, title = 'Trend is DOWN', message = 'Trend is DOWN')
    alertcondition(trend == 0, title = 'NO TREND', message = 'NO TREND')
    
    fig-1.png fig-1.png fig-2.png fig-2.png fig-3.png fig-3.png
    #177940 quote
    denmar
    Participant
    Veteran

    Good day everyone

    A humble re-request for the conversion of this indicator.

    Thank you

    Denmar

    #178528 quote
    robertogozzi
    Moderator
    Master
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Help converting “Trend Follower” Indicator from Trading View


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
denmar @denmar Participant
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 05/29/2021
Status: Active
Attachments: 3 files
Logo Logo
Loading...