traduzione codice TW Weighted Oscillator Convergence Divergence

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #237531 quote
    Msport71
    Participant
    Junior

    Buongiorno,

     

    chiedo cortese traduzione di questo codice, che sono curioso di testare e vedere se è migliore del famoso Alligator di Williams.

    Grazie come sempre per l’aiuto.

    https://it.tradingview.com/script/JAZ2GOdu-Weighted-Oscillator-Convergence-Divergence/

    // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
    // © tseddik

    //@version=5
    indicator(title=”Weighted Oscillator Convergence Divergence”, shorttitle=”WOCD”, overlay=false, timeframe = ”, timeframe_gaps = true)

    // Inputs
    length = input(9, title=”Length”)
    smooth1 = input(5, title=”Smoothing 1″)
    smooth2 = input(7, title=”Smoothing 2″)
    maTypeInput = input.string(“Weighted”, title=”MA Type”, options=[“Weighted”,”NonLag”,”Wilder”])
    src = input.source(close, title= “source”)
    oscDiff = input(9, title=”0sc Diff”)

    col_length = input(#2962FF, “Length  ”, group=”Color Settings”, inline=”Length”)
    col_smooth1 = input(#FF6D00, “Smooth1  ”, group=”Color Settings”, inline=”Smooth1″)
    col_smooth2 = input(#ff00d4, “Smooth2  ”, group=”Color Settings”, inline=”Smooth2″)
    col_grow_above = input(#00ffe5, “Above   Grow”, group=”Histogram”, inline=”Above”)
    col_fall_above = input(#b2dcdf, “Fall”, group=”Histogram”, inline=”Above”)
    col_grow_below = input(#ffcdf0, “Below Grow”, group=”Histogram”, inline=”Below”)
    col_fall_below = input(#ff52bd, “Fall”, group=”Histogram”, inline=”Below”)

    nonLagEMA(src, length) =>
    alpha = 2 / (length + 1)
    nonLag = 0.0
    nonLag := alpha * src + (1 – alpha) * ta.ema(src, length)
    nonLag

    Wild_ma(_src, _malength) =>
    _wild = 0.0
    _wild := nz(_wild[1]) + (_src – nz(_wild[1])) / _malength
    _wild

    ma(source, length, type) =>
    switch type
    “NonLag” => nonLagEMA(source, length)
    “Wilder” => Wild_ma(source, length)
    “Weighted” => ta.wma(source, length)

    // Calculate raw oscillator value
    diff = close – src[length]

    smoothedOscillator = ma(diff, oscDiff, maTypeInput)

    // Apply smoothing
    smoothedValue1 = ta.ema(smoothedOscillator, smooth1)
    smoothedValue2 = ta.sma(smoothedOscillator, smooth2)

    hist = smoothedOscillator – smoothedValue1

    // Plot oscillator and smoothed values
    plot(hist, title=”Histogram”, style=plot.style_columns, color=(hist>=0 ? (hist[1] < hist ? col_grow_above : col_fall_above) : (hist[1] < hist ? col_grow_below : col_fall_below)))
    plot(smoothedOscillator, color=col_length, title=”WOCD Line”)
    plot(smoothedValue1, color=col_smooth1, title=”Smoothed EMA”)
    plot(smoothedValue2, color=col_smooth2, title=”Smoothed SMA”)

    // Plot zero line
    hline(0, “Zero Line”, color=color.gray)

    #237533 quote
    Iván González
    Moderator
    Master

    Ecco qui:

    //--------------------------------------------------------//
    //PRC_Weighted Oscillator Convergence Divergence (WOCD)
    //version = 0
    //13.09.2024
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //--------------------------------------------------------//
    //-----Inputs---------------------------------------------//
    //--------------------------------------------------------//
    length=9
    smooth1=5
    smooth2=7
    maTypeInput=1 //1=Weighted 2=NonLag 3=Wilder
    src=close
    oscDiff=9
    //--------------------------------------------------------//
    //-----Raw Oscillator-------------------------------------//
    //--------------------------------------------------------//
    diff=close-src[length]
    if maTypeInput=1 then
    smoothedOscillator=weightedaverage[oscDiff](diff)
    elsif maTypeInput=2 then
    alpha=2/(oscDiff+1)
    smoothedOscillator=alpha*diff+(1-alpha)*exponentialaverage[oscdiff](diff)
    elsif maTypeInput=3 then
    smoothedOscillator=WilderAverage[oscdiff](diff)
    endif
    //--------------------------------------------------------//
    //-----Apply Smoothing------------------------------------//
    //--------------------------------------------------------//
    smoothedValue1=exponentialaverage[smooth1](smoothedOscillator)
    smoothedValue2=average[smooth2](smoothedOscillator)
    //--------------------------------------------------------//
    //-----Histogram------------------------------------------//
    //--------------------------------------------------------//
    hist=smoothedOscillator-smoothedValue1
    //--------------------------------------------------------//
    //-----Plot Oscillator and smoothed values----------------//
    //--------------------------------------------------------//
    if hist>0 then
    if hist[1]<hist then
    r=0
    g=255
    b=229
    else
    r=178
    g=220
    b=223
    endif
    else
    if hist[1]<hist then
    r=255
    g=205
    b=240
    else
    r=255
    g=82
    b=189
    endif
    endif
    //--------------------------------------------------------//
    return hist as "Histogram" style(histogram)coloured(r,g,b), smoothedOscillator as "WOCD Line" coloured(41,98,255)style(line,2),smoothedValue1 as "Smoothed EMA" coloured(255,109,0), smoothedValue2 as "Smoothed SMA" coloured(255,0,212)
    Msport71 thanked this post
    #237539 quote
    Msport71
    Participant
    Junior

    Grazie e mille, super veloce!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

traduzione codice TW Weighted Oscillator Convergence Divergence


ProBuilder: Indicatori & Strumenti Personalizzati

New Reply
Author
author-avatar
Msport71 @carlo-pasca Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Msport71
1 year, 4 months ago.

Topic Details
Forum: ProBuilder: Indicatori & Strumenti Personalizzati
Language: Italian
Started: 09/13/2024
Status: Active
Attachments: 1 files
Logo Logo
Loading...