Howwise RSS
Trading Software8 min read

TradingView Export Drawings Data: What Works and What Doesn't

Short answer

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.

Key takeaways
  • 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.

ItemIn the exported CSV?Notes
Time columnYesISO time or UNIX timestamp, chosen in the export dialog
Open, High, Low, Close, VolumeYesOnly for bars currently loaded on the chart
Visible indicator plotsYesOne column per plot; hidden indicators are skipped
Long/Short Position toolNoEntry, stop, target and times are drawing properties
Other drawings (lines, rectangles, text)NoLayout objects only
Strategy Tester tradesNoUse the Strategy Tester export instead
Replay-state tradesNoNot stored as data anywhere
Warning: Plan requirements, the maximum number of exportable bars and the exact export dialog options change over time. Export chart data has needed a paid plan (not Free/Basic) and the bar limit varies by plan, so confirm both in your own account before building a workflow around them.

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.

RouteGets youEffortFidelityPlan requirementToS risk
Export chart dataOHLCV and indicator plots, no tradesLowHigh for bars, zero for drawingsPaid plan (verify)None
Strategy Tester exportList of trades, performance summary, propertiesMedium (needs Pine)High, simulated fillsAny plan that can run strategiesNone
Paper trading history exportOrders placed in the Trading Panel, including in replayMediumHigh for orders you actually placedPaper trading is available to users; verify limitsNone
Charting Library / Advanced ChartsgetAllShapes, getShapeById, getPoints in your own appHigh (separate product, developer work)High, but only for charts inside your appSeparate licenceNone
Manual loggingEntry, stop, target, times in a spreadsheetMedium per tradeDepends on disciplineAnyNone
Unofficial scraping or userscriptsWhatever the private endpoints exposeHigh and fragileVariableAnyHigh: violates ToS, breaks without notice
Warning: There is no official public TradingView API for reading a user's drawings. Reading private websocket or REST endpoints, or scripting the page DOM with an extension or userscript, violates the terms of service. It can get an account restricted, and it fails whenever the site changes.

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)
Warning: Check the levels before trusting the results: for a long the stop must be below and the target above the entry, and the reverse for a short. If a level sits on the wrong side, the exit fills on the first bar and the Strategy Tester shows a misleading trade. A trade with no stop or target stays open until the chart ends.

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:

  1. Start Bar Replay and open the Trading Panel at the bottom of the chart.
  2. Place entries, stops and targets as orders rather than drawing position tools.
  3. After the session, open the History tab of the panel and use its export option (the exact location can change between releases).
  4. Run Export chart data from the same chart so you have OHLCV for the same period.
  5. 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(...)
Warning: Set tolerance so a trade outside the exported range does not attach to the last bar. The ambiguous and nonexistent arguments mark daylight-saving edge cases as NaT instead of silently shifting them. The remaining datetime values in the Excel file are UTC, so label the columns accordingly.

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 mistakeWhy it happensFix
Expecting drawings in the CSVExport covers only series and plotsLog manually or rebuild as a strategy
Expecting replay trades in Strategy TesterPosition tool is a drawing, not an orderUse Trading Panel orders or a Pine strategy
Too few rows exportedOnly loaded bars are writtenScroll back to load history first, within plan limits
Trades offset by hoursChart timezone versus UTCLocalize then convert both sides to UTC
Exact-match join returns NaNTrade times rarely equal bar open timesUse merge_asof, direction backward
to_excel fails on datetimesExcel cannot store timezone-aware valuesApply tz_localize(None) first, or use to_csv
Strategy exits at once or neverStop or target left at 0.0Pass 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.

Related topics:tradingviewpine scriptdata exportbacktestingpandas