tmaster81
Pine Script Rookie
Pine Script Rookie
Posts: 2
Joined: December 22nd, 2021

Multiple alerts with one script

Hi Experts,

I am absolute new to pine editor, so I would like if someone with knowledge can help me with a script which I need to enable me to create multiple alerts with one script

Points Which needs to be covered. Alert should pop up when
1. 50 EMA crosses 200 EMA (both side - up or down)
2. In multiple time frame ( 1 or 3 or 5 minute)
3. For multiple stocks (Eg: banknifty, Nifty, Mindtree, etc)

I have updated the script to get the 50 & 200 EMA, but I need help in script for setting alerts and also the time frame

I would really appreciate if some one could help me with a pine script for me to work around to create this alert in trading view.

Thanks,
Tejas
Last edited by tmaster81 on Thu Dec 23, 2021 2:51 pm, edited 1 time in total.

tmaster81
Pine Script Rookie
Pine Script Rookie
Posts: 2
Joined: December 22nd, 2021

Re: Multiple alerts with one script

//@version=5
indicator(title='50-200new', overlay=true)

i_T1 = input.symbol('BANKNIFTY')
i_T2 = input.symbol('NIFTY')
i_T3 = input.symbol('MINDTREE')

f_strategy() =>
emafast = ta.ema(close, 50)
emaslow = ta.ema(close, 200)


//get user input
emalength1 = input(title='EMA 1 length', defval=50)
emalength2 = input(title='EMA 2 length', defval=200)

//get EMAs
ema1 = ta.ema(close, emalength1)
ema2 = ta.ema(close, emalength2)

//Plot EMA
plot(ema1, color=color.new(color.green, 0))
plot(ema2, color=color.new(color.black, 0))

//Send our alert if there is a golden crossover

Pro4x
Pine Script Rookie
Pine Script Rookie
Posts: 1
Joined: January 9th, 2022
Contact: TradingView Profile

Re: Multiple alerts with one script

Here's something similar that you should be able to customise.

//@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")

Return to “Request Scripts”