Quick Start Guide
📋 Prerequisites
Section titled “📋 Prerequisites”Before you begin, make sure you have:
- TradingView Account with Pine Script access
- Alpaca Trading Account (paper or live)
- Basic understanding of trading concepts
🚀 Step 1: Set Up Your Alpaca Account
Section titled “🚀 Step 1: Set Up Your Alpaca Account”Get Your API Keys
Section titled “Get Your API Keys”- Log into your Alpaca Dashboard
- Navigate to “Your API Keys” section
- Generate new API keys:
- API Key ID (public)
- Secret Key (private)
- Important: Start with paper trading keys for testing
Configure API Keys in Algo Trade Analytics
Section titled “Configure API Keys in Algo Trade Analytics”- Go to Settings → API Keys in Algo Trade Analytics
- Enter your Alpaca credentials:
API Key ID: [Your Alpaca Key ID]Secret Key: [Your Secret Key]Environment: Paper (for testing)
- Click “Test Connection” to verify
🔗 Step 2: Create Your First Webhook
Section titled “🔗 Step 2: Create Your First Webhook”Generate Webhook URL
Section titled “Generate Webhook URL”- Navigate to Webhooks → Create New
- Fill in webhook details:
- Name: “My First Strategy”
- Description: “Testing Algo Trade Analytics integration”
- Auth Key: Auto-generated secure key
- Copy the generated webhook URL
Webhook URL Format
Section titled “Webhook URL Format”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”Basic Strategy Template
Section titled “Basic Strategy Template”Copy this Pine Script template to TradingView:
//@version=6strategy("Algo Trade Analytics Quick Start", overlay=true)
// Algo Trade Analytics ConfigurationauthKey = "your_auth_key_here" // Replace with your auth keyticker = syminfo.ticker
// Simple Moving Average StrategymaLength = input.int(20, "MA Length")ma = ta.sma(close, maLength)
// Entry ConditionslongCondition = 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 Tradesif longCondition strategy.entry("Long", strategy.long, alert_message=longMessage)if shortCondition strategy.entry("Short", strategy.short, alert_message=shortMessage)
// Plot Moving Averageplot(ma, "MA", color=color.blue)Configure the Script
Section titled “Configure the Script”- Replace
your_auth_key_herewith your actual auth key from Step 2 - Adjust quantity (
qty:10) based on your risk tolerance - Save the script in TradingView
🔔 Step 4: Set Up TradingView Alerts
Section titled “🔔 Step 4: Set Up TradingView Alerts”Create Alert
Section titled “Create Alert”- Right-click on your chart in TradingView
- Select “Add Alert”
- Configure alert settings:
- Condition: Choose your strategy
- Options: “Once Per Bar Close”
- Expiration: Never
- Actions: Check “Webhook URL”
Add Webhook URL
Section titled “Add Webhook URL”- In the Webhook URL field, paste your Algo Trade Analytics webhook URL
- Message: Leave empty (Pine Script handles this)
- Click “Create”
✅ Step 5: Test Your Setup
Section titled “✅ Step 5: Test Your Setup”Send Test Trade
Section titled “Send Test Trade”- Go to Algo Trade Analytics → Webhooks → Test
- Select your webhook
- Send a test message:
{"ticker": "AAPL","direction": "long","auth_key": "your_auth_key","qty": 1}
Verify in Alpaca
Section titled “Verify in Alpaca”- Check your Alpaca Dashboard
- Look for the test order in Orders section
- Verify it was executed correctly
📊 Step 6: Monitor Your Trades
Section titled “📊 Step 6: Monitor Your Trades”Algo Trade Analytics Dashboard
Section titled “Algo Trade Analytics Dashboard”- Navigate to Dashboard → Trade Analysis
- View real-time trade matching
- Monitor performance metrics:
- Win Rate
- Profit Factor
- Average Slippage
Key Metrics to Watch
Section titled “Key Metrics to Watch”- Setup Cost: Intentional strategy cost
- Execution Slippage: Unintended deviation
- Fill Rate: Percentage of successful orders
- Latency: Time from signal to execution
🛡️ Step 7: Risk Management
Section titled “🛡️ Step 7: Risk Management”Essential Settings
Section titled “Essential Settings”- Position Sizing: Never risk more than 1-2% per trade
- Stop Losses: Always use protective stops
- Daily Limits: Set maximum daily loss limits
- Paper Trading: Test thoroughly before going live
Risk Management Code
Section titled “Risk Management Code”Add this to your Pine Script for better risk control:
// Risk ManagementriskPercent = input.float(1.0, "Risk % per trade")accountBalance = 10000 // Your account sizestopLossPercent = input.float(2.0, "Stop Loss %")
// Calculate position sizeriskAmount = accountBalance * (riskPercent / 100)stopDistance = close * (stopLossPercent / 100)qty = math.round(riskAmount / stopDistance)
// Use calculated quantity in webhooklongMessage = '{"ticker":"' + ticker + '","direction":"long","auth_key":"' + authKey + '","qty":' + str.tostring(qty) + '}'🎯 Next Steps
Section titled “🎯 Next Steps”Recommended Actions
Section titled “Recommended Actions”- Start Small: Begin with minimal position sizes
- Monitor Closely: Watch first few trades carefully
- Analyze Performance: Use Algo Trade Analytics analytics
- Optimize Strategy: Refine based on results
Advanced Features
Section titled “Advanced Features”- Multiple Timeframes: Scale your strategy
- Complex Order Types: Stop-limit orders
- Portfolio Management: Multiple strategies
- Risk Analytics: Advanced performance metrics
📚 Additional Resources
Section titled “📚 Additional Resources”- Trading Guides - Advanced Pine Script strategies
- Algo Trade Analytics Webhook API - Complete API reference
- Knowledge Base - FAQ and troubleshooting
- Integration Guide - Technical details
⚠️ Important Notes
Section titled “⚠️ Important Notes”Congratulations! 🎉 You’ve successfully set up Algo Trade Analytics. Your TradingView strategies can now automatically execute trades through Alpaca with full analytics and monitoring.