커뮤니티

수식 부탁드립니다

프로필 이미지
사노소이
2025-05-26 16:16:37
253
글번호 191183
답변완료
지표식 부탁드립니다. //@version=5 indicator("Ultimate RSI", "Ultimate RSI", overlay = false) //Settings length = input.int(14, minval = 2) smoType1 = input.string('RMA', 'Method', options = ['EMA', 'SMA', 'RMA', 'TMA']) src = input(close, 'Source') arsiCss = input(color.silver, 'Color', inline = 'rsicss') autoCss = input(true, 'Auto', inline = 'rsicss') //Signal Line smooth = input.int(14, minval = 1, group = 'Signal Line') smoType2 = input.string('EMA', 'Method', options = ['EMA', 'SMA', 'RMA', 'TMA'], group = 'Signal Line') signalCss = input(#ff5d00, 'Color', group = 'Signal Line') //OB/OS Style obValue = input.float(80, 'Overbought', inline = 'ob', group = 'OB/OS Style') obCss = input(#089981, '', inline = 'ob', group = 'OB/OS Style') obAreaCss = input(color.new(#089981, 80), '', inline = 'ob', group = 'OB/OS Style') osValue = input.float(20, 'Oversold&#8196;&#8196;&#8196;&#8196;', inline = 'os', group = 'OB/OS Style') osCss = input(#f23645, '', inline = 'os', group = 'OB/OS Style') osAreaCss = input(color.new(#f23645, 80), '', inline = 'os', group = 'OB/OS Style') //Functions ma(x, len, maType)=> switch maType 'EMA' => ta.ema(x, len) 'SMA' => ta.sma(x, len) 'RMA' => ta.rma(x, len) 'TMA' => ta.sma(ta.sma(x, len), len) //Augmented RSI upper = ta.highest(src, length) lower = ta.lowest(src, length) r = upper - lower d = src - src[1] diff = upper > upper[1] ? r : lower < lower[1] ? -r : d num = ma(diff, length, smoType1) den = ma(math.abs(diff), length, smoType1) arsi = num / den * 50 + 50 signal = ma(arsi, smooth, smoType2) //Plots plot_rsi = plot(arsi, 'Ultimate RSI' , arsi > obValue ? obCss : arsi < osValue ? osCss : autoCss ? chart.fg_color : arsiCss) plot(signal, 'Signal Line', signalCss) //Levels plot_up = plot(obValue, color = na, editable = false) plot_avg = plot(50, color = na, editable = false) plot_dn = plot(osValue, color = na, editable = false) //OB-OS fill(plot_rsi, plot_up, arsi > obValue ? obAreaCss : na) fill(plot_dn, plot_rsi, arsi < osValue ? osAreaCss : na) //Gradient fill(plot_rsi, plot_avg, obValue, 50, obAreaCss, color.new(chart.bg_color, 100)) fill(plot_avg, plot_rsi, 50, osValue, color.new(chart.bg_color, 100), osAreaCss) hline(obValue, 'Overbought') hline(50, 'Midline') hline(osValue, 'Oversold') //시그널 교차 감지 및 화살표 표시 추가 crossUp = ta.crossover(arsi, signal) crossDn = ta.crossunder(arsi, signal) plotshape(crossUp, title="RSI Cross Up", location=location.bottom, style=shape.triangleup, color=#00ff00, size=size.tiny) plotshape(crossDn, title="RSI Cross Down", location=location.top, style=shape.triangledown, color=#ff0000, size=size.tiny)
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2025-05-27 09:47:54

