Skip to content

Pine Script Export Guide

Export Algo Trade Analytics Data to TradingView Pine Script

Section titled “Export Algo Trade Analytics Data to TradingView Pine Script”

Close the loop between TradingView strategy development and real execution analysis. Export your Algo Trade Analytics trade data back to TradingView as Pine Script indicators to visualize exactly where your strategy succeeded or failed.

The Pine Script export feature allows you to:

  1. Import signals from TradingView (CSV or webhook)
  2. Analyze execution in Algo Trade Analytics dashboard
  3. Export results back to Pine Script indicators
  4. Visualize performance directly on TradingView charts

This creates a complete feedback loop for strategy optimization.

  1. Navigate to the trading dashboard
  2. Click “Trading-View” in the sidebar menu
  3. Select the data you want to export
  4. Configure export settings
  5. Generate Pine Script code

The export generates a Pine Script v5 indicator (not a strategy) that plots:

  • Entry markers - Buy/sell signal points
  • Exit markers - Position close points
  • Execution prices - Actual fill prices vs signal prices
  • Performance metrics - Profit/loss zones
  • Trade statistics - Win/loss ratios, drawdowns

Note: The generated script is an indicator template. You cannot edit the template itself, but you can freely modify the exported Pine Script code to customize visualization.

Choose what to export:

  • Date Range: Select specific time period
  • Symbols: Export single symbol or multiple
  • Trade Types: All trades, profitable only, or losses only
  • Strategy Filter: Specific strategy or all strategies

Configure what appears on chart:

  • Entry/Exit Markers: Show trade entry and exit points
  • Price Lines: Draw horizontal lines at execution prices
  • Performance Zones: Color background for profit/loss periods
  • Statistics Table: Display performance metrics on chart
  • Trade Labels: Show trade details on hover

Visual settings:

  • Shape: Triangle, circle, diamond, arrow
  • Size: Small, medium, large
  • Colors: Custom colors for buy/sell signals
  • Labels: Show price, time, or custom text
//@version=5
indicator("Algo Trade Analytics Export - [Strategy Name]", overlay=true)
// ========================
// Algo Trade Analytics Export Data
// Generated: [Export Date]
// Strategy: [Strategy Name]
// Period: [Date Range]
// ========================
// Trade execution data (auto-generated)
var trade_entries = array.new<float>()
var trade_exits = array.new<float>()
var entry_times = array.new<int>()
var exit_times = array.new<int>()
// Initialize trade data
if barstate.isfirst
// Entry signals
array.push(trade_entries, 150.25) // AAPL buy at 150.25
array.push(entry_times, 1640995200) // Timestamp
array.push(trade_entries, 148.75) // AAPL sell at 148.75
array.push(entry_times, 1641081600) // Timestamp
// Exit signals
array.push(trade_exits, 152.50) // AAPL exit at 152.50
array.push(exit_times, 1641168000) // Timestamp
// Plot entry markers
plotshape(
series = time == array.get(entry_times, 0) ? array.get(trade_entries, 0) : na,
style = shape.triangleup,
location = location.belowbar,
color = color.green,
size = size.small,
title = "Buy Signal"
)
// Plot exit markers
plotshape(
series = time == array.get(exit_times, 0) ? array.get(trade_exits, 0) : na,
style = shape.triangledown,
location = location.abovebar,
color = color.red,
size = size.small,
title = "Sell Signal"
)
// Performance statistics table
var table performance_table = table.new(position.top_right, 2, 5, bgcolor=color.white, border_width=1)
if barstate.islast
table.cell(performance_table, 0, 0, "Total Trades", text_color=color.black)
table.cell(performance_table, 1, 0, "15", text_color=color.black)
table.cell(performance_table, 0, 1, "Win Rate", text_color=color.black)
table.cell(performance_table, 1, 1, "67%", text_color=color.green)
table.cell(performance_table, 0, 2, "Avg Profit", text_color=color.black)
table.cell(performance_table, 1, 2, "$245", text_color=color.green)
table.cell(performance_table, 0, 3, "Max Drawdown", text_color=color.black)
table.cell(performance_table, 1, 3, "-$850", text_color=color.red)
//@version=5
indicator("Algo Trade Analytics Advanced Export", overlay=true)
// Signal vs Execution Comparison
signal_price = 150.00 // Original TradingView signal price
execution_price = 150.25 // Actual fill price from broker
slippage = execution_price - signal_price
// Plot signal price (dotted line)
plot(signal_price, color=color.blue, style=plot.style_circles, linewidth=1, title="Signal Price")
// Plot execution price (solid line)
plot(execution_price, color=color.orange, style=plot.style_line, linewidth=2, title="Execution Price")
// Highlight slippage area
bgcolor(slippage > 0 ? color.new(color.red, 90) : color.new(color.green, 90), title="Slippage Zone")
// Trade performance zones
in_position = false // Logic to determine if in position
position_pnl = 0.0 // Current position P&L
// Color background based on performance
bgcolor(
in_position ?
(position_pnl > 0 ? color.new(color.green, 95) : color.new(color.red, 95)) :
na,
title="Position P&L"
)
  1. Complete export in Algo Trade Analytics
  2. Copy the generated Pine Script code
  3. Save to a text file for backup
  1. Open TradingView chart for your symbol
  2. Click “Pine Editor” at the bottom
  3. Paste the exported code
  4. Click “Add to Chart”

