Skip to content
Algo Trade Analytics Docs

Backtest vs Alerts

The Backtest vs Alerts tool is your first line of defense against logic divergence. It helps you understand why a strategy that looks great in the TradingView Strategy Tester might be failing to fire alerts correctly in real-time.

Location: Algo Trade Analytics > Backtest vs Alerts

Many traders assume alerts match backtesting perfectly. In reality, several factors cause them to drift:

  • Repainting: Strategy signals that disappear after the bar closes.
  • REST vs WebSocket: Differences in data feeds between historical and real-time.
  • Complex Logic: Conditional blocks that behave differently on historical bars.

The analysis follows a structured 4-step workflow:

  1. Scope: Define your audit parameters (ticker, timeframe, and analysis window).
  2. Strategy: Provide your strategy context (name, version, and optional source code).
  3. Backtesting: Upload your TradingView backtest export (List of Trades CSV).
  4. Configuration: Fine-tune matching tolerances (time windows, price deviation).
  • Symbol: Enter the exact ticker symbol used in TradingView (e.g., NASDAQ:AAPL or BTCUSD).
  • Date Range: Select the start and end dates for your audit. Ensure this range is covered by your backtest data.
  • Timeframe: Match the chart timeframe of your strategy (e.g., 1h, 4h, 1D).
  • Strategy Name: A label for this audit report.
  • Source Code (Optional): Pasting your Pine Script allows the AI agent to provide deeper logic debugging if discrepancies are found.
  • Export from TradingView:
    1. Open the Strategy Tester panel at the bottom of your TradingView chart.
    2. Click the List of Trades tab.
    3. Click the Export CSV icon (usually located at the top-right of the trade list table).
  • Upload: Drag and drop this file into the upload zone.
  • Validation: The system will verify headers and row counts. Ensure your CSV includes standard columns like “Trade #”, “Type”, “Signal”, “Date/Time”, “Price”, and “Profit”.

You can compare your backtest against two types of real-time data:

  • Webhook Events: Automatically pull signals received by your configured webhooks.
  • CSV Upload: Manually upload a CSV of alert logs if you aren’t using webhooks yet.
  • Max Time Difference: How many minutes/seconds of drift are allowed between a backtest timestamp and a real-time alert? (Default: 5 mins).
  • Price Tolerance: What percentage of price deviation is acceptable? (Default: 0.5%).
  • Ignore Close-on-Trigger: Toggle this if your strategy repaints by design (e.g., calc_on_every_tick=true).

The analysis output presents a side-by-side grid of every trade:

  • Matched: Signals that align within your tolerance settings.
  • Missing: Trades present in the backtest but absent in real-time alerts.
  • Unmatched Alerts: Real-time alerts that have no corresponding backtest trade.
  • Visual Audit: A synchronized price chart overlays your backtest trades (markers) and real-time alerts (flags).
  • Drift Visualization: Hover over any signal to see the exact time and price delta between the expected and actual event.

If discrepancies are found, the Analyze with AI feature becomes available. The AI agent will:

  1. Analyze Context: Correlate the specific discrepancy with price action and strategy settings.
  2. Diagnose Logic: Identify common causes like repainting, intrabar failures, or timestamp misalignments.
  3. Suggest Fixes: Provide concrete Pine Script code adjustments to align your backtest with real-time behavior.
  • Direct Fixes: Send the resolution directly to the AI Editor to automatically update your Pine Script.
  • High Match Rate: Production ready. Logic is stable.
  • Medium Match Rate: Minor drift. Check your calc_on_order_fills and process_orders_on_close settings.
  • Low Match Rate: High risk. Your backtest is likely “lying” about real-world performance. Fix the script before live trading.