DSL OSCILLATOR TW
Forums › ProRealTime forum Italiano › Supporto ProBuilder › DSL OSCILLATOR TW
- This topic has 3 replies, 3 voices, and was last updated 4 days ago by robertogozzi.
-
-
10/26/2024 at 8:46 PM #239546
Ciao, chiedo se è possibile tradurre questo indicatore che mi pare interessante in combinazione con un indicatore di trend: https://www.tradingview.com/script/bVMgRGq8-DSL-Oscillator-BigBeluga/#:~:text=The%20DSL%20(Discontinued%20Signal%20Lines,Exponential%20Moving%20Average%20(ZLEMA)
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © BigBeluga//@version=5
indicator(“DSL Oscillator [BigBeluga]”)// ====================================================================================================================}
// INPUTS
// ===================================================================================================================={// User inputs for customization
len = input.int(10, “Length”)
dsl_mode = input.string(“Fast”, “DSL Lines Mode”, [“Fast”, “Slow”]) == “Fast” ? 2 : 1// Color definitions
color_up = #8BD8BD
color_dn = #436cd3// Condition for a dashed line
bool dashed = bool(bar_index % 2)// ====================================================================================================================}
// CALCULATIONS
// ===================================================================================================================={// Calculate RSI with a period of 10
RSI = ta.rsi(close, 10)// Zero-Lag Exponential Moving Average function
zlema(src, length) =>
lag = math.floor((length – 1) / 2)
ema_data = 2 * src – src[lag]
ema2 = ta.ema(ema_data, length)
ema2// Discontinued Signal Lines
dsl_lines(src, length)=>
up = 0.
dn = 0.
up := (src > ta.sma(src, length)) ? nz(up[1]) + dsl_mode / length * (src – nz(up[1])) : nz(up[1])
dn := (src < ta.sma(src, length)) ? nz(dn[1]) + dsl_mode / length * (src – nz(dn[1])) : nz(dn[1])
[up, dn]// Calculate DSL lines for RSI
[lvlu, lvld] = dsl_lines(RSI, len)// Calculate DSL oscillator using ZLEMA of the average of upper and lower DSL Lines
dsl_osc = zlema((lvlu + lvld) / 2, 10)// Calculate DSL Lines for the oscillator
[level_up, level_dn] = dsl_lines(dsl_osc, 10)// Determine color based on oscillator position relative to its DSL Lines
color = color.from_gradient(dsl_osc, level_dn, level_up, color_dn, color_up)// ====================================================================================================================}
// PLOT
// ===================================================================================================================={// Plot upper and lower DSL Lines
plot(level_up, color = dashed ? color.new(color_up, 20) : na, editable = false)
plot(level_dn, color = dashed ? color.new(color_dn, 20) : na, editable = false)// Plot the DSL oscillator
plot(dsl_osc, color = color, linewidth = 2)// Detect crossovers for signal generation
up = ta.crossover(dsl_osc, level_dn) and dsl_osc < 55
dn = ta.crossunder(dsl_osc, level_up) and dsl_osc > 50// Plot signals on the oscillator
plotshape(up ? dsl_osc[1] : na, “”, shape.circle, location.absolute, color_up, -1, “”, chart.fg_color, false, size.tiny)
plotshape(dn ? dsl_osc[1] : na, “”, shape.circle, location.absolute, color_dn, -1, “”, chart.fg_color, false, size.tiny)// Plot signals on the chart
plotshape(up, “”, shape.triangleup, location.bottom, color_up, 0, “Enter”, chart.fg_color, true, size.tiny,
force_overlay = true)
plotshape(dn, “”, shape.triangledown, location.top, color_dn, 0, “Exit”, chart.fg_color, true, size.tiny,
force_overlay = true)// Color the background on signal occurrences
bgcolor(up ? color.new(color_up, 90) : na, force_overlay = true, editable = false)
bgcolor(dn ? color.new(color_dn, 90) : na, force_overlay = true, editable = false)// Color candles based on signals
candle_col = up ? color.new(color_up, 0) : dn ? color.new(color_dn, 0) : naplotcandle(open, high, low, close, “”,
candle_col,
candle_col,
bordercolor = candle_col,
force_overlay = true,
editable = false)// Plot horizontal lines for visual reference
h = plot(75, display = display.none, editable = false)
m = plot(50, display = display.none, editable = false)
l = plot(25, display = display.none, editable = false)// Fill areas between horizontal lines
fill(m, h, 120, 50, color_up, na, editable = false)
fill(m, l, 50, -20, na, color_dn, editable = false)// ====================================================================================================================}
10/29/2024 at 5:50 PM #239738Ciao. Eccolo qui:
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273//-----------------------------------------////PRC_DSL Oscillator//version = 0//29.10.2024//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//-----------------------------------------////-----------------------------------------////-----------------------------------------////len=10 //length//fast=1if fast thendslMode=2elsedslMode=1endif//-----------------------------------------//// RSI and DSL Calculations ////-----------------------------------------////-----Rsimyrsi=rsi[10](close)//-----DSL Lines for RSIlvlu=0lvld=0if myrsi>average[len](myrsi) thenlvlu=lvlu[1]+dslMode/len*(myrsi-lvlu[1])lvld=lvld[1]elsif myrsi<average[len](myrsi) thenlvld=lvld[1]+dslMode/len*(myrsi-lvld[1])lvlu=lvlu[1]endif//-----------------------------------------//// DSL Oscillator Calculations ////-----------------------------------------////-----DSL Oscillatorsrc=(lvlu+lvld)/2length=10lag=floor((length-1)/2)if barindex>lag thenemaData=2*src-src[lag]endifdslOsc=average[length,1](emaData)//-----DSL Lines for the OscillatorlevelUp=0levelDn=0if dslOsc>average[10](dslOsc) thenlevelUp=levelUp[1]+dslMode/10*(dslOsc-levelUp[1])levelDn=levelDn[1]elsif dslOsc<average[10](dslOsc) thenlevelDn=levelDn[1]+dslMode/10*(dslOsc-levelDn[1])levelUp=levelUp[1]endif//-----------------------------------------//// Plot Configuration ////-----------------------------------------////-----Signalsif dslOsc crosses under levelUp thendrawpoint(barindex,dslOsc,2)coloured("blue")elsif dslOsc crosses over levelDn thendrawpoint(barindex,dslOsc,2)coloured("fuchsia")endif//-----DSL Oscillator colorif dslOsc > levelUp thenr=0g=0b=255elsif dslOsc<levelDn thenr=255g=0b=255endif//-----------------------------------------//return dslOsc style(line,2)coloured(r,g,b), levelUp as "Level Up" coloured("fuchsia")style(dottedline),levelDn as "Level Down" coloured("blue")style(dottedline), 25 style(dottedline2,1)coloured("grey",100),50 style(dottedline2,1)coloured("grey",100),75 style(dottedline2,1)coloured("grey",100)11/02/2024 at 11:29 AM #23989511/02/2024 at 4:20 PM #239903Basta che togli le doppie barre (solo quelle iniziali) dalle linee 10 e 11.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on