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
Why Audit Your Backtest?
Section titled “Why Audit Your Backtest?”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.
Workflow Overview
Section titled “Workflow Overview”The analysis follows a structured 4-step workflow:
- Scope: Define your audit parameters (ticker, timeframe, and analysis window).
- Strategy: Provide your strategy context (name, version, and optional source code).
- Backtesting: Upload your TradingView backtest export (List of Trades CSV).
- Configuration: Fine-tune matching tolerances (time windows, price deviation).
Detailed Steps
Section titled “Detailed Steps”1. Scope Definition
Section titled “1. Scope Definition”- Symbol: Enter the exact ticker symbol used in TradingView (e.g.,
NASDAQ:AAPLorBTCUSD). - 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).
2. Strategy Context
Section titled “2. Strategy Context”- 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.
3. Backtest Data Upload
Section titled “3. Backtest Data Upload”- Export from TradingView:
- Open the Strategy Tester panel at the bottom of your TradingView chart.
- Click the List of Trades tab.
- 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”.
4. Alert Data Selection
Section titled “4. Alert Data Selection”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.
5. Analysis Configuration
Section titled “5. Analysis Configuration”- 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).
Understanding the Results
Section titled “Understanding the Results”Comparison Grid
Section titled “Comparison Grid”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.
Interactive Chart
Section titled “Interactive Chart”- 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.
AI Logic Resolution
Section titled “AI Logic Resolution”If discrepancies are found, the Analyze with AI feature becomes available. The AI agent will:
- Analyze Context: Correlate the specific discrepancy with price action and strategy settings.
- Diagnose Logic: Identify common causes like repainting, intrabar failures, or timestamp misalignments.
- 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.
Performance Benchmarks
Section titled “Performance Benchmarks”- High Match Rate: Production ready. Logic is stable.
- Medium Match Rate: Minor drift. Check your
calc_on_order_fillsandprocess_orders_on_closesettings. - Low Match Rate: High risk. Your backtest is likely “lying” about real-world performance. Fix the script before live trading.