traduzione codice Donchian Channel Strenght
Forums › ProRealTime forum Italiano › Supporto ProBuilder › traduzione codice Donchian Channel Strenght
- This topic has 2 replies, 2 voices, and was last updated 3 months ago by
Msport71.
-
-
05/17/2024 at 7:15 AM #232747
Buongiorno,
sempre in tema di Canale di Donchain, mi piacerebbe testare questo codice che sembra un oscillatore RSI applicato a Donchian, con evidenziazione di zone
di overbought e oversold.
Ringrazio sempre per il cortese aiuto.
https://it.tradingview.com/script/hCfZsNU2-Donchian-Channels-Strength/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Daniel_Ge//@version=5
indicator(title=”Donchian Channels Strength”, shorttitle=”DC Strength”, overlay=false, timeframe=””, timeframe_gaps=true)// Input
src = input(close, “Source”, inline = “Source”)
include_wicks = input.bool(false, “Include Wicks”, inline = “Source”)
length = input.int(13, “Length”, minval=2)
maTypeInput = input.string(“SMMA (RMA)”, title=”MA Type”, options=[“SMA”, “EMA”, “SMMA (RMA)”, “WMA”, “VWMA”])
signal_length = input.int(9, “Signal Length”)
overbought_zone = input.int(80, “Overbought Zone”, tooltip = “Can be used for alerts”)
oversold_zone = input.int(20, “Oversold Zone”, tooltip = “Can be used for alerts”)// MA Switch
ma(source, length, type) =>
switch type
“SMA” => ta.sma(source, length)
“EMA” => ta.ema(source, length)
“SMMA (RMA)” => ta.rma(source, length)
“WMA” => ta.wma(source, length)
“VWMA” => ta.vwma(source, length)// Calculations
lower = ta.lowest(src, length)
upper = ta.highest(src, length)if include_wicks
lower := ta.lowest(low, length)
upper := ta.highest(high, length)basis = math.avg(upper, lower)
dif = src – basis
ma_dif = ma(dif, length, maTypeInput)
ma_dif_abs = ma(math.abs(dif), length, maTypeInput)
dc_strength = ma_dif / ma_dif_abs * 50 + 50// Lines
hline(overbought_zone, linestyle = hline.style_dotted, display = display.none)
hline(50, linestyle = hline.style_solid)
hline(oversold_zone, linestyle = hline.style_dotted, display = display.none)// Plots
p_50 = plot(50, editable = false, display = display.none) // only used for filling
p_strength = plot(dc_strength, “DC Strength”, color = dc_strength > 50 ? color(#00cbff) : color(#ff0099))
plot(ta.ema(dc_strength, signal_length), “Signal”, color = color(#d1d4dc))// Filling
fill(p_strength, p_50, 80, 50, color.new(#00cbff, 70), na, title = “Upper Filling”)
fill(p_50, p_strength, 50, 20, na, color.new(#ff0099, 70), title = “Lower Filling”)// Alerts
alertcondition(ta.crossover(dc_strength, 50), “DC Strength crossover 50”, “DC Strength crossover 50”)
alertcondition(ta.crossunder(dc_strength, 50), “DC Strength crossunder 50”, “DC Strength crossunder 50”)
alertcondition(ta.crossover(dc_strength, overbought_zone), “DC Strength entered overbought zone”, “DC Strength entered overbought zone”)
alertcondition(ta.crossunder(dc_strength, overbought_zone), “DC Strength left overbought zone”, “DC Strength left overbought zone”)
alertcondition(ta.crossunder(dc_strength, oversold_zone), “DC Strength entered oversold zone”, “DC Strength entered oversold zone”)
alertcondition(ta.crossover(dc_strength, oversold_zone), “DC Strength left oversold zone”, “DC Strength left oversold zone”)05/20/2024 at 2:36 PM #232822Ciao. Ecco il codice tradotto:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778//--------------------------------------------------////PRC_Donchian Channels Strength//version = 0//20.05.24//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//--------------------------------------------------////-----Inputs---------------------------------------//src=closeincludeWicks=0//Boolean//Include Wickslength=13maTypeInput=3//0=SMA, 1=EMA 2=WMA, 3=SMMA (RMA)signalLength=9//overboughtZone=80//Overbought ZoneoversoldZone=20//Oversold Zone//--------------------------------------------------////-----Calculations---------------------------------//if includewicks thenlower=lowest[length](low)upper=highest[length](high)elselower=lowest[length](src)upper=highest[length](src)endifbasis=(upper+lower)/2dif=src-basis//----MA DIF Calculations----------------------------//source=difif maTypeInput=0 thenmadif=average[length,0](source)elsif maTypeInput=1 thenmadif=average[length,1](source)elsif maTypeInput=2 thenmadif=average[length,2](source)elsealpha = 1/lengthif barindex <= 2*length thenmadif = average[length](source)elsemadif = alpha*source + (1-alpha)*madif[1]endifendif//--------------------------------------------------////----MA abs(DIF) Calculations----------------------//source2=abs(dif)if maTypeInput=0 thenmadifabs=average[length,0](source2)elsif maTypeInput=1 thenmadifabs=average[length,1](source2)elsif maTypeInput=2 thenmadifabs=average[length,2](source2)elsealpha = 1/lengthif barindex <= 2*length thenmadifabs = average[length](source2)elsemadifabs = alpha*source2 + (1-alpha)*madifabs[1]endifendif//--------------------------------------------------////-----Strength-------------------------------------//dcstrength=madif/madifabs*50+50signalstrength=average[signallength,1](dcstrength)//--------------------------------------------------////-----Colours----------------------------------------//if dcstrength>50 thenr=0g=203b=255elser=255g=0b=153endifcolorbetween(50,dcstrength,r,g,b,35)//--------------------------------------------------//return overboughtZone style(dottedline2), oversoldZone style(dottedline2), 50, dcstrength as "DC Strength"coloured(r,g,b)style(line,3),signalstrength as "Signal"coloured("grey")style(line,2)05/20/2024 at 3:48 PM #232826 -
AuthorPosts
Find exclusive trading pro-tools on