Check that markers appear correctly:

  • ✅ Entry markers align with your signal times
  • ✅ Exit markers match your trade closes
  • ✅ Prices match your execution records
  • ✅ Performance statistics are accurate

Modify the script to suit your needs:

// Change marker colors
plotshape(
// ... existing code ...
color = color.blue, // Change from green to blue
// ... rest of code ...
)
// Add custom labels
plotshape(
// ... existing code ...
text = "Entry: $" + str.tostring(close),
// ... rest of code ...
)
// Modify table position
var table performance_table = table.new(
position.bottom_left, // Change from top_right
// ... rest of configuration ...
)

Purpose: Compare TradingView signals with actual execution

What it shows:

  • Original signal prices vs actual fill prices
  • Timing differences between signal and execution
  • Slippage analysis
  • Signal accuracy metrics

Best for: Strategy optimization and execution analysis

Purpose: Visualize overall strategy performance

What it shows:

  • Profit/loss zones on chart
  • Drawdown periods
  • Win/loss streaks
  • Performance statistics table

Best for: Strategy evaluation and presentation

Purpose: Analyze trade execution efficiency

What it shows:

  • Fill quality vs market conditions
  • Execution timing analysis
  • Order type effectiveness
  • Broker performance comparison

Best for: Execution platform evaluation

Purpose: Evaluate risk management effectiveness

What it shows:

  • Stop loss execution points
  • Take profit achievements
  • Risk/reward ratios
  • Position sizing effectiveness

Best for: Risk management optimization

// Calculate win rate
total_trades = 25
winning_trades = 17
win_rate = winning_trades / total_trades * 100
// Display on chart
var label win_rate_label = na
if barstate.islast
win_rate_label := label.new(
x = bar_index,
y = high,
text = "Win Rate: " + str.tostring(win_rate, "#.##") + "%",
color = win_rate > 60 ? color.green : color.red,
textcolor = color.white,
style = label.style_label_left
)
// Identify high slippage periods
high_slippage = math.abs(execution_price - signal_price) > 0.50
// Highlight on chart
bgcolor(
high_slippage ? color.new(color.yellow, 70) : na,
title = "High Slippage Warning"
)
// Add warning labels
if high_slippage
label.new(
x = bar_index,
y = high * 1.01,
text = "⚠️ High Slippage",
color = color.yellow,
textcolor = color.black,
style = label.style_label_down
)
// Compare multiple strategies
strategy_a_signals = // ... data for strategy A
strategy_b_signals = // ... data for strategy B
// Plot different markers for each
plotshape(strategy_a_signals, style=shape.triangleup, color=color.blue, title="Strategy A")
plotshape(strategy_b_signals, style=shape.circle, color=color.purple, title="Strategy B")

Cause: Incorrect timeframe or symbol mismatch Solution: Ensure TradingView chart matches Algo Trade Analytics data timeframe and symbol

Cause: Timezone differences between platforms Solution: Verify timezone settings in both Algo Trade Analytics and TradingView

Cause: Data filtering or calculation errors Solution: Check export date range and trade filters in Algo Trade Analytics

Cause: Pine Script syntax issues in generated code Solution: Copy error message, check Pine Script v5 syntax requirements

Before using exported script:

  • Trade count matches between Algo Trade Analytics and Pine Script
  • Date range covers expected period
  • Symbol matches chart symbol exactly
  • Timeframe matches your analysis period
  • Entry/exit prices align with your records
  • Export regularly to track strategy evolution
  • Save exported scripts with version numbers
  • Document changes to strategy configuration
  • Backup data before major strategy modifications
  • Use consistent colors across different exports
  • Limit marker density for chart readability
  • Position tables to avoid chart overlap
  • Test on different timeframes for optimal visibility
  • Track key metrics consistently across exports
  • Compare periods to identify performance trends
  • Highlight anomalies for investigation
  • Share insights with team or community

Part 9: Integration with Strategy Development

Section titled “Part 9: Integration with Strategy Development”
  1. Develop strategy in TradingView Pine Script
  2. Deploy with dual webhooks (execution + analytics)
  3. Monitor real performance in Algo Trade Analytics
  4. Export results back to Pine Script
  5. Analyze discrepancies between backtest and live
  6. Optimize strategy based on real execution data
  7. Repeat cycle for continuous improvement

Using Export Data for Strategy Enhancement

Section titled “Using Export Data for Strategy Enhancement”

Identify patterns:

  • Which market conditions cause execution issues?
  • When does slippage impact performance most?
  • Are certain signal types more reliable?
  • How does timing affect trade outcomes?

Make data-driven improvements:

  • Adjust position sizes based on slippage data
  • Modify entry/exit logic for better timing
  • Add filters for low-quality signals
  • Optimize for broker execution characteristics

Once you’ve exported and analyzed your data:

  1. Optimize Strategy Configuration: Use insights to improve Pine Script settings
  2. Enhance Webhook Integration: Refine signal timing and payload structure
  3. Scale Analysis: Apply learnings to additional strategies
  4. Share Results: Export visualizations for team review or documentation