Conversion TV : Optimized Trend Tracker

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #162433 quote
    LucioleLuciole
    Participant
    Senior

    Hello,

    Would it be possible to convert this indicator to PRT ? It’s a dynamic S/R line. (ScreenShot attached)

    This is the complete code from tradingView.

    Many unecassy lines because of the moving average type options and alerts system I guess.

    The 2 usefull variables are “OTT Period” and “OTT Percent”

    Thanks a lot

     

    //@version=4
    // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
    // © KivancOzbilgic
    
    //created by: @Anil_Ozeksi
    //developer: ANIL ÖZEKŞİ
    //author: @kivancozbilgic
    
    study("Optimized Trend Tracker","OTT", overlay=true)
    src = input(close, title="Source")
    length=input(2, "OTT Period", minval=1)
    percent=input(1.4, "OTT Percent", type=input.float, step=0.1, minval=0)
    showsupport = input(title="Show Support Line?", type=input.bool, defval=true)
    showsignalsk = input(title="Show Support Line Crossing Signals?", type=input.bool, defval=true)
    showsignalsc = input(title="Show Price/OTT Crossing Signals?", type=input.bool, defval=false)
    highlight = input(title="Show OTT Color Changes?", type=input.bool, defval=false)
    showsignalsr = input(title="Show OTT Color Change Signals?", type=input.bool, defval=false)
    highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true)
    mav = input(title="Moving Average Type", defval="VAR", options=["SMA", "EMA", "WMA", "TMA", "VAR", "WWMA", "ZLEMA", "TSF"])
    Var_Func(src,length)=>
        valpha=2/(length+1)
        vud1=src>src[1] ? src-src[1] : 0
        vdd1=src<src[1] ? src[1]-src : 0
        vUD=sum(vud1,9)
        vDD=sum(vdd1,9)
        vCMO=nz((vUD-vDD)/(vUD+vDD))
        VAR=0.0
        VAR:=nz(valpha*abs(vCMO)*src)+(1-valpha*abs(vCMO))*nz(VAR[1])
    VAR=Var_Func(src,length)
    Wwma_Func(src,length)=>
        wwalpha = 1/ length
        WWMA = 0.0
        WWMA := wwalpha*src + (1-wwalpha)*nz(WWMA[1])
    WWMA=Wwma_Func(src,length)
    Zlema_Func(src,length)=>
        zxLag = length/2==round(length/2) ? length/2 : (length - 1) / 2
        zxEMAData = (src + (src - src[zxLag]))
        ZLEMA = ema(zxEMAData, length)
    ZLEMA=Zlema_Func(src,length)
    Tsf_Func(src,length)=>
        lrc = linreg(src, length, 0)
        lrc1 = linreg(src,length,1)
        lrs = (lrc-lrc1)
        TSF = linreg(src, length, 0)+lrs
    TSF=Tsf_Func(src,length)
    getMA(src, length) =>
        ma = 0.0
        if mav == "SMA"
            ma := sma(src, length)
            ma
    
        if mav == "EMA"
            ma := ema(src, length)
            ma
    
        if mav == "WMA"
            ma := wma(src, length)
            ma
    
        if mav == "TMA"
            ma := sma(sma(src, ceil(length / 2)), floor(length / 2) + 1)
            ma
    
        if mav == "VAR"
            ma := VAR
            ma
    
        if mav == "WWMA"
            ma := WWMA
            ma
    
        if mav == "ZLEMA"
            ma := ZLEMA
            ma
    
        if mav == "TSF"
            ma := TSF
            ma
        ma
        
    MAvg=getMA(src, length)
    fark=MAvg*percent*0.01
    longStop = MAvg - fark
    longStopPrev = nz(longStop[1], longStop)
    longStop := MAvg > longStopPrev ? max(longStop, longStopPrev) : longStop
    shortStop =  MAvg + fark
    shortStopPrev = nz(shortStop[1], shortStop)
    shortStop := MAvg < shortStopPrev ? min(shortStop, shortStopPrev) : shortStop
    dir = 1
    dir := nz(dir[1], dir)
    dir := dir == -1 and MAvg > shortStopPrev ? 1 : dir == 1 and MAvg < longStopPrev ? -1 : dir
    MT = dir==1 ? longStop: shortStop
    OTT=MAvg>MT ? MT*(200+percent)/200 : MT*(200-percent)/200 
    plot(showsupport ? MAvg : na, color=#0585E1, linewidth=2, title="Support Line")
    OTTC = highlight ? OTT[2] > OTT[3] ? color.green : color.red : #B800D9 
    pALL=plot(nz(OTT[2]), color=OTTC, linewidth=2, title="OTT", transp=0)
    alertcondition(cross(OTT[2], OTT[3]), title="Color ALARM", message="OTT Has Changed Color!")
    alertcondition(crossover(OTT[2], OTT[3]), title="GREEN ALERT", message="OTT GREEN BUY SIGNAL!")
    alertcondition(crossunder(OTT[2], OTT[3]), title="RED ALERT", message="OTT RED SELL SIGNAL!")
    alertcondition(cross(MAvg, OTT[2]), title="Cross Alert", message="OTT - Support Line Crossing!")
    alertcondition(crossover(MAvg, OTT[2]), title="Crossover Alarm", message="Support Line BUY SIGNAL!")
    alertcondition(crossunder(MAvg, OTT[2]), title="Crossunder Alarm", message="Support Line SELL SIGNAL!")
    alertcondition(cross(src, OTT[2]), title="Price Cross Alert", message="OTT - Price Crossing!")
    alertcondition(crossover(src, OTT[2]), title="Price Crossover Alarm", message="PRICE OVER OTT - BUY SIGNAL!")
    alertcondition(crossunder(src, OTT[2]), title="Price Crossunder Alarm", message="PRICE UNDER OTT - SELL SIGNAL!")
    buySignalk = crossover(MAvg, OTT[2])
    plotshape(buySignalk and showsignalsk ? OTT*0.995 : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0)
    sellSignallk = crossunder(MAvg, OTT[2])
    plotshape(sellSignallk and showsignalsk ? OTT*1.005 : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)
    buySignalc = crossover(src, OTT[2])
    plotshape(buySignalc and showsignalsc ? OTT*0.995 : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0)
    sellSignallc = crossunder(src, OTT[2])
    plotshape(sellSignallc and showsignalsc ? OTT*1.005 : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)
    mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0,display=display.none)
    longFillColor = highlighting ? (MAvg>OTT ? color.green : na) : na
    shortFillColor = highlighting ? (MAvg<OTT ? color.red : na) : na
    fill(mPlot, pALL, title="UpTrend Highligter", color=longFillColor)
    fill(mPlot, pALL, title="DownTrend Highligter", color=shortFillColor)
    buySignalr = crossover(OTT[2], OTT[3])
    plotshape(buySignalr and showsignalsr ? OTT*0.995 : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0)
    sellSignallr = crossunder(OTT[2], OTT[3])
    plotshape(sellSignallr and showsignalsr ? OTT*1.005 : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)
      
      
      
    
    DEU30-13813.2.png DEU30-13813.2.png
    #162452 quote
    NicolasNicolas
    Keymaster
    Legend

    ok, will do it asap.

    Luciole thanked this post
    #164522 quote
    LucioleLuciole
    Participant
    Senior

    Hello Nicolas , not willing to put you into hurry !

    but as it’s been a month the topic is some pages away hidden, just to be sure it’s still on a “todo list” , and to say that I didn’t lost interest in exploring it in PRT 😉

    #164557 quote
    NicolasNicolas
    Keymaster
    Legend

    I started looking at it at the beginning of the week, I'll get down to it. That said, it looks like yet another trailingstop type indicator (like the supertrend) based on a percentage deviation from the type of moving average you choose.

    #165179 quote
    NicolasNicolas
    Keymaster
    Legend

    Conversion is done, you can download this indicator in the library:

    Optimized Trend Tracker

    Luciole thanked this post
    optimized-trend-tracker-trading-view.png optimized-trend-tracker-trading-view.png
    #165189 quote
    LucioleLuciole
    Participant
    Senior

    Thanks Nicolas !

    I get your feeling about “another SuperTrend”.

    I still appreciate your conversion, hope it will suits other people needs.

    #229350 quote
    supertitisupertiti
    Participant
    Master

    Bonsoir à tous,

    Encore un indicateur qui devrait retenir toute notre attention ! Je lui ai adjoint une moyenne pour adoucir les courbes.

    OTTMA = average [p,m](pALL)

    p = 2

    m = 1 exponentielle

    J’aimerai faire 2 screeners UP and DOWN quand les “closes” croisent la moyenne (OTTMA)

    je n’arrive pas à créer le screener  car le code me renvoie un problème avec ” averagetypevar”

    Alors si quelqu’un peut aider il est le bienvenu.

    Bons trades à tous.

    ci-joint un graphe AIR LIQUIDE

    OTTMA-AIR-LIQUIDE.jpg OTTMA-AIR-LIQUIDE.jpg
    #229519 quote
    supertitisupertiti
    Participant
    Master

    Bonjour à tous,

    Alors personne pour résoudre le problème à priori simple mais qui fonctionne pas ?

    C1 = customclose crosses over OTTMA

    pourquoi “averagetypevar” vient nos embêter ?!

    Si quelqu’un a une idée il est le bienvenu

    bon week-end

    joint graphe de Nvidia avec la OTTMA

    NVIDIA.jpg NVIDIA.jpg
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Conversion TV : Optimized Trend Tracker


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 7 replies,
has 3 voices, and was last updated by supertitisupertiti
2 years, 6 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 02/23/2021
Status: Active
Attachments: 4 files
ProRealCode ProRealCode
Loading...