Deploy kingdomedge-bot-template
Self-hosted trading bot. TradingView signals -> Alpaca bracket orders.
kingdomedge-bot-template
Just deployed
Deploy and Host kingdomedge-bot-template on Railway
This is KingdomEdge Algo's self-hosted trading bot. It receives webhook signals from the KingdomEdge SETS Trade indicator on TradingView, runs eight pre-trade risk checks (kill switch, daily loss cap, position size limit, trading hours window, cooldown, etc.), and places Alpaca bracket orders with up to three take-profit targets. You own the Alpaca broker keys; KingdomEdge never sees them.
About Hosting kingdomedge-bot-template
Deploy in roughly five minutes with the button below. Railway will prompt you for three required environment variables — WEBHOOK_SECRET (a 32-character random string you generate locally), ALPACA_API_KEY and ALPACA_API_SECRET (paper-trading keys from app.alpaca.markets) — and three optional ones with safe defaults (ALPACA_PAPER=true, QUANTITY_OVERRIDE=1, SENTRY_DSN). Once deployed, copy the Railway service URL into your TradingView SETS Trade alert's webhook URL, paste the matching secret into the alert's JSON message under the "secret" field, and your signals will route through the bot end-to-end. Monthly cost is roughly five dollars on Railway's Hobby plan.
Common Use Cases
- Solo retail traders running the SurgeU Surge Strategy methodology on Alpaca paper accounts who want signal-to-execution automation without writing Python.
- KingdomEdge Algo subscribers who prefer owning their own bot infrastructure over KingdomEdge-hosted multi-tenant routing.
- TradingView users who want a turnkey webhook receiver with built-in risk controls, bracket order placement, and three-target scale-out logic.
Dependencies for kingdomedge-bot-template Hosting
- A TradingView account on the Pro plan or higher (Pro is the minimum tier that allows webhook alerts).
- An Alpaca brokerage account (paper or live) at app.alpaca.markets. Paper accounts are free and instant.
- A KingdomEdge Algo subscription on the Ultimate tier or higher to access the SETS Trade Pine indicator that produces the webhook signals.
Deployment Dependencies
- Railway Hobby plan ($5/mo) or higher for hosting the bot.
- The bot template repo at https://github.com/markjramos2009/kingdomedge-bot-template, which this Railway template references directly.
- KingdomEdge SETS Trade Pine v2 or higher on TradingView, configured with a webhook alert pointing at your Railway service URL.
Implementation Details
The bot is a single-tenant Flask + Waitress service. Webhook payloads from TradingView are HMAC-validated against your WEBHOOK_SECRET, then passed through eight serial risk gates before reaching the Alpaca REST adapter. The bracket order is composed as an OCA (one-cancels-all) group with entry plus stop plus up to three take-profits. Full implementation lives in the public bot-template repo; review the README there for code-level detail.
Why Deploy kingdomedge-bot-template on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying kingdomedge-bot-template on Railway, you get push-to-deploy from GitHub, automatic HTTPS for your webhook endpoint, integrated logs and metrics, and one-click rollback on bad deploys. The Deploy-on-Railway button below takes you from zero to a running bot in roughly five minutes.
Template Content
kingdomedge-bot-template
markjramos2009/kingdomedge-bot-templateALPACA_API_KEY
Your Alpaca paper API key (starts with PK). Get from app.alpaca.markets -> API Keys -> Generate New Keys. The API key shows in plaintext; the secret only shows ONCE - save both immediately in a password manager.
WEBHOOK_SECRET
32-character random string. Generate locally with: openssl rand -hex 32 (Mac/Linux) or PowerShell -join ((48..57)+(65..90)+(97..122) | Get-Random -Count 32 | %{[char]$_}). Save in a password manager. Paste the SAME secret into your TradingView alert's webhook JSON message under the "secret" field.
ALPACA_API_SECRET
Your Alpaca paper API secret. Save in a password manager - Alpaca only displays it once at generation. Pair with ALPACA_API_KEY above.
