Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.

Fetch OHLC (Open, High, Low, Close) candle data from TradingView

Last updated on 3 days ago
K
KevinMember
Posted 3 days ago
You can fetch OHLC (Open, High, Low, Close) data from TradingView using different methods, depending on your requirements.

Method 1: Using TradingView's Charting Library API (WebSocket)
TradingView provides a WebSocket-based API to retrieve live market data, but it requires reverse engineering since they don't provide official access for free users.

Open TradingView in your browser.
Open the Developer Console (F12 > Network > WS).
Find the WebSocket connection and analyze the data structure.
Use Python with websocket-client to connect and retrieve OHLC data.
Method 2: Using TradingView unofficial API (Pine Script)
If you want historical data:

Use TradingView's Pine Script to create a custom indicator that logs OHLC values.
Export the data manually or send it to a server.
K
KevinMember
Posted 3 days ago
Method 3: Using Third-Party APIs
Some third-party APIs offer TradingView-like data:

tradingview-ta Python Library
Install the library:

bash
Copy
Edit
pip install tradingview-ta
Fetch OHLC:

python
Copy
Edit
from tradingview_ta import TA_Handler, Interval

ohlc = TA_Handler(
symbol="CRUDEOIL",
exchange="NSE",
screener="india",
interval=Interval.INTERVAL_15_MINUTES
)

print(ohlc.get_analysis().indicators)
Investing.com or Yahoo Finance APIs
If TradingView data is unavailable, you can fetch similar OHLC data using:

python
Copy
Edit
import yfinance as yf

data = yf.download("CL=F", interval="15m", period="1d")
print(data)
You can view all discussion threads in this forum.
You cannot start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You cannot download attachments in this forum.
Sign In
Not a member yet? Click here to register.
Forgot Password?
Users Online Now
Guests Online 3
Members Online 0

Total Members: 16
Newest Member: Sunny