커뮤니티

지표 변환 문의드립니다.

프로필 이미지
knoll
2025-04-28 20:43:02
316
글번호 190477
답변완료
귀사의 무궁한 발전을 기원합니다 안녕하세요,수고 많으십니다 트레이딩뷰 지표 변환해 주시면 대단히 감사하겠습니다. 주석이 좀 많네요. 챠트상에 봉그리기 비쥬얼은 구현하기 힘들면 넘어가시고, 매수,매도 신호만 ▲, ▼ 이런식으로 넣어 주시면 안될까요. 글자가 깨지면 수식은 첨부화일에 있어요. +++++++++ //@version=6 indicator(title="Adaptive Trend Flow [QuantAlgo]", overlay=true, max_labels_count=500) // &#9556;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9559; // // &#9553; USER-DEFINED SETTINGS &#9553; // // &#9562;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9565; // // Input Groups var string trend_settings = "&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552; Trend Settings &#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;" var string visual_settings = "&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552; Visualization Settings &#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;" // Tooltips tooltip_length = "Length of the trend calculation period. Higher values create smoother signals." tooltip_smooth = "Smoothing period for volatility. Higher values reduce noise." tooltip_sens = "Multiplier for volatility bands. Higher values create wider bands." tooltip_bars = "Enable/disable bar coloring based on trend direction" tooltip_bg = "Enable/disable background gradient coloring" tooltip_signals = "Enable/disable signal markers on trend changes" // Trend Settings length = input.int(10, "Main Length", minval=2, group=trend_settings, tooltip=tooltip_length) smooth_len = input.int(14, "Smoothing Length", minval=2, group=trend_settings, tooltip=tooltip_smooth) sensitivity = input.float(2.0, "Sensitivity", step=0.1, group=trend_settings, tooltip=tooltip_sens) // Visualization Settings bullcolor = input.color(#00ffaa, "Bullish Color", group=visual_settings) bearcolor = input.color(#ff0000, "Bearish Color", group=visual_settings) showbars = input.bool(true, "Color Bars?", group=visual_settings, tooltip=tooltip_bars) showbg = input.bool(true, "Background Color?", group=visual_settings, tooltip=tooltip_bg) showsignals = input.bool(true, "Show Signals?", group=visual_settings, tooltip=tooltip_signals) // &#9556;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9559; // // &#9553; TREND CALCULATIONS &#9553; // // &#9562;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9565; // calculate_trend_levels() => typical = hlc3 fast_ema = ta.ema(typical, length) slow_ema = ta.ema(typical, length * 2) basis = (fast_ema + slow_ema) / 2 vol = ta.stdev(typical, length) smooth_vol = ta.ema(vol, smooth_len) upper = basis + (smooth_vol * sensitivity) lower = basis - (smooth_vol * sensitivity) [basis, upper, lower] get_trend_state(upper, lower, basis) => var float prev_level = na var int trend = 0 if na(prev_level) trend := close > basis ? 1 : -1 prev_level := trend == 1 ? lower : upper if trend == 1 if close < lower trend := -1 prev_level := upper else prev_level := lower else if close > upper trend := 1 prev_level := lower else prev_level := upper [trend, prev_level] [basis, upper, lower] = calculate_trend_levels() [trend, level] = get_trend_state(upper, lower, basis) // &#9556;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9559; // // &#9553; VISUALIZATION &#9553; // // &#9562;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9565; // // Signal detection long_signal = trend == 1 and trend[1] == -1 short_signal = trend == -1 and trend[1] == 1 // Plot average/basis line p2 = plot(basis, color=trend == 1 ? bullcolor : bearcolor, linewidth=2) // Plot trend line with breaks p1 = plot(level, color=close > level ? bullcolor : bearcolor, linewidth=2, style=plot.style_linebr) // Plot additional trend line plot(level, color=close > level ? bullcolor : bearcolor, linewidth=2, style=plot.style_linebr) // Add labels for crossovers if showsignals and ta.crossunder(close, level) label.new(bar_index, level, "&#119930;", color=bearcolor, textcolor=chart.fg_color, style=label.style_label_lower_right) if showsignals and ta.crossover(close, level) label.new(bar_index, level, "&#119923;", color=bullcolor, textcolor=chart.bg_color, style=label.style_label_upper_right) // Background gradient coloring var float intensity = 0.0 var int prev_trend = 0 // Reset intensity on trend change if trend != prev_trend intensity := 0.0 prev_trend := trend // Increment intensity based on trend intensity := trend == 1 ? math.min(intensity + 1, 20) : trend == -1 ? math.min(intensity + 1, 20) : intensity // Calculate gradient colors color grad_color = trend == 1 ? color.from_gradient(intensity, 0, 20, color.new(bullcolor, 95), color.new(bullcolor, 80)) : color.from_gradient(intensity, 0, 20, color.new(bearcolor, 95), color.new(bearcolor, 80)) bgcolor(showbg ? grad_color : na) // Fill between the lines fill(p1, p2, level, basis, trend == 1 ? bullcolor : bearcolor, na) fill(p1, p2, level, basis, trend == 1 ? bullcolor : bearcolor, na) // Bar Coloring barcolor(showbars ? (trend == 1 ? color.new(bullcolor, 15) : color.new(bearcolor, 15)) : na) // &#9556;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9559; // // &#9553; ALERTS &#9553; // // &#9562;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9565; // alertcondition(long_signal, title="Adaptive Trend Flow Long", message="Adaptive Trend Flow Long {{exchange}}:{{ticker}}") alertcondition(short_signal, title="Adaptive Trend Flow Short", message="Adaptive Trend Flow Short {{exchange}}:{{ticker}}") // &#9556;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9559; // // &#9553; CREATED BY &#9553; // // &#9562;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9565; //
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2025-04-29 11:09:55

