TradingView Export Drawings Data: What Works and What Doesn't
No: TradingView export drawings data is not possible through Export chart data, which writes only OHLCV bars and visible indicator plots. Long/Short Position tools must be logged by hand, rebuilt as a Pine strategy, or replaced by Trading Panel orders.
- Export chart data writes a time column, OHLCV and one column per visible indicator plot; Long/Short Position drawings are never in the file.
- The Long/Short Position tool is a drawing, so it never appears in Strategy Tester or in any order history.
- A Pine strategy with input.time entries turns logged trades into a Strategy Tester List of trades that exports to CSV or XLSX.
- Orders placed through the Trading Panel (paper trading) have an exportable history, which drawings do not.
- Join manual trades to exported bars with pandas merge_asof after converting both sides to UTC, and strip the timezone before writing to Excel.
Does Export chart data include drawings?
No. The Export chart data command writes the price series and the plotted values of indicators on the chart. Trend lines, rectangles, text and the Long/Short Position tools are stored as chart layout objects, and the exporter does not read them.
The file is built from the data the chart has loaded, so what you get depends on what the chart holds at that moment. The table below shows the usual contents.
| Item | In the exported CSV? | Notes |
|---|---|---|
| Time column | Yes | ISO time or UNIX timestamp, chosen in the export dialog |
| Open, High, Low, Close, Volume | Yes | Only for bars currently loaded on the chart |
| Visible indicator plots | Yes | One column per plot; hidden indicators are skipped |
| Long/Short Position tool | No | Entry, stop, target and times are drawing properties |
| Other drawings (lines, rectangles, text) | No | Layout objects only |
| Strategy Tester trades | No | Use the Strategy Tester export instead |
| Replay-state trades | No | Not stored as data anywhere |
Why are replay trades and position tools not stored as data?
The Long/Short Position tool is a visual calculator. It holds a few anchor points (entry, stop, target) and draws a risk/reward box. It is not an order, so no engine ever fills it and no trade record exists.
Strategy Tester only lists trades that a Pine strategy script generates. Because it never sees hand-drawn boxes, a replay session full of position tools shows an empty Strategy Tester.
Bar Replay adds a second limit. The export contains the bars loaded in the chart, and in replay the chart shows data only up to the replay cursor. The replay position itself is not exported, and the session state is not saved as trade data.
Layouts and drawings live in TradingView's cloud. You can save a layout (Ctrl+S), copy it or make a snapshot image, but you cannot export it as a file. A snapshot is a picture, so it is no use for analysis.
Which route should I use? A decision table
Each route trades effort against fidelity. Ratings are general; verify plan requirements yourself because they change.
| Route | Gets you | Effort | Fidelity | Plan requirement | ToS risk |
|---|---|---|---|---|---|
| Export chart data | OHLCV and indicator plots, no trades | Low | High for bars, zero for drawings | Paid plan (verify) | None |
| Strategy Tester export | List of trades, performance summary, properties | Medium (needs Pine) | High, simulated fills | Any plan that can run strategies | None |
| Paper trading history export | Orders placed in the Trading Panel, including in replay | Medium | High for orders you actually placed | Paper trading is available to users; verify limits | None |
| Charting Library / Advanced Charts | getAllShapes, getShapeById, getPoints in your own app | High (separate product, developer work) | High, but only for charts inside your app | Separate licence | None |
| Manual logging | Entry, stop, target, times in a spreadsheet | Medium per trade | Depends on discipline | Any | None |
| Unofficial scraping or userscripts | Whatever the private endpoints expose | High and fragile | Variable | Any | High: violates ToS, breaks without notice |
How do I turn Long/Short Position tool data into Strategy Tester trades?
Pine cannot read hand-drawn objects, but it can read inputs. With confirm=true, input.time and input.price let you click the chart to pick a time or price when the script is added. A strategy can then place entries at those times, and Strategy Tester will list them.
The template below handles one trade. Copy the position tool's values into the inputs, then add more input groups or duplicate blocks for more trades.
Stop and target default to 0.0, which means "not set". The script converts 0.0 to na before calling strategy.exit, because a literal price of 0 is not a valid level. On a long, a stop of 0 would never trigger; on a short, a stop or limit of 0 would be hit or filled immediately and distort every result.
Fills follow strategy rules. A market entry created on the bar where time crosses entryTime fills at the next bar's open, not at your drawn entry price. That is expected, and it means results are a simulation of your plan, not a record of your drawing.
//@version=6
strategy("Logged trade 1", overlay=true, pyramiding=0, initial_capital=10000, default_qty_type=strategy.fixed, default_qty_value=1)
direction = input.string("Long", "Direction", options=["Long", "Short"])
entryTime = input.time(timestamp("2025-01-06T14:30:00+0000"), "Entry time", confirm=true)
// 0.0 means "not set". Enter real prices from the position tool.
stopPx = input.price(0.0, "Stop price (0 = none)", confirm=true)
targetPx = input.price(0.0, "Target price (0 = none)", confirm=true)
// Never pass 0.0 to strategy.exit: use na so the level is ignored
stopArg = stopPx > 0 ? stopPx : na
targetArg = targetPx > 0 ? targetPx : na
var bool entered = false
if not entered and time >= entryTime
entered := true
strategy.entry("T1", direction == "Long" ? strategy.long : strategy.short)
if entered and (not na(stopArg) or not na(targetArg))
strategy.exit("T1 exit", from_entry="T1", stop=stopArg, limit=targetArg)How do I export replay trades to CSV?
Use the Trading Panel instead of drawings. In Bar Replay, the Replay Trading feature lets you place orders against the replayed data. Those orders and closed positions appear in the account history, which can be exported, unlike drawings.
Steps for a repeatable logging session:
- Start Bar Replay and open the Trading Panel at the bottom of the chart.
- Place entries, stops and targets as orders rather than drawing position tools.
- After the session, open the History tab of the panel and use its export option (the exact location can change between releases).
- Run Export chart data from the same chart so you have OHLCV for the same period.
- Merge the two files in pandas, as shown in the next section.
How do I join logged trades with the exported OHLCV CSV?
If you logged trades by hand, read the position tool's values by double-clicking it and opening the Coordinates tab. It shows entry, stop and target prices plus the time or bar index of its anchor points. Log those in a spreadsheet with columns like entry_time, side, entry, stop, target, exit_time.
Timestamps are where merges break. Exported ISO times may be in UTC or your chart timezone depending on the dialog option, while your manual times are usually in chart timezone. Make both timezone-aware and convert to UTC before joining. Use merge_asof with direction="backward" so each trade attaches to the bar that was open at that time, instead of requiring an exact match that rarely exists.
Excel cannot store timezone-aware datetimes, and to_excel raises an error if it receives them. The code therefore removes the timezone from the two UTC columns just before writing the file.
import pandas as pd
bars = pd.read_csv("chart_export.csv")
# UNIX export: unit="s". ISO export: drop unit.
bars["time"] = pd.to_datetime(bars["time"], unit="s", utc=True)
bars = bars.sort_values("time")
trades = pd.read_csv("my_trades.csv")
# manual times were written in the chart timezone
trades["entry_time"] = (
pd.to_datetime(trades["entry_time"])
.dt.tz_localize("America/New_York", ambiguous="NaT", nonexistent="NaT")
.dt.tz_convert("UTC")
)
trades = trades.sort_values("entry_time")
merged = pd.merge_asof(
trades, bars,
left_on="entry_time", right_on="time",
direction="backward",
tolerance=pd.Timedelta("1D"),
)
merged["risk"] = (merged["entry"] - merged["stop"]).abs()
merged["reward"] = (merged["target"] - merged["entry"]).abs()
merged["rr"] = merged["reward"] / merged["risk"]
# Excel does not support timezone-aware datetimes: drop the tz (values stay in UTC)
merged[["entry_time", "time"]] = merged[["entry_time", "time"]].apply(
lambda s: s.dt.tz_localize(None)
)
merged.to_excel("trades_with_bars.xlsx", index=False) # or merged.to_csv(...)Can I read drawings through an API, or should I scrape them?
Not from tradingview.com. The Charting Library (Advanced Charts) is a separate product for embedding charts in your own application. There you can call getAllShapes(), getShapeById() and getPoints() on drawings, and persist chart content using save_load_adapter. It does not connect to a user's charts on tradingview.com.
Unofficial routes exist, such as reading private websocket or REST calls, or a userscript that reads the DOM. They break without notice, may expose session credentials, and violate the terms. Treat them as unsuitable for anything you depend on.
A Pine-side alternative for forward use is alerts. A script can fire alert() with a JSON message (entry, stop, target, bar time) to a webhook you control, giving a durable log of what the script computed. It still cannot see manual drawings.
| Common mistake | Why it happens | Fix |
|---|---|---|
| Expecting drawings in the CSV | Export covers only series and plots | Log manually or rebuild as a strategy |
| Expecting replay trades in Strategy Tester | Position tool is a drawing, not an order | Use Trading Panel orders or a Pine strategy |
| Too few rows exported | Only loaded bars are written | Scroll back to load history first, within plan limits |
| Trades offset by hours | Chart timezone versus UTC | Localize then convert both sides to UTC |
| Exact-match join returns NaN | Trade times rarely equal bar open times | Use merge_asof, direction backward |
| to_excel fails on datetimes | Excel cannot store timezone-aware values | Apply tz_localize(None) first, or use to_csv |
| Strategy exits at once or never | Stop or target left at 0.0 | Pass na for unset levels and check long/short sides |
Common questions
Does TradingView export chart data include drawings?
No. The export contains the time column, OHLCV and the plotted values of visible indicators. Drawings such as the Long/Short Position tool, trend lines and text are not written to the file.
Can I save TradingView drawings to Excel?
Not directly, because layouts are stored in the cloud and cannot be exported as a file. The practical options are to read each tool's Coordinates tab and type the values into a spreadsheet, or to rebuild trades as a Pine strategy and export the List of trades.
Is Export chart data available on a free plan?
It has been restricted to paid plans, and the maximum number of exported bars also depends on the plan. Plan rules change, so check the export option inside your own account before relying on it.
Why does my exported CSV stop earlier than the chart's visible history?
The export includes only bars loaded on the chart, so scrolling back loads more before exporting. In Bar Replay, the data stops at the replay point. Intraday history is also capped by plan limits.
Can a Pine script read the drawings I made by hand?
No. Pine cannot access manually drawn objects. A script can only draw its own lines and boxes, or take your values through input.time and input.price so you re-enter the trade as parameters.