Skip to content

Webhook Integration Guide

The #1 onboarding challenge solved. This guide walks you through setting up real-time webhook integration between TradingView and Algo Trade Analytics.

The most effective setup uses two webhooks from the same TradingView strategy:

  1. Execution Webhook → Trading platform (e.g., TraderPost → Alpaca)
  2. Analytics Webhook → Algo Trade Analytics (signal recording)

This allows you to:

  • ✅ Execute trades via your preferred platform
  • ✅ Record all signals in Algo Trade Analytics for analysis
  • ✅ Compare intended signals vs actual execution
  • ✅ Optimize strategy performance based on real data

Why Two Webhooks? You need one webhook for trade execution and another for analytics. Algo Trade Analytics focuses on performance analysis, not trade execution.

Part 1: Algo Trade Analytics Webhook Setup

Section titled “Part 1: Algo Trade Analytics Webhook Setup”

Step 1: Create Webhook in Algo Trade Analytics

Section titled “Step 1: Create Webhook in Algo Trade Analytics”
  1. Navigate to the trading dashboard
  2. Click “Webhook Management” in the sidebar
  3. Click “Create New Webhook”
  4. Enter a descriptive name (e.g., “My Strategy Analytics”)
  5. Copy the generated webhook URL

Your webhook URL format:

https://algo-trade-analytics.com/api/webhooks/wh_[unique_id]

Each webhook requires authentication via auth_key in the payload:

{
"auth_key": "your_unique_auth_key_here",
// ... rest of your payload
}

Security Note: The auth_key is unique per webhook and required for all requests.

Algo Trade Analytics is NOT built for High-Frequency Trading:

  • Webhook Limit: 30 requests per minute
  • Global Limit: 100 requests per 15 minutes
  • Designed for: Strategy signals, not HFT scalping

If you exceed limits, you’ll receive a 429 error. This is intentional to ensure platform stability.

Part 2: TradingView Pine Script Configuration

Section titled “Part 2: TradingView Pine Script Configuration”

Configure your Pine Script strategy to send webhooks:

//@version=5
strategy("My Strategy with Webhooks", overlay=true, calc_on_every_tick=true)
// Your strategy logic here
longCondition = ta.crossover(ta.sma(close, 14), ta.sma(close, 28))
shortCondition = ta.crossunder(ta.sma(close, 14), ta.sma(close, 28))
// Entry signals with webhook alerts
if longCondition and strategy.position_size == 0
strategy.entry("Long", strategy.long)
// Algo Trade Analytics Webhook
alert('{"auth_key":"YOUR_AUTH_KEY","ticker":"' + syminfo.ticker + '","direction":"long","marketPrice":' + str.tostring(close) + ',"orderType":"market","qty":100,"positionIntent":"entryLong","metadata":{"strategy":"MA Crossover","signal":"Golden Cross","confidence":0.8,"timestamp":"' + str.tostring(time) + '"}}', alert.freq_once_per_bar)
if shortCondition and strategy.position_size == 0
strategy.entry("Short", strategy.short)
// Algo Trade Analytics Webhook
alert('{"auth_key":"YOUR_AUTH_KEY","ticker":"' + syminfo.ticker + '","direction":"short","marketPrice":' + str.tostring(close) + ',"orderType":"market","qty":100,"positionIntent":"entryShort","metadata":{"strategy":"MA Crossover","signal":"Death Cross","confidence":0.8,"timestamp":"' + str.tostring(time) + '"}}', alert.freq_once_per_bar)

Advanced: Unified Dual Webhook Pine Script

Section titled “Advanced: Unified Dual Webhook Pine Script”

This example shows how to create webhook functions that can format for either platform:

