traduzione codice TW Weighted Oscillator Convergence Divergence
Forums › ProRealTime forum Italiano › Supporto ProBuilder › traduzione codice TW Weighted Oscillator Convergence Divergence
- This topic has 2 replies, 2 voices, and was last updated 3 months ago by Msport71.
-
-
09/13/2024 at 7:10 AM #237531
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)
nonLagWild_ma(_src, _malength) =>
_wild = 0.0
_wild := nz(_wild[1]) + (_src – nz(_wild[1])) / _malength
_wildma(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)09/13/2024 at 9:23 AM #237533Ecco qui:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162//--------------------------------------------------------////PRC_Weighted Oscillator Convergence Divergence (WOCD)//version = 0//13.09.2024//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//--------------------------------------------------------////-----Inputs---------------------------------------------////--------------------------------------------------------//length=9smooth1=5smooth2=7maTypeInput=1 //1=Weighted 2=NonLag 3=Wildersrc=closeoscDiff=9//--------------------------------------------------------////-----Raw Oscillator-------------------------------------////--------------------------------------------------------//diff=close-src[length]if maTypeInput=1 thensmoothedOscillator=weightedaverage[oscDiff](diff)elsif maTypeInput=2 thenalpha=2/(oscDiff+1)smoothedOscillator=alpha*diff+(1-alpha)*exponentialaverage[oscdiff](diff)elsif maTypeInput=3 thensmoothedOscillator=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 thenif hist[1]<hist thenr=0g=255b=229elser=178g=220b=223endifelseif hist[1]<hist thenr=255g=205b=240elser=255g=82b=189endifendif//--------------------------------------------------------//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)1 user thanked author for this post.
09/13/2024 at 12:20 PM #237539 -
AuthorPosts
Find exclusive trading pro-tools on