i want to combine rsi indicator and ema (candles chart) in one script. that rsi is under chart, and ema is plottet in the chart. ema not in/from rsi values.
i have for rsi this
<code>// @version=5
indicator(title="rsi and ema", shorttitle="rsi and ema", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
//
rsiLengthInput = input.int(14, minval=1, title="Length")
rsiSourceInput = input.source(close, "Source")
up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
rsiPlot = plot(rsi, "RSI", color=#AB47BC)
band1 = hline(80, "upper band 1", color=color.new(#F23645, 0))
band2 = hline(20, "lower band 2", color=color.new(#2962FF, 0))
</code>
<code>// @version=5
indicator(title="rsi and ema", shorttitle="rsi and ema", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
//
rsiLengthInput = input.int(14, minval=1, title="Length")
rsiSourceInput = input.source(close, "Source")
up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
rsiPlot = plot(rsi, "RSI", color=#AB47BC)
band1 = hline(80, "upper band 1", color=color.new(#F23645, 0))
band2 = hline(20, "lower band 2", color=color.new(#2962FF, 0))
</code>
// @version=5
indicator(title="rsi and ema", shorttitle="rsi and ema", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
//
rsiLengthInput = input.int(14, minval=1, title="Length")
rsiSourceInput = input.source(close, "Source")
up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
rsiPlot = plot(rsi, "RSI", color=#AB47BC)
band1 = hline(80, "upper band 1", color=color.new(#F23645, 0))
band2 = hline(20, "lower band 2", color=color.new(#2962FF, 0))
and for ema this
<code>study(title="EMA 50/200", overlay=true)
short = ema(close, 50)
longer = ema(close, 100)
plot(short, color = orange)
plot(longer, color = aqua)
</code>
<code>study(title="EMA 50/200", overlay=true)
short = ema(close, 50)
longer = ema(close, 100)
plot(short, color = orange)
plot(longer, color = aqua)
</code>
study(title="EMA 50/200", overlay=true)
short = ema(close, 50)
longer = ema(close, 100)
plot(short, color = orange)
plot(longer, color = aqua)
if i copy/combine ema code under rsi code it dont work. how do i fix this? i dont want to use two separate codes / two separate indicators. want this in one.
thx for help