// ==================
// WEBHOOK PLATFORM SELECTION
// ==================
g_platform = "Webhook Platform"
i_webhookPlatform = input.string("Algo Trade Analytics", "Webhook Platform",
options=["TraderPost", "Algo Trade Analytics"], group=g_platform,
tooltip="Select the webhook platform format")
// ==================
// WEBHOOK CONFIGURATION
// ==================
g_webhook = "Webhook Configuration"
i_authKey = input.string("your_auth_key", "Webhook Auth Key", group=g_webhook)
i_webhookQty = input.int(100, "Webhook Quantity", minval=1, group=g_webhook)
// ==================
// UNIFIED WEBHOOK FUNCTIONS
// ==================
// TraderPost webhook format
createTraderPostAlert(direction, orderType) =>
ticker = syminfo.ticker
sentiment = direction == "buy" ? "bullish" : "bearish"
baseMsg = '"ticker": "' + ticker + '", "action": "' + direction + '", "sentiment": "' + sentiment +
'", "orderType": "' + orderType + '", "timeInForce": "gtc"'
extrasMsg = '"message": "Strategy Entry", "price": ' + str.tostring(close)
'{' + baseMsg + ', "extras": {' + extrasMsg + '}}'
// Algo Trade Analytics webhook format
createAlgoTradeAnalyticsAlert(side, orderType) =>
ticker = syminfo.ticker
direction = side == "buy" ? "long" : "short"
positionIntent = side == "buy" ? "entryLong" : "entryShort"
// Required fields
requiredFields = '"auth_key": "' + i_authKey + '", "ticker": "' + ticker +
'", "direction": "' + direction + '", "marketPrice": ' + str.tostring(close) +
', "qty": ' + str.tostring(i_webhookQty)
// Order configuration
orderConfig = ', "orderType": "' + orderType + '", "positionIntent": "' + positionIntent + '"'
// Metadata
metadata = ', "metadata": {"strategy": "Your Strategy", "signal": "Entry Signal", ' +
'"signalPlatform": "tradingview", "brokerPlatform": "alpaca", ' +
'"timestamp": "' + str.format_time(timenow, "yyyy-MM-dd'T'HH:mm:ss.000'Z'", "UTC") + '"}'
'{' + requiredFields + orderConfig + metadata + '}'
// Unified webhook creation that routes to the correct format
createUnifiedAlert(side, orderType) =>
if i_webhookPlatform == "TraderPost"
createTraderPostAlert(side, orderType)
else
createAlgoTradeAnalyticsAlert(side, orderType)
// ==================
// USAGE IN YOUR STRATEGY
// ==================
// In your entry/exit logic, use:
// alert_message = createUnifiedAlert("buy", "market") // For long entries
// alert_message = createUnifiedAlert("sell", "market") // For short entries

Key Benefits:

  • Platform Switching: One dropdown to change webhook format
  • Format Compliance: Each platform gets its expected structure
  • Easy Integration: Drop these functions into any strategy
  • Maintenance: Update webhook logic in one place

For Each Signal (Entry/Exit), Create TWO Alerts:

  1. Condition: Your strategy → alert() function calls
  2. Webhook URL: Your execution platform URL (TraderPost, etc.)
  3. Message: Execution-focused payload
  4. Settings:
    • Frequency: “Once Per Bar Close”
    • Expiration: “Never”
  1. Condition: Your strategy → alert() function calls
  2. Webhook URL: Your Algo Trade Analytics webhook URL
  3. Message: Analytics-focused payload (with auth_key)
  4. Settings:
    • Frequency: “Once Per Bar Close”
    • Expiration: “Never”
{
"auth_key": "YOUR_AUTH_KEY",
"ticker": "{{ticker}}",
"direction": "long",
"marketPrice": {{close}},
"orderType": "market",
"qty": 100,
"positionIntent": "entryLong",
"metadata": {
"strategy": "{{strategy.order.comment}}",
"signal": "Manual Entry",
"timestamp": "{{time}}",
"confidence": 0.8
}
}
{
"auth_key": "YOUR_AUTH_KEY",
"ticker": "{{ticker}}",
"direction": "long",
"marketPrice": {{close}},
"orderType": "stop_limit",
"qty": 100,
"stopPrice": {{close}},
"limitPrice": {{close}},
"timeInForce": "DAY",
"positionIntent": "entryLong",
"takeProfit": {
"price": {{close * 1.02}},
"timeInForce": "GTC"
},
"stopLoss": {
"price": {{close * 0.98}},
"timeInForce": "GTC"
},
"metadata": {
"strategy": "Breakout Strategy",
"signal": "Volume Spike",
"signalPlatform": "tradingview",
"brokerPlatform": "alpaca",
"timestamp": "{{time}}",
"confidence": 0.9,
"riskLevel": "medium"
}
}
  1. Navigate to Webhook Management
  2. Select your webhook
  3. Click “Test Webhook”
  4. Choose test mode:
    • Single Test: Test one payload
    • Bulk Test: Test multiple payloads from CSV

