Jonathan Costa
Jonathan Costa

Reputation: 21

How to call the closing price of other stocks in Pine Script?

I want to include in the indicator code the closing prices of several different stocks in a comparison, but I don't know how to refer to the closing prices of these other stocks. what function would allow me to do that?

Upvotes: 2

Views: 4520

Answers (1)

Petermailpan
Petermailpan

Reputation: 115

The function you are looking for is called security. Here is the reference.

For an example: If you want to retrieve the close price of BTC/USD on biance you use the security function like

btc_close = nz(security("binance:BTCUSDT", timeframe.period, close))

The function nz replaces NaN values with zeros.

Upvotes: 5

Related Questions