Skip to content

Quick Start Guide

Before you begin, make sure you have:

  • TradingView Account with Pine Script access
  • Alpaca Trading Account (paper or live)
  • Basic understanding of trading concepts
  1. Log into your Alpaca Dashboard
  2. Navigate to “Your API Keys” section
  3. Generate new API keys:
    • API Key ID (public)
    • Secret Key (private)
  4. Important: Start with paper trading keys for testing

Configure API Keys in Algo Trade Analytics

Section titled “Configure API Keys in Algo Trade Analytics”
  1. Go to SettingsAPI Keys in Algo Trade Analytics
  2. Enter your Alpaca credentials:
    API Key ID: [Your Alpaca Key ID]
    Secret Key: [Your Secret Key]
    Environment: Paper (for testing)
  3. Click “Test Connection” to verify
  1. Navigate to WebhooksCreate New
  2. Fill in webhook details:
    • Name: “My First Strategy”
    • Description: “Testing Algo Trade Analytics integration”
    • Auth Key: Auto-generated secure key
  3. Copy the generated webhook URL
https://your-algo-trade-analytics-domain.com/api/webhook/[YOUR_WEBHOOK_ID]

📝 Step 3: Create Your Pine Script Strategy

Section titled “📝 Step 3: Create Your Pine Script Strategy”

Copy this Pine Script template to TradingView:

//@version=6
strategy("Algo Trade Analytics Quick Start", overlay=true)
// Algo Trade Analytics Configuration
authKey = "your_auth_key_here" // Replace with your auth key
ticker = syminfo.ticker
// Simple Moving Average Strategy
maLength = input.int(20, "MA Length")
ma = ta.sma(close, maLength)
// Entry Conditions
longCondition = ta.crossover(close, ma)
shortCondition = ta.crossunder(close, ma)
// Webhook Messages (Algo Trade Analytics format)
longMessage = '{"ticker":"' + ticker + '","direction":"long","auth_key":"' + authKey + '","qty":10}'
shortMessage = '{"ticker":"' + ticker + '","direction":"short","auth_key":"' + authKey + '","qty":10}'
// Execute Trades
if longCondition
strategy.entry("Long", strategy.long, alert_message=longMessage)
if shortCondition
strategy.entry("Short", strategy.short, alert_message=shortMessage)
// Plot Moving Average
plot(ma, "MA", color=color.blue)
  1. Replace your_auth_key_here with your actual auth key from Step 2
  2. Adjust quantity (qty:10) based on your risk tolerance
  3. Save the script in TradingView
  1. Right-click on your chart in TradingView
  2. Select “Add Alert”
  3. Configure alert settings:
    • Condition: Choose your strategy
    • Options: “Once Per Bar Close”
    • Expiration: Never
    • Actions: Check “Webhook URL”
  1. In the Webhook URL field, paste your Algo Trade Analytics webhook URL
  2. Message: Leave empty (Pine Script handles this)
  3. Click “Create”
  1. Go to Algo Trade AnalyticsWebhooksTest
  2. Select your webhook
  3. Send a test message:
    {
    "ticker": "AAPL",
    "direction": "long",
    "auth_key": "your_auth_key",
    "qty": 1
    }
  1. Check your Alpaca Dashboard
  2. Look for the test order in Orders section
  3. Verify it was executed correctly
  1. Navigate to DashboardTrade Analysis
  2. View real-time trade matching
  3. Monitor performance metrics:
    • Win Rate
    • Profit Factor
    • Average Slippage
  • Setup Cost: Intentional strategy cost
  • Execution Slippage: Unintended deviation
  • Fill Rate: Percentage of successful orders
  • Latency: Time from signal to execution
  1. Position Sizing: Never risk more than 1-2% per trade
  2. Stop Losses: Always use protective stops
  3. Daily Limits: Set maximum daily loss limits
  4. Paper Trading: Test thoroughly before going live

Add this to your Pine Script for better risk control:

// Risk Management
riskPercent = input.float(1.0, "Risk % per trade")
accountBalance = 10000 // Your account size
stopLossPercent = input.float(2.0, "Stop Loss %")
// Calculate position size
riskAmount = accountBalance * (riskPercent / 100)
stopDistance = close * (stopLossPercent / 100)
qty = math.round(riskAmount / stopDistance)
// Use calculated quantity in webhook
longMessage = '{"ticker":"' + ticker + '","direction":"long","auth_key":"' + authKey + '","qty":' + str.tostring(qty) + '}'
  1. Start Small: Begin with minimal position sizes
  2. Monitor Closely: Watch first few trades carefully
  3. Analyze Performance: Use Algo Trade Analytics analytics
  4. Optimize Strategy: Refine based on results
  • Multiple Timeframes: Scale your strategy
  • Complex Order Types: Stop-limit orders
  • Portfolio Management: Multiple strategies
  • Risk Analytics: Advanced performance metrics

Congratulations! 🎉 You’ve successfully set up Algo Trade Analytics. Your TradingView strategies can now automatically execute trades through Alpaca with full analytics and monitoring.