'I have set up an alertcondition on SPY, once triggered, how can it send me the price of another ticker like TSLA in PineScript?
I'm using TradingView to follow the trend of the SPY index. Once its RSI fall out of range, I have set up a alertcondition to trigger the system to send me a message.
However, I can only find it send me the close price of the SPY, which is the ticker that I set up the alert on.
What I want to do is to ask the alertcondition function to send me the close price of another stock like TSLA.
I've tried to use request.security, but because it returns a series string, not a constant string, it can't be used in the message part.
Does anyone know how to use the alertcondition function to send another ticker's close price?
Solution 1:[1]
You can use the securtiy() together with the alert() function.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © vitruvius
//@version=5
indicator("My script", overlay=true)
c_sec = request.security("BINANCE:ETHUSDT", timeframe.period, close)
_s = "BTC: " + str.format("{0,number,#.##}", close) + "\nETH: " + str.format("{0,number,#.##}", c_sec)
alert(_s, alert.freq_once_per_bar_close)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | vitruvius |