안녕하세요 예스스탁입니다. input : length(10),smooth_len(14),sensitivity(2.0); input : bullcolor(Cyan); input : bearcolor(Red); input : showbars(true); input : showbg(true); input : showsignals(true); var : typical(0),fast_ema(0),slow_ema(0),basis(0); var : vol(0),smooth_vol(0),upper(0),lower(0); typical = (h+l+c)/3; fast_ema = ema(typical, length); slow_ema = ema(typical, length * 2); basis = (fast_ema + slow_ema) / 2; vol = std(typical, length); smooth_vol = ema(vol, smooth_len); upper = basis + (smooth_vol * sensitivity); lower = basis - (smooth_vol * sensitivity); var : Level(Nan),trend(0); if IsNaN(level) == true Then { trend = iff(close > basis , 1 , -1); level = iff(trend == 1 , lower , upper); } if trend == 1 Then { if close < lower Then { trend = -1; level = upper; } else { level = lower; } } else { if close > upper Then { trend = 1; level = lower; } else { level = upper; } } var : long_signal(False),short_signal(False),tx(0); long_signal = trend == 1 and trend[1] == -1; short_signal = trend == -1 and trend[1] == 1; plot1(basis,"basis",iff(trend == 1 , bullcolor , bearcolor)); plot2(level,"level1",iff(close > level , bullcolor , bearcolor)); // Add labels for crossovers if showsignals and CrossDown(close, level) Then { tx = Text_New(sDate,sTime,level,"▼"); Text_SetColor(tx,bearcolor); Text_SetStyle(tx,2,1); Text_SetSize(tx,20); } if showsignals and CrossUp(close, level) Then { tx = Text_New(sDate,sTime,level,"▲"); Text_SetColor(tx,bullcolor); Text_SetStyle(tx,2,0); Text_SetSize(tx,20); } 즐거운 하루되세요 > knoll 님이 쓴 글입니다. > 제목 : 지표 변환 문의드립니다. > 귀사의 무궁한 발전을 기원합니다 안녕하세요,수고 많으십니다 트레이딩뷰 지표 변환해 주시면 대단히 감사하겠습니다. 주석이 좀 많네요. 챠트상에 봉그리기 비쥬얼은 구현하기 힘들면 넘어가시고, 매수,매도 신호만 ▲, ▼ 이런식으로 넣어 주시면 안될까요. 글자가 깨지면 수식은 첨부화일에 있어요. +++++++++ //@version=6 indicator(title="Adaptive Trend Flow [QuantAlgo]", overlay=true, max_labels_count=500) // &#9556;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9559; // // &#9553; USER-DEFINED SETTINGS &#9553; // // &#9562;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9565; // // Input Groups var string trend_settings = "&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552; Trend Settings &#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;" var string visual_settings = "&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552; Visualization Settings &#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;" // Tooltips tooltip_length = "Length of the trend calculation period. Higher values create smoother signals." tooltip_smooth = "Smoothing period for volatility. Higher values reduce noise." tooltip_sens = "Multiplier for volatility bands. Higher values create wider bands." tooltip_bars = "Enable/disable bar coloring based on trend direction" tooltip_bg = "Enable/disable background gradient coloring" tooltip_signals = "Enable/disable signal markers on trend changes" // Trend Settings length = input.int(10, "Main Length", minval=2, group=trend_settings, tooltip=tooltip_length) smooth_len = input.int(14, "Smoothing Length", minval=2, group=trend_settings, tooltip=tooltip_smooth) sensitivity = input.float(2.0, "Sensitivity", step=0.1, group=trend_settings, tooltip=tooltip_sens) // Visualization Settings bullcolor = input.color(#00ffaa, "Bullish Color", group=visual_settings) bearcolor = input.color(#ff0000, "Bearish Color", group=visual_settings) showbars = input.bool(true, "Color Bars?", group=visual_settings, tooltip=tooltip_bars) showbg = input.bool(true, "Background Color?", group=visual_settings, tooltip=tooltip_bg) showsignals = input.bool(true, "Show Signals?", group=visual_settings, tooltip=tooltip_signals) // &#9556;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9559; // // &#9553; TREND CALCULATIONS &#9553; // // &#9562;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9565; // calculate_trend_levels() => typical = hlc3 fast_ema = ta.ema(typical, length) slow_ema = ta.ema(typical, length * 2) basis = (fast_ema + slow_ema) / 2 vol = ta.stdev(typical, length) smooth_vol = ta.ema(vol, smooth_len) upper = basis + (smooth_vol * sensitivity) lower = basis - (smooth_vol * sensitivity) [basis, upper, lower] get_trend_state(upper, lower, basis) => var float prev_level = na var int trend = 0 if na(prev_level) trend := close > basis ? 1 : -1 prev_level := trend == 1 ? lower : upper if trend == 1 if close < lower trend := -1 prev_level := upper else prev_level := lower else if close > upper trend := 1 prev_level := lower else prev_level := upper [trend, prev_level] [basis, upper, lower] = calculate_trend_levels() [trend, level] = get_trend_state(upper, lower, basis) // &#9556;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9559; // // &#9553; VISUALIZATION &#9553; // // &#9562;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9565; // // Signal detection long_signal = trend == 1 and trend[1] == -1 short_signal = trend == -1 and trend[1] == 1 // Plot average/basis line p2 = plot(basis, color=trend == 1 ? bullcolor : bearcolor, linewidth=2) // Plot trend line with breaks p1 = plot(level, color=close > level ? bullcolor : bearcolor, linewidth=2, style=plot.style_linebr) // Plot additional trend line plot(level, color=close > level ? bullcolor : bearcolor, linewidth=2, style=plot.style_linebr) // Add labels for crossovers if showsignals and ta.crossunder(close, level) label.new(bar_index, level, "&#119930;", color=bearcolor, textcolor=chart.fg_color, style=label.style_label_lower_right) if showsignals and ta.crossover(close, level) label.new(bar_index, level, "&#119923;", color=bullcolor, textcolor=chart.bg_color, style=label.style_label_upper_right) // Background gradient coloring var float intensity = 0.0 var int prev_trend = 0 // Reset intensity on trend change if trend != prev_trend intensity := 0.0 prev_trend := trend // Increment intensity based on trend intensity := trend == 1 ? math.min(intensity + 1, 20) : trend == -1 ? math.min(intensity + 1, 20) : intensity // Calculate gradient colors color grad_color = trend == 1 ? color.from_gradient(intensity, 0, 20, color.new(bullcolor, 95), color.new(bullcolor, 80)) : color.from_gradient(intensity, 0, 20, color.new(bearcolor, 95), color.new(bearcolor, 80)) bgcolor(showbg ? grad_color : na) // Fill between the lines fill(p1, p2, level, basis, trend == 1 ? bullcolor : bearcolor, na) fill(p1, p2, level, basis, trend == 1 ? bullcolor : bearcolor, na) // Bar Coloring barcolor(showbars ? (trend == 1 ? color.new(bullcolor, 15) : color.new(bearcolor, 15)) : na) // &#9556;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9559; // // &#9553; ALERTS &#9553; // // &#9562;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9565; // alertcondition(long_signal, title="Adaptive Trend Flow Long", message="Adaptive Trend Flow Long {{exchange}}:{{ticker}}") alertcondition(short_signal, title="Adaptive Trend Flow Short", message="Adaptive Trend Flow Short {{exchange}}:{{ticker}}") // &#9556;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9559; // // &#9553; CREATED BY &#9553; // // &#9562;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9565; //