안녕하세요 예스스탁입니다. input : length(14); input : smoType1(3); #1:EMA, 2:SMA, 3:RMA, 4TMA input : arsiCss(silver); input : autoCss(true); //Signal Line input : smooth(14); input : smoType2(1);#1EMA, 2SMA, 3RMA, 4TMA input : signalCss(Orange); //OB/OS Style input : obValue(80); input : obCss(Green); input : obAreaCss(LightGreen); input : osValue(20); input : osCss(Red); input : osAreaCss(LightRed); var : src(0); var : upper(0),lower(0),r(0); var : d(0),diff(0),alpha(0),num(0),den(0),arsi(0),signal(0),a(0),tx(0); src = close; upper = highest(src, length); lower = lowest(src, length); r = upper - lower; d = src - src[1]; diff = iff(upper > upper[1] , r , iff(lower < lower[1] , -r , d)); if smoType1 == 1 Then { num = ema(diff, length); den = ema(abs(diff), length); } if smoType1 == 2 Then { num = ma(diff, length); den = ma(abs(diff), length); } if smoType1 == 3 Then { alpha = 1/length; num = iff(isnan(num[1]) == true, ma(diff, length) , alpha * diff + (1 - alpha) * iff(isnan(num[1])==true,0,num[1])); den = iff(isnan(den[1]) == true, ma(abs(diff), length) , alpha * abs(diff) + (1 - alpha) * iff(isnan(den[1])==true,0,den[1])); } if smoType1 == 4 Then { num = ma(ma(diff, length),length); den = ma(ma(abs(diff), length), length); } arsi = num / den * 50 + 50; if smoType2 == 1 Then { signal = ema(arsi, smooth); } if smoType2 == 2 Then { signal = ma(arsi, smooth); } if smoType2 == 3 Then { a = 1/smooth; signal = iff(isnan(signal[1]) == true, ma(arsi, length) , a * arsi + (1 - a) * iff(isnan(signal[1])==true,0,signal[1])); } if smoType2 == 4 Then { signal = ma(arsi, smooth); } plot1(arsi, "Ultimate RSI",IFf(arsi > obValue , obCss , IFF(arsi < osValue , osCss ,IFf( autoCss , Black , arsiCss)))); plot2(signal, "Signal Line", signalCss); PlotBaseLine1(obValue, "Overbought"); PlotBaseLine2(50, "Midline"); PlotBaseLine3(osValue, "Oversold"); if CrossUp(arsi, signal) Then { tx = Text_New_Self(sDate,sTime,osValue,"▲"); Text_SetStyle(tx,2,0); Text_SetColor(tx,Lime); } if CrossDown(arsi, signal) Then { tx = Text_New_Self(sDate,sTime,obValue,"▼"); Text_SetStyle(tx,2,1); Text_SetColor(tx,Red); } 즐거운 하루되세요 > 사노소이 님이 쓴 글입니다. > 제목 : 수식 부탁드립니다 > 지표식 부탁드립니다. //@version=5 indicator("Ultimate RSI", "Ultimate RSI", overlay = false) //Settings length = input.int(14, minval = 2) smoType1 = input.string('RMA', 'Method', options = ['EMA', 'SMA', 'RMA', 'TMA']) src = input(close, 'Source') arsiCss = input(color.silver, 'Color', inline = 'rsicss') autoCss = input(true, 'Auto', inline = 'rsicss') //Signal Line smooth = input.int(14, minval = 1, group = 'Signal Line') smoType2 = input.string('EMA', 'Method', options = ['EMA', 'SMA', 'RMA', 'TMA'], group = 'Signal Line') signalCss = input(#ff5d00, 'Color', group = 'Signal Line') //OB/OS Style obValue = input.float(80, 'Overbought', inline = 'ob', group = 'OB/OS Style') obCss = input(#089981, '', inline = 'ob', group = 'OB/OS Style') obAreaCss = input(color.new(#089981, 80), '', inline = 'ob', group = 'OB/OS Style') osValue = input.float(20, 'Oversold&#8196;&#8196;&#8196;&#8196;', inline = 'os', group = 'OB/OS Style') osCss = input(#f23645, '', inline = 'os', group = 'OB/OS Style') osAreaCss = input(color.new(#f23645, 80), '', inline = 'os', group = 'OB/OS Style') //Functions ma(x, len, maType)=> switch maType 'EMA' => ta.ema(x, len) 'SMA' => ta.sma(x, len) 'RMA' => ta.rma(x, len) 'TMA' => ta.sma(ta.sma(x, len), len) //Augmented RSI upper = ta.highest(src, length) lower = ta.lowest(src, length) r = upper - lower d = src - src[1] diff = upper > upper[1] ? r : lower < lower[1] ? -r : d num = ma(diff, length, smoType1) den = ma(math.abs(diff), length, smoType1) arsi = num / den * 50 + 50 signal = ma(arsi, smooth, smoType2) //Plots plot_rsi = plot(arsi, 'Ultimate RSI' , arsi > obValue ? obCss : arsi < osValue ? osCss : autoCss ? chart.fg_color : arsiCss) plot(signal, 'Signal Line', signalCss) //Levels plot_up = plot(obValue, color = na, editable = false) plot_avg = plot(50, color = na, editable = false) plot_dn = plot(osValue, color = na, editable = false) //OB-OS fill(plot_rsi, plot_up, arsi > obValue ? obAreaCss : na) fill(plot_dn, plot_rsi, arsi < osValue ? osAreaCss : na) //Gradient fill(plot_rsi, plot_avg, obValue, 50, obAreaCss, color.new(chart.bg_color, 100)) fill(plot_avg, plot_rsi, 50, osValue, color.new(chart.bg_color, 100), osAreaCss) hline(obValue, 'Overbought') hline(50, 'Midline') hline(osValue, 'Oversold') //시그널 교차 감지 및 화살표 표시 추가 crossUp = ta.crossover(arsi, signal) crossDn = ta.crossunder(arsi, signal) plotshape(crossUp, title="RSI Cross Up", location=location.bottom, style=shape.triangleup, color=#00ff00, size=size.tiny) plotshape(crossDn, title="RSI Cross Down", location=location.top, style=shape.triangledown, color=#ff0000, size=size.tiny)