List view
Overview
Overview
Price Data
Price Data
Price Data
How to Use Price Data?
🔒 Only subscribed users can use price data.
Intruduction
In Pine Script, you can directly access OHLCV data (Open, High, Low, Close, Volume) for the current chart's timeframe. If you need to obtain price data for other trading pairs or timeframes in your indicators or strategies, you'll need to create Price Data.
With Price Data, you can achieve the following functions:
- Cross-timeframe Data: Access price data from other timeframes on the current timeframe chart, such as obtaining 1-hour period data on a 15-minute chart
- Cross-pair Data: Access price data from other trading pairs on the current pair's chart, such as obtaining ETH/USDT data on a BTC/USDT chart
- Data Comparison Analysis: Implement data comparison between different trading pairs or timeframes, helping with correlation analysis or arbitrage strategy development
- Complex Indicator Calculations: Create more sophisticated technical indicators by combining data from multiple trading pairs or timeframes
- Cross-market Analysis: Obtain price data from different markets for comprehensive analysis, such as spot and futures price spread analysis
- …
Using these features lets you create better indicators by combining data in different ways. This means you can build trading strategies that use more data points and work more effectively.
Add Price Data
The Logic panel on the right contains the Price Data creation option.
Next, we need to configure the corresponding settings.
To create Price Data, you need to set the corresponding Ticker Symbol and Timeframe.
- Ticker Symbol: This represents the trading pair you want to add, such as AAPL, BINANCE:BTCUSD, etc. Make sure to use the correct format(Supports the format "Ticker" or "Exchange:Ticker”). the default is the current Ticker Symbol of the chart.
- Timeframe: Select the time interval for the price data, ranging from 1 second to 12 month. The default is the interval of the chart, which can be customized to any interval.
❓ How do I get the Ticker Symbol of the currently open chart?
You can add this script to your chart to display the complete Symbol Ticker Value on the last candle of the main chart.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Pineify //@version=6 indicator("[Pineify] Display Ticker Symbol", overlay = true, behind_chart=false) if last_bar_index == bar_index label.new(bar_index, close, syminfo.tickerid)
Of course, you can also enter the name of Ticker directly without prefixing it with Exchange. For example BTCUSD.
Binding Ticker Symbol and Timeframe to Input
If you want to be able to modify these two values in the script settings without changing the code, you can bind them to corresponding Inputs. This allows you to make adjustments at any time.
When creating Price Data, enable the "Use Input" option, And select the corresponding Input.
Once created, you'll see these relationships clearly displayed in the names listed on the left pane.
In the TradingView script settings, you can see these two Input parameters corresponding to Ticker Symbol and Timeframe. You can modify their values directly here without changing the code.
Use Price Data
After adding Price Data, you can use it in Conditions and Plots.
Use in Conditions
In conditions, you can use Price Data as an operand and access its historical values.
For example, we can create a condition where the chart's close price crosses up the close price of this Price Data.
Historical values can also be used here. Note that for close price, one bar's historical value corresponds to the chart's timeframe, while for "Symbol, TF, Close", one bar's historical value corresponds to the Price Data's timeframe.
Use in Plots
For Price Data, you can visualize it on the chart using Plots.
For example, you can use Price Data to plot higher timeframe Close prices as lines on your chart.
Simply create a Price Data first, set the Timeframe to your desired interval(Here we take 4h as an example), then add a Plot. For the Plot's Data field, select the Close value from your Price Data.
Set the chart's interval to 30min and add this indicator. You'll then be able to see both price trends displayed on the same chart.
With Price Data, you can add unlimited price data to your chart, regardless of Symbol or timeframe.