πŸš€ AI Scalper Flow β€” Full Setup Guide & Course
Transform from complete beginner to advanced trader with this comprehensive guide. Learn to build a working AI-driven trading workflow inside n8n that connects seamlessly to Alpaca for automated market execution.
Get Full Course Access
πŸ“Œ Core Concepts Before You Start
What Is n8n?
A powerful workflow automation tool that connects apps and APIs without heavy coding. Each workflow is a visual graph of nodes representing stepsβ€”from triggers to logic to HTTP requests. Workflows are stored as JSON for easy import and export.
Alpaca API
A modern brokerage API enabling programmatic trading for both paper and live accounts. You'll need API keys from Alpaca for paper trading during testing. These keys integrate into HTTP Request nodes in n8n to execute buy and sell orders.
Technical Indicators
Indicators generate signals from price data: RSI measures overbought/oversold conditions, RMI provides momentum analysis, and SuperTrend identifies trend direction. Compute these using code nodes or market data APIs like TwelveData.
πŸ› οΈ Setup Tools You'll Need
Required Accounts
Everything you need to get started with automated trading
01
n8n Platform
Self-hosted or cloud account for workflow automation
02
Alpaca Trading
Paper trading API keys for testing strategies
03
Market Data API
TwelveData or similar for price and indicator data
04
Google Cloud
OAuth credentials for Gmail and Google Sheets integration
Essential n8n Nodes
Schedule Trigger
Runs your bot at defined intervals during market hours
HTTP Request
Fetches market data and places trades via API calls
Code Node
Computes custom indicators and parses JSON data
Google Sheets
Logs all trades for analysis and record-keeping
Email & Alerts
Sends notifications via Gmail or Telegram
🧩 Importing a JSON Trading Workflow
n8n workflows are stored as JSON files, making it incredibly easy to copy and paste entire automation flows. This powerful feature lets you quickly deploy proven trading strategies without building from scratch.
Open n8n
Navigate to Workflows and create a new workflow
Paste JSON
Click canvas and paste the workflow JSON code
Configure Credentials
Add API keys to nodes with red warning icons

Pro Tip: If a node shows a red warning icon after import, it typically means credentials are missing. Simply click the node and add your API keys to resolve the issue.
πŸ“ˆ Building the Workflow Step-by-Step
1
Step 1: Trigger (Schedule)
Use the Schedule Trigger node and set it to run every 1-5 minutes during market hours. This ensures your bot monitors the market continuously without manual intervention.
2
Step 2: Fetch Price Data
Create an HTTP Request node to pull recent OHLC prices (candles) via a Market Data API. This real-time data feeds your indicator calculations.
GET https://api.marketdata.com/v1/quote?symbol=AAPL&interval=1min
3
Step 3: Compute Indicators
Use a Code Node to calculate RMI, SuperTrend, and RSI. Your code should parse the price JSON and output structured indicator values for decision-making.
const data = items[0].json; const prices = data.priceArray; const rmi = calculateRMI(prices); const superTrend = calculateSuperTrend(prices); return [{json: {rmi, superTrend}}];
4
Step 4: AI Signal Logic
For advanced setups, use an AI Agent Node that analyzes technical data and outputs structured JSON like {"signal":"BUY","confidence":0.72}. This adds intelligent decision-making to your workflow.
πŸ’° Executing Trades with Alpaca
Once your indicators generate signals, it's time to execute trades. Alpaca's API makes this seamless with simple HTTP requests that place market orders instantly.
HTTP Request Configuration
Place buy and sell orders using Alpaca's paper trading endpoint. Include your API key and secret in the headers for authentication.
POST https://paper-api.alpaca.markets/v2/orders Headers: APCA-API-KEY-ID: your_key APCA-API-SECRET-KEY: your_secret Body JSON: { "symbol": "AAPL", "qty": 1, "side": "buy", "type": "market", "time_in_force": "day" }
Order Types
  • Buy Orders: Set "side":"buy" to enter positions
  • Sell Orders: Set "side":"sell" to exit positions
  • Market Orders: Execute immediately at current price
  • Time in Force: "day" ensures orders expire at market close
πŸ“Š Logging & Alerts System
Google Sheets Integration
Log every executed trade with comprehensive data: timestamp, symbol, entry price, exit price, signal type, and profit/loss. This creates an auditable trail for performance analysis.
  • Timestamp of execution
  • Trading symbol
  • Entry and exit prices
  • Signal confidence score
  • Profit/loss calculation
Real-Time Alerts
Use Gmail or Telegram nodes to receive instant notifications when trades execute. Stay informed without constantly monitoring the dashboard.
"⚑ Bought AAPL at $175.50 based on RMI/SuperTrend BUY signal with 0.82 confidence"
πŸš€ Complete Workflow Logic
Here's how all the components connect to create your automated trading system. Each node passes data to the next, creating a seamless flow from market data to trade execution.
This architecture ensures every trade is based on solid technical analysis, properly logged, and immediately reported. The modular design lets you modify any component without breaking the entire system.
1
Schedule Trigger
Initiates the workflow at set intervals
2
HTTP Request
Fetches real-time price data
3
Code Node
Computes technical indicators
4
AI Agent
Generates buy/sell signals
5
Alpaca API
Executes market orders
6
Google Sheets
Logs trade details
7
Alerts
Sends notifications
🧠 What You'll Learn By Doing This
Building this automated trading system teaches you far more than just automationβ€”you'll gain deep insights into how professional traders think and operate.
Indicator Mastery
Understand how indicators work under the hood, not just how to use them. Learn the mathematical foundations that drive trading decisions.
Real-Time Data Processing
Master the art of fetching and processing live market data in real time, handling API rate limits and data quality issues.
Data Structuring
Process and structure complex data with JavaScript, transforming raw market feeds into actionable trading signals.
AI-Driven Decisions
Trigger trades based on intelligent logic or AI decisions, combining technical analysis with machine learning confidence scores.
End-to-End Automation
Log and automate your entire trading loop, creating a professional-grade system that runs 24/7 without supervision.
⚑ Tips & Best Practices
Start with Paper Trading
Always begin with paper trading before risking real capital. Test your strategies thoroughly and build confidence in your system's performance.
Implement Risk Controls
Add stop-loss and take-profit rules to protect your capital. Define maximum position sizes and daily loss limits to manage risk effectively.
Backtest Your Logic
Test your strategy against historical data before deploying live. This reveals potential weaknesses and validates your approach.
Use Structured JSON
Ensure indicators output clean, structured JSON so decision logic receives properly formatted data. This prevents errors and improves reliability.

Ready to Build Your Trading Bot?
This comprehensive guide gives you everything needed to create a professional automated trading system. From basic concepts to advanced AI integration, you now have the roadmap to trading automation success.
Don't waitβ€”start building your AI trading system today and join the future of algorithmic trading.
Get Full Course Access
Unlock complete workflow templates, video tutorials, and ongoing support
Made with