커뮤니티

부탁드립니다.

프로필 이미지
다올
2023-07-19 10:25:05
1351
글번호 170748
답변완료
변환 부탁 드립니다.(트레이딩뷰 RVI) indicator(title="Relative Volatility Index", shorttitle="RVI", format=format.price, precision=2, timeframe="", timeframe_gaps=true) length = input.int(10, minval=1) offset = input.int(0, "Offset", minval = -500, maxval = 500) maTypeInput = input.string("SMA", title="MA Type", options=["SMA", "Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="MA Settings") maLengthInput = input.int(14, title="MA Length", group="MA Settings") bbMultInput = input.float(2.0, minval=0.001, maxval=50, title="BB StdDev", group="MA Settings") src = close len = 14 stddev = ta.stdev(src, length) upper = ta.ema(ta.change(src) <= 0 ? 0 : stddev, len) lower = ta.ema(ta.change(src) > 0 ? 0 : stddev, len) rvi = upper / (upper + lower) * 100 ma(source, length, type) => switch type "SMA" => [ta.sma(source, length), na, na] "Bollinger Bands" => [middleValue, highValue, lowValue] = ta.bb(source, length, bbMultInput) [middleValue, highValue, lowValue] "EMA" => [ta.ema(source, length), na, na] "SMMA (RMA)" => [ta.rma(source, length), na, na] "WMA" => [ta.wma(source, length), na, na] "VWMA" => [ta.vwma(source, length), na, na] [rviMA,highValue,lowValue] = ma(rvi, maLengthInput, maTypeInput) h0 = hline(80, "Upper Band", color=#787B86) hline(50, "Middle Band", color=color.new(#787B86, 50)) h1 = hline(20, "Lower Band", color=#787B86) fill(h0, h1, color=color.rgb(126, 87, 194, 90), title="Background") plot(rvi, title="RVI", color=#7E57C2, offset = offset) plot(rviMA, "RVI-based MA", color=color.yellow, offset = offset) bbUpper = plot(highValue, title="Upper Bollinger Band", color=color.green) bbLower = plot(lowValue, title="Lower Bollinger Band", color=color.green) fill(bbUpper, bbLower, color = color.new(color.green, 90), title="Bollinger Bands Background Fill")
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2023-07-20 10:03:02

안녕하세요 예스스탁입니다. input : length(10),offset(0); input : maTypeInput(1);//1:SMA, 2: Bollinger Bands, 3:EMA, 4:SMMA(RMA), 5:WMA, 6:VWMA; input : maLengthInput(14); input : bbMultInput(2.0); input : src(close),len(14); var : stddev(0),upper(0),lower(0),rvi(0); var : rviMA(0),highValue(0),lowValue(0); var : alpha(0),rmav(0); stddev = std(src, length); upper = ema(iff(src <= src[1], 0 ,stddev), len); lower = ema(iff(src > src[1], 0 ,stddev), len); rvi = upper / (upper + lower) * 100; if maTypeInput == 1 Then { rviMA = ma(rvi,maLengthInput); highValue = Nan; lowValue = nan; } if maTypeInput == 2 Then { rviMA = ma(rvi,maLengthInput); var1 = std(rvi,maLengthInput); highValue = rviMA+var1+bbMultInput; lowValue = rviMA+var1+bbMultInput; } if maTypeInput == 3 Then { rviMA = ema(rvi,maLengthInput); highValue = Nan; lowValue = nan; } if maTypeInput == 4 Then { alpha = 1/maLengthInput; rmav = 0.0; rmav = iff(IsNaN(rmav[1]) == true, ma(rvi, maLengthInput) , alpha * rvi + (1 - alpha) * IFf(IsNan(rmav[1])==true,0,rmav[1])); rviMA = rmav; highValue = Nan; lowValue = nan; } if maTypeInput == 5 Then { rviMA = wma(rvi,maLengthInput); highValue = Nan; lowValue = nan; } if maTypeInput == 6 Then { rviMA = ma(rvi * volume, maLengthInput) / ma(volume, maLengthInput); highValue = Nan; lowValue = nan; } PlotBaseLine1(80, "Upper Band"); PlotBaseLine2(50, "Middle Band"); PlotBaseLine3(20, "Lower Band"); plot1(rvi, "RVI"); plot2(rviMA, "RVI-based MA"); plot3(highValue, "Upper Bollinger Band"); plot4(lowValue, "Lower Bollinger Band"); 즐거운 하루되세요 > 다올 님이 쓴 글입니다. > 제목 : 부탁드립니다. > 변환 부탁 드립니다.(트레이딩뷰 RVI) indicator(title="Relative Volatility Index", shorttitle="RVI", format=format.price, precision=2, timeframe="", timeframe_gaps=true) length = input.int(10, minval=1) offset = input.int(0, "Offset", minval = -500, maxval = 500) maTypeInput = input.string("SMA", title="MA Type", options=["SMA", "Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="MA Settings") maLengthInput = input.int(14, title="MA Length", group="MA Settings") bbMultInput = input.float(2.0, minval=0.001, maxval=50, title="BB StdDev", group="MA Settings") src = close len = 14 stddev = ta.stdev(src, length) upper = ta.ema(ta.change(src) <= 0 ? 0 : stddev, len) lower = ta.ema(ta.change(src) > 0 ? 0 : stddev, len) rvi = upper / (upper + lower) * 100 ma(source, length, type) => switch type "SMA" => [ta.sma(source, length), na, na] "Bollinger Bands" => [middleValue, highValue, lowValue] = ta.bb(source, length, bbMultInput) [middleValue, highValue, lowValue] "EMA" => [ta.ema(source, length), na, na] "SMMA (RMA)" => [ta.rma(source, length), na, na] "WMA" => [ta.wma(source, length), na, na] "VWMA" => [ta.vwma(source, length), na, na] [rviMA,highValue,lowValue] = ma(rvi, maLengthInput, maTypeInput) h0 = hline(80, "Upper Band", color=#787B86) hline(50, "Middle Band", color=color.new(#787B86, 50)) h1 = hline(20, "Lower Band", color=#787B86) fill(h0, h1, color=color.rgb(126, 87, 194, 90), title="Background") plot(rvi, title="RVI", color=#7E57C2, offset = offset) plot(rviMA, "RVI-based MA", color=color.yellow, offset = offset) bbUpper = plot(highValue, title="Upper Bollinger Band", color=color.green) bbLower = plot(lowValue, title="Lower Bollinger Band", color=color.green) fill(bbUpper, bbLower, color = color.new(color.green, 90), title="Bollinger Bands Background Fill")