An automated futures trading bot that connects to Tradovate via API and WebSocket, receives signals from TradingView, and executes trades using a grid strategy — with a real-time React dashboard for monitoring and configuration.
The dashboard provides a live view of your account: candlestick chart, strategy performance metrics, open positions, and execution logs — all updating in real time.
Strategy Performance metrics:
- Win Rate, Max Drawdown, Risk/Reward, Profit Factor
- Sharpe Ratio, Average Win, Average Loss, Expectancy
Active Positions table:
- Symbol, direction (LONG/SHORT), contracts, entry price, current price, unrealized P&L
Execution Logs panel:
- Timestamped INFO / WARN / ERROR entries from every strategy step
Secure password-protected access. Enable or disable authentication via the TRADOVATE_AUTHENTICATION_ENABLED environment variable.
Adjust all strategy parameters from the UI without restarting the bot:
| Section | Options |
|---|---|
| Bot Setting | Enable/disable auto-trading, select active symbol |
| Authentication | Tradovate demo/live credentials |
| Symbol Setting | Timeframe, contract (e.g. ESZ2 / 1m) |
| Call Configurations | Logic #1/#2, Stop Loss, Stop Loss Strong, Point In |
Browse closed trades with entry/exit prices, P&L in points and dollars, and the logic gate that triggered the trade (Logic #1, #2, #4).
- Automated trading — Executes buy/sell orders based on TradingView signals (
BUY,SELL,STRONG_BUY,STRONG_SELL) - Grid trading strategy — Multiple entry/exit levels with configurable stop-loss percentages
- Technical indicators — WMA, RSI, CrossUp, CrossDown signal confirmation
- Trailing stop-loss — Configurable max loss protection per trade
- Real-time candlestick chart — Live OHLCV bars via WebSocket, powered by
lightweight-charts - Strategy configuration — Change all parameters from the UI without restarting
- Slack notifications — Alerts for order confirmations and executions
- Job monitoring — Built-in Bull Board for queue inspection at
/bull-board - Local tunnel support — Expose bot publicly to receive TradingView webhook alerts
The core weakness of indicator-only systems is regime blindness: RSI, WMA, and MACD generate signals regardless of whether the market is in a trending state or grinding sideways. In sideways (choppy) markets, these signals fail at a statistically high rate, producing a cascade of stoploss hits. The v2.0 layer solves this by classifying market regime from raw futures microstructure data before any entry is considered.
New agents (all run as isolated PM2 processes):
| Agent | Description | Publishes |
|---|---|---|
agent-order-flow |
Computes CVD (Cumulative Volume Delta) and Execution Pressure from raw Tradovate tick data every 5 seconds | evt:order-flow:snapshot |
agent-vol-profile |
Builds a live intraday volume profile per contract (reset at 09:30 ET), computes POC / VAH / VAL / HVN / LVN | evt:vol-profile:snapshot |
agent-regime |
Fuses OrderFlow + VolProfile into a 5-class regime label every 10 seconds | evt:regime:snapshot |
Regime classification:
| Regime | Condition | Strategy action |
|---|---|---|
DEAD_PINNING |
` | pressure |
SIDEWAY |
Price inside value area, low conviction flow | Block all entries |
MIXED |
Ambiguous — flow exists but no clear direction | Allow entries, tighter risk |
ACTION |
` | pressure |
HARD_ACTION |
` | pressure |
Volume Profile — futures-native equivalents of options GEX levels:
| Futures metric | Options GEX equivalent | Interpretation |
|---|---|---|
| POC (Point of Control) | Gamma Flip level | Price gravitates here in low-volatility sessions |
| VAH (Value Area High) | Call Wall | Upper resistance; sellers defend above value area |
| VAL (Value Area Low) | Put Wall | Lower support; buyers defend below value area |
| HVN (High Volume Node) | Gamma wall cluster | Liquidity node that slows price movement |
| LVN (Low Volume Node) | GEX gap / thin zone | Price moves fast through these levels |
Dashboard — Market Intelligence panel:
The new row between the chart and the positions table shows live:
- Regime badge (color-coded by severity)
- Regime hint (
EXPANDING_UP/EXPANDING_DOWN/PINNING/FLAT) - Execution pressure (±0.000 scale)
- CVD (running buy/sell imbalance)
- VAH / POC / VAL prices
- Price-vs-value-area indicator (
ABOVE_VAH/INSIDE_VA/BELOW_VAL) - Session phase (OPEN / MORNING / LUNCH / AFTERNOON / POWER_HOUR / CLOSED)
See docs/MARKET-INTELLIGENCE.md for a full technical deep-dive on why indicator-only bots fail and how the regime layer works.
| Symbol | Description |
|---|---|
| ES | E-mini S&P 500 |
| NQ | E-mini Nasdaq-100 |
| MES | Micro E-mini S&P 500 |
| MNQ | Micro E-mini Nasdaq-100 |
| Layer | Technology |
|---|---|
| Backend | Node.js, Express.js, Bull queue, WebSocket, Bunyan |
| Database | PostgreSQL (trade history, logs, strategy config) |
| Cache | Redis + Redlock (market data, account state, locks) |
| Messaging | Redis pub/sub (inter-agent event bus) |
| Process management | PM2 (one OS process per agent) |
| Frontend | React 18, TypeScript, Vite, TailwindCSS, Radix UI |
| Charts | lightweight-charts (TradingView library) |
| Data fetching | React Query (TanStack Query v5) |
- Node.js 18+ and npm 9+ (for local dev)
- PostgreSQL 14+ and Redis 6+ (or Docker)
- A Tradovate account (demo or live)
- A TradingView account for signal alerts (optional)
git clone https://github.com/dearvn/tradovate-trading-bot.git
cd tradovate-trading-bot
cp .env.example .envEdit .env with your credentials:
# Tradovate mode: "local" (demo) or "production" (live)
TRADOVATE_MODE=local
# Demo app credentials (from Tradovate API Management)
TRADOVATE_DEMO_APP_ID=your_app_id
TRADOVATE_DEMO_APP_VERSION=1.0
TRADOVATE_DEMO_CID=your_cid
TRADOVATE_DEMO_SECRET=your_secret
# Demo account credentials
TRADOVATE_DEMO_USERNAME=your_username
TRADOVATE_DEMO_PASSWORD=your_password
# UI login
TRADOVATE_AUTHENTICATION_ENABLED=true
TRADOVATE_AUTHENTICATION_PASSWORD=admin123bash run_local.shThis script will:
- Check for Node.js, PostgreSQL, and Redis
- Install all npm dependencies
- Create the PostgreSQL role and database if missing
- Run database migrations
- Seed initial data
- Start the backend and frontend dev servers
Access the dashboard at http://localhost:3000 (default password: admin123)
docker-compose build
docker-compose up -dAccess the dashboard at http://localhost:8086
| Variable | Description | Default |
|---|---|---|
TRADOVATE_MODE |
local (demo) or production (live) |
local |
TRADOVATE_DEMO_APP_ID |
Demo app ID from Tradovate | — |
TRADOVATE_DEMO_CID |
Demo client ID | — |
TRADOVATE_DEMO_SECRET |
Demo client secret | — |
TRADOVATE_DEMO_USERNAME |
Tradovate account email | — |
TRADOVATE_DEMO_PASSWORD |
Tradovate account password | — |
TRADOVATE_LIVE_APP_ID |
Live app ID | — |
TRADOVATE_LIVE_CID |
Live client ID | — |
TRADOVATE_LIVE_SECRET |
Live client secret | — |
TRADOVATE_LIVE_USERNAME |
Live account email | — |
TRADOVATE_LIVE_PASSWORD |
Live account password | — |
TRADOVATE_AUTHENTICATION_ENABLED |
Enable UI login | true |
TRADOVATE_AUTHENTICATION_PASSWORD |
UI login password | — |
TRADOVATE_SLACK_ENABLED |
Enable Slack alerts | false |
TRADOVATE_SLACK_WEBHOOK_URL |
Slack incoming webhook URL | — |
TRADOVATE_LOCAL_TUNNEL_ENABLED |
Expose via local tunnel | false |
TRADOVATE_LOCAL_TUNNEL_SUBDOMAIN |
Custom tunnel subdomain | — |
TRADOVATE_POSTGRES_HOST |
PostgreSQL host | postgres |
TRADOVATE_POSTGRES_DATABASE |
Database name | tradovate |
- Enable local tunnel in
.env(TRADOVATE_LOCAL_TUNNEL_ENABLED=true) or expose port 8086 publicly - In TradingView, create an alert with webhook URL pointing to your bot
- Set the alert message body to one of:
{ "symbol": "ES", "action": "BUY" }
{ "symbol": "ES", "action": "SELL" }
{ "symbol": "NQ", "action": "STRONG_BUY" }
{ "symbol": "NQ", "action": "STRONG_SELL" }The bot maps signal strength to grid logic levels: BUY/SELL → Logic #1, STRONG_BUY/STRONG_SELL → Logic #2.
| Method | Path | Description |
|---|---|---|
GET |
/api/healthz |
Health check |
GET |
/api/dashboard/summary |
Account balance, positions, daily P&L |
GET |
/api/positions |
Open positions |
DELETE |
/api/positions/:id |
Close a position |
GET |
/api/strategy |
Current strategy configuration |
PUT |
/api/strategy |
Update strategy settings |
GET |
/api/strategy/performance |
Win rate, drawdown, Sharpe, expectancy |
GET |
/api/trades |
Trade history |
GET |
/api/logs |
Application logs |
GET |
/api/bars |
OHLCV bars for chart (Redis cache) |
POST |
/auth/login |
Authenticate (returns JWT) |
GET |
/bull-board |
Bull queue monitor |
# Install all dependencies
npm install && cd frontend && npm install && cd ..
# Start backend with hot reload
npm run dev
# Start frontend dev server (separate terminal)
cd frontend && npm run dev
# Run backend tests
npm test
# Database migrations
npm run migrate:up
npm run migrate:down
# Seed development data
node scripts/seed.js# Build and start all services
docker-compose build && docker-compose up -d
# View logs
docker-compose logs -f
# Stop all services
docker-compose down
# Stop and remove all volumes (destructive)
docker-compose down -vtradovate-trading-bot/
├── agents/ # PM2 agent processes (v2.0+)
│ ├── shared/
│ │ ├── channels.js # Redis pub/sub channel name constants
│ │ ├── redis-pubsub.js # createPublisher / createSubscriber
│ │ ├── cache.js # Redis client wrapper
│ │ ├── logger.js # Bunyan structured logger
│ │ └── error-handler.js # Process-level uncaught exception handler
│ ├── config/ # Hot-reload config from PostgreSQL
│ ├── market-data/ # Tradovate WebSocket → Redis (quotes, chart, DOM)
│ ├── order-flow/ # CVD + Execution Pressure (5s snapshots)
│ ├── vol-profile/ # Volume Profile: POC/VAH/VAL/HVN/LVN (30s snapshots)
│ ├── regime/ # Regime classifier: DEAD_PINNING→HARD_ACTION (10s)
│ ├── strategy/ # TradingView signals + regime gate → orders
│ ├── order/ # Tradovate order state machine
│ ├── notification/ # Slack + WebSocket notification relay
│ └── frontend/ # Express HTTP + WebSocket server
├── app/
│ ├── tradovate/ # Tradovate REST + WebSocket client
│ ├── cronjob/
│ │ ├── trailingTradeHelper/ # Core strategy logic (grid, stop-loss)
│ │ └── trailingTradeIndicator/ # WMA, RSI, CrossUp, CrossDown, token refresh
│ ├── frontend/
│ │ ├── webserver/ # REST API route handlers
│ │ └── bull-board/ # Job queue monitor UI
│ └── helpers/ # cache.js, postgres.js, logger.js, slack.js
├── frontend/ # React dashboard (Vite + TypeScript)
│ └── src/
│ ├── pages/ # Dashboard, TradeHistory, Settings, Logs
│ ├── components/ # CandlestickChart, PositionsTable, LogsPanel
│ └── hooks/
│ ├── useMarketData.ts # Price tick / price update WebSocket hook
│ ├── useOrderFlow.ts # CVD / pressure / regime / vol-profile hook
│ └── useChartData.ts # OHLCV bars for candlestick chart
├── docs/
│ └── MARKET-INTELLIGENCE.md # Deep-dive: regime-aware trading system
├── config/ # Strategy defaults (default.json)
├── ecosystem.config.js # PM2 process definitions
├── migrations/ # PostgreSQL schema migrations
├── scripts/
│ └── seed.js # Development seed data
├── run_local.sh # Local dev startup script
├── docker-compose.yml
└── .env.example
- Tradovate OAuth + direct auth
- WebSocket real-time market data
- Grid trading strategy with configurable stop-loss
- TradingView signal integration
- WMA, RSI, CrossUp, CrossDown indicators
- PostgreSQL trade/order persistence
- Redis caching + Redlock distributed locks
- Bull job queue with monitoring UI
- Live candlestick chart (lightweight-charts)
- Strategy performance metrics (Sharpe, drawdown, expectancy)
- Trade history and execution logs
- Strategy settings UI (live config without restart)
- Slack notifications
- JWT authentication with rate limiting
- Local tunnel for TradingView webhooks
- Docker Compose deployment
- OrderFlowAgent: CVD + Execution Pressure from raw Tradovate tick data
- VolProfileAgent: real-time POC / VAH / VAL / HVN / LVN per contract
- RegimeAgent: DEAD_PINNING / SIDEWAY / MIXED / ACTION / HARD_ACTION classification
- Strategy regime gate: blocks entries in DEAD_PINNING and SIDEWAY regimes
- Frontend WebSocket bridges for order-flow, vol-profile, regime channels
-
useOrderFlowReact hook with auto-reconnect - Market Intelligence dashboard panel (regime, CVD, pressure, POC/VAH/VAL)
- PM2 multi-agent process management (ecosystem.config.js)
- Contract auto-rotation (ESZ2 → ESH3 on expiry)
- Backtesting engine — replay historical candles against current strategy
- Paper trading mode — simulate without placing real orders
- Multi-symbol side-by-side dashboard
- Trailing stop as price distance, not fixed percentage
- Telegram / Discord alerts
- Daily P&L email summary
- Equity curve chart
- Trade journaling with CSV export
- Alert on WebSocket connection loss
- Multi-account management
- Role-based access (read-only viewer vs. admin)
- Audit log for config changes
- TOTP two-factor authentication
Feature requests and contributions welcome — open an issue or PR.
MIT