Test your webhook directly:

Terminal window
curl -X POST https://algo-trade-analytics.com/api/webhooks/wh_your_id \
-H "Content-Type: application/json" \
-d '{
"auth_key": "your_auth_key",
"ticker": "AAPL",
"direction": "long",
"marketPrice": 150.50,
"orderType": "market",
"qty": 100,
"positionIntent": "entryLong"
}'

Expected Response:

{
"status": "success",
"message": "Webhook processed successfully",
"eventId": "evt_123456"
}
  1. Market Order Entry: Basic buy/sell signals
  2. Stop-Limit Orders: Complex order types
  3. Risk Management: Orders with take profit/stop loss
  4. High Frequency: Test rate limiting (30/minute max)
  5. Error Handling: Invalid payloads, missing auth_key

Monitor all webhook activity in Algo Trade Analytics:

  1. Navigate to Webhook Management
  2. Select “Events” tab
  3. View real-time webhook deliveries
  4. Filter by webhook, date, or status

Cause: Missing or invalid auth_key Solution: Verify auth_key matches your webhook configuration

Cause: More than 30 requests per minute Solution: Reduce signal frequency or optimize your strategy

Cause: Malformed JSON or missing required fields Solution: Validate JSON syntax and include required fields: auth_key, ticker, direction, marketPrice

Cause: Incorrect webhook URL Solution: Copy the correct URL from Algo Trade Analytics webhook management

Cause: Alert configuration or strategy issues Solution: Check strategy logic, calc_on_every_tick setting, and alert conditions

  • Use calc_on_every_tick=true for real-time signals
  • Enable magnifier for accurate intrabar calculations
  • Test in paper trading before going live
  • Set reasonable position sizes for live trading
  • Include metadata for better analytics
  • Use descriptive strategy names for organization
  • Test webhook delivery before strategy deployment
  • Monitor rate limits to avoid 429 errors
  • Implement retry logic in your execution platform
  • Monitor webhook events for failed deliveries
  • Set up alerts for webhook failures
  • Keep backup logs of all signals

Part 7: Integration with Execution Platforms

Section titled “Part 7: Integration with Execution Platforms”

Execution Webhook (TraderPost format):

{
"ticker": "{{ticker}}",
"action": "buy",
"orderType": "market",
"quantity": 100
}

Analytics Webhook (Algo Trade Analytics format):

{
"auth_key": "YOUR_AUTH_KEY",
"ticker": "{{ticker}}",
"direction": "long",
"marketPrice": {{close}},
"orderType": "market",
"qty": 100,
"positionIntent": "entryLong",
"metadata": {
"executionPlatform": "traderpost",
"signalPlatform": "tradingview"
}
}

Algo Trade Analytics plans to integrate with Alpaca Connect, eliminating the need for manual API setup. Users will authenticate directly through Alpaca’s platform.

  1. Test Webhook Delivery

    • Use Algo Trade Analytics webhook tester
    • Verify payload format and auth_key
    • Check rate limiting
  2. Verify TradingView Configuration

    • Confirm alert is active and not expired
    • Check webhook URL is correct
    • Validate JSON message syntax
  3. Monitor Real-time Events

    • Watch webhook events in real-time
    • Check for error messages or failed deliveries
    • Verify signal timing matches expectations
  4. Compare with Execution Platform

    • Check if execution webhook is working
    • Compare signal timing between platforms
    • Verify both webhooks receive same signals

Once your webhook integration is working:

  1. Monitor Performance: Use Algo Trade Analytics to compare signals vs execution
  2. Optimize Strategy: Adjust Pine Script settings based on real performance
  3. Scale Up: Add more strategies with the same dual-webhook pattern
  4. Export Results: Use Pine Script export to visualize performance in TradingView