is there a way to make this trigger on multiple tickers
In this example the values of one RSI indicator are checked, but on five symbols at once. The script alert will be triggered if RSI crosses a specified level for any of the symbols, and the message will contain the symbol and the indicator value at the moment of crossing.
In this example the values of one RSI indicator are checked, but on five symbols at once. The script alert will be triggered if RSI crosses a specified level for any of the symbols, and the message will contain the symbol and the indicator value at the moment of crossing.
//@version=4
study("alert() with multiple symbols")
f_triggerRsi(_ticker)=>
_r = rsi(close, 7)
_x = crossover(_r,70)
_y = crossunder(_r,30)
_rt = barstate.isrealtime
[_rsi, _co, _cu, _rt_bar] = security(_ticker, timeframe.period, [_r, _x, _y, _rt])
_msg = _ticker + ", " + timeframe.period + ": "
if _co and _rt_bar
_msg := _msg + "RSI (" + tostring(_rsi) + ") crossing up 70 level"
alert(_msg, alert.freq_once_per_bar_close)
else if _cu and _rt_bar
_msg := _msg + "RSI (" + tostring(_rsi) + ") crossing down 30 level"
alert(_msg, alert.freq_once_per_bar_close)
plot(rsi(close, 7), "RSI", color=#8E1599)
band1 = hline(70, "Upper Band", color=#C0C0C0)
band0 = hline(30, "Lower Band", color=#C0C0C0)
fill(band1, band0, color=color.new(#9915FF,90), title="Background")
f_triggerRsi(syminfo.tickerid)
f_triggerRsi("NASDAQ:MSFT")
f_triggerRsi("FX:EURUSD")
f_triggerRsi("NASDAQ:TSLA")
f_triggerRsi("NASDAQ:PYPL")