답변완료
수식 부탁드립니다
지표식 부탁드립니다.
//@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    ', 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)
2025-05-26
252
글번호 191183
지표
답변완료
확인을 부탁 드립니다.
안녕하세요!
아래식으로 지표를 설정하고 종가선이 트랜드기준선을 돌파해서 상승일때, 하락일때 배경색이 나타나게 설정하고싶은데 하락시는 바탕색이 적용이 되는데 상승시는 배경색이 안나타납니다.
확인 좀 부탁드립니다.
감사합니다.
input : upertrendAtrPeriod(10);
input : supertrendAtrMultiplier(2.7);
var : haClose(0),haOpen(0),haHigh(0),haLow(0),haTR(0),alpha(0),haTrueRange(0);
var : haSupertrendUp(0),haSupertrendDown(0),trendingUp(Nan),trendingDown(Nan);
var : direction(0),supertrend(0),supertrendUp(False),supertrendDown(False);
if index == 0 then
{
haClose = (O+H+L+C)/4;
haOpen = open;
haHigh = MaxList( high, haOpen, haClose);
haLow = MinList( low, haOpen,haClose);
}
else
{
haClose = (O+H+L+C)/4;
haOpen = (haOpen [1] + haClose [1])/2 ;
haHigh = MaxList(High, haOpen, haClose) ;
haLow = MinList(Low, haOpen, haClose) ;
}
haTR = max(haHigh - haLow, abs(haHigh - haClose[1]), abs(haLow - haClose[1]));
alpha = 1 / upertrendAtrPeriod ;
haTrueRange = IFf(IsNan(haTrueRange[1]) == true, ma(haTR,upertrendAtrPeriod) , alpha * haTR + (1 - alpha) * IFf(isnan(haTrueRange[1])==true,0,haTrueRange[1]));
haSupertrendUp =((haHigh +haLow )/2 )-(supertrendAtrMultiplier *haTrueRange );
haSupertrendDown =((haHigh +haLow )/2 )+(supertrendAtrMultiplier *haTrueRange );
direction = 0;
trendingUp = iff(haClose[1]>trendingUp[1] , max (haSupertrendUp ,trendingUp[1]) , haSupertrendUp);
trendingDown = iff(haClose[1]<trendingDown[1] , min (haSupertrendDown ,trendingDown[1]) , haSupertrendDown);
direction = iff(haClose > trendingDown[1] , 1 , iff(haClose < trendingUp[1], -1 , IFf(IsNan(direction[1]) == true,1,direction[1])));
supertrend = iff(direction == 1 , trendingUp , trendingDown);
if direction == 1 Then
{
plot1(supertrend,"supertrendUp", Green);
NoPlot(2);
}
Else
{
plot2(supertrend,"supertrendDow", Red);
NoPlot(1);
Plot3(c, "종가");
}
2025-05-26
246
글번호 191163
지표