커뮤니티

지표 변환 부탁 드립니다

프로필 이미지
재벌후손
2025-05-03 11:28:25
344
글번호 190565
답변완료
// ====================================================================================================================} // 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) : na plotcandle(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) // ====================================================================================================================}
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2025-05-07 10:17:04

안녕하세요 예스스탁입니다. input : len(10); input : dsl_mode(2); #1: Slow,2 Fast var : color_up(0),color_dn(0),Dashed(False),R(0); color_up = Cyan; color_dn = Blue; Dashed = index % 2 == 0; R = rsi(10); var : lvlu(0),lvld(0); lvlu = IFF(R > ma(R, len) , IFF(IsNan(lvlu[1])==true,0,lvlu[1]) + dsl_mode / len * (R - IFF(IsNan(lvlu[1])==true,0,lvlu[1])) , IFF(IsNan(lvlu[1])==true,0,lvlu[1])); lvld = IFf(R < ma(R, len) , IFF(IsNan(lvld[1])==true,0,lvld[1]) + dsl_mode / len * (R - IFF(IsNan(lvld[1])==true,0,lvld[1])) , IFF(IsNan(lvld[1])==true,0,lvld[1])); var : src(0),lag(0),Ema_data(0),Ema2(0),dsl_osc(0); src = (lvlu + lvld) / 2; lag = floor((10 - 1) / 2); ema_data = 2 * src - src[lag]; ema2 = ema(ema_data, 10); dsl_osc = Ema2; var : level_up(0),level_dn(0); level_up = IFF(dsl_osc > ma(dsl_osc, 10) , IFF(IsNan(level_up[1])==true,0,level_up[1]) + dsl_mode / 10 * (dsl_osc - IFF(IsNan(level_up[1])==true,0,level_up[1])) , IFF(IsNan(level_up[1])==true,0,level_up[1])); level_dn = IFf(dsl_osc < ma(dsl_osc, 10) , IFF(IsNan(level_dn[1])==true,0,level_dn[1]) + dsl_mode / 10 * (dsl_osc - IFF(IsNan(level_dn[1])==true,0,level_dn[1])) , IFF(IsNan(level_dn[1])==true,0,level_dn[1])); plot1(level_up,"level_up",IFF(dashed , color_up , Black)); plot2(level_dn,"level_dn",IFF(dashed , color_dn , Black)); plot3(dsl_osc,"dsl_osc"); var : tx1(0),tx2(0); if CrossUp(dsl_osc, level_dn) and dsl_osc < 55 then { tx1 = Text_New_Self(sDate[1],sTime[1],dsl_osc[1],"●"); Text_SetColor(tx1,color_up); Text_SetStyle(tx1,2,2); tx2 = Text_New(sDate,sTime,L,"▲"); Text_SetColor(tx2,color_up); Text_SetStyle(tx2,2,0); Text_SetSize(tx2,20); } if CrossDown(dsl_osc, level_up) and dsl_osc > 50 then { tx1 = Text_New_Self(sDate[1],sTime[1],dsl_osc[1],"●"); Text_SetColor(tx1,color_dn); Text_SetStyle(tx1,2,2); tx2 = Text_New(sDate,sTime,H,"▼"); Text_SetColor(tx2,color_dn); Text_SetStyle(tx2,2,1); Text_SetSize(tx2,20); } 즐거운 하루되세요 > 재벌후손 님이 쓴 글입니다. > 제목 : 지표 변환 부탁 드립니다 > // ====================================================================================================================} // 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) : na plotcandle(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) // ====================================================================================================================}