โ† Back to Dashboard

๐Ÿš€ Deployment Guide

Deploy your TradingView โ†’ MT4 Signal Bridge to production with a permanent HTTPS URL.

โญ Recommended: Vercel + Neon (Free Forever)

Vercel hosts the app (serverless, always-on). Neon hosts the PostgreSQL database (free tier, no sleep). Both are free for hobby use with no time limits.

โœ… Free forever ยท โœ… Always-on (no sleep) ยท โœ… Automatic HTTPS ยท โœ… Permanent URL

1Create Neon Database

  1. Go to neon.tech โ†’ Sign up (GitHub login is fastest)
  2. Click "Create Project"
  3. Name it tv-mt4-bridge, pick region closest to you
  4. Click "Create Project"
  5. On the dashboard, go to Connection Details and copy the Connection String
    postgresql://username:[email protected]/neondb?sslmode=require

โš ๏ธ Use the Direct connection string, NOT the pooled one. The pooled URL contains -pooler in the hostname โ€” avoid that.

2Create Database Tables in Neon

In Neon dashboard, click SQL Editor in the left sidebar. Paste this entire SQL block and click Run:

do $$
begin
  if not exists (select 1 from pg_type where typname = 'signal_status') then
    create type signal_status as enum ('pending','executed','failed','expired','cancelled');
  end if;
end $$;

create table if not exists api_keys (
  id uuid primary key,
  name varchar(100) not null,
  key varchar(64) not null unique,
  is_active boolean not null default true,
  created_at timestamp not null default now(),
  last_used_at timestamp
);

create table if not exists signals (
  id uuid primary key,
  api_key_id uuid references api_keys(id),
  action varchar(20) not null,
  action_type varchar(50),
  symbol varchar(20) not null,
  price numeric(18,8),
  stop_loss numeric(18,8),
  take_profit numeric(18,8),
  lot_size numeric(10,2),
  magic_number varchar(20),
  ticket varchar(20),
  expiration timestamp,
  comment text,
  status signal_status not null default 'pending',
  source varchar(50) default 'tradingview',
  raw_payload text,
  executed_at timestamp,
  error_message text,
  created_at timestamp not null default now(),
  updated_at timestamp not null default now()
);

create table if not exists signal_logs (
  id uuid primary key,
  signal_id uuid not null references signals(id),
  message text not null,
  level varchar(10) not null default 'info',
  created_at timestamp not null default now()
);

You should see CREATE TABLE / DO results with no errors.

๐Ÿ’ก Verify tables exist: In SQL Editor, run select table_name from information_schema.tables where table_schema = 'public'; โ€” you should see api_keys, signals, signal_logs.

3Push Code to GitHub

  1. Create a new repo at github.com/new named tv-mt4-bridge
  2. Do NOT check "Add a README"
  3. In terminal / command prompt:
    cd your-project-folder
    git init
    git add .
    git commit -m "Initial commit"
    git remote add origin https://github.com/YOUR_USERNAME/tv-mt4-bridge.git
    git branch -M main
    git push -u origin main

โš ๏ธ Make sure you have a .gitignore that excludes node_modules/ and .next/ and .env. Otherwise GitHub will reject the push.

4Deploy to Vercel

  1. Go to vercel.com โ†’ Sign up with GitHub
  2. Click "Add New โ†’ Project"
  3. Import your tv-mt4-bridge repo
  4. Expand "Environment Variables" and add:
    DATABASE_URL = your-neon-connection-string-from-step-1
  5. Ensure all environments (Production, Preview, Development) are checked
  6. Click "Deploy"

Vercel builds in ~60 seconds. You'll get a permanent URL like tv-mt4-bridge.vercel.app.

5Verify Deployment

  1. Open https://your-app.vercel.app/api/health โ†’ should return {"ok":true}
  2. Open https://your-app.vercel.app/api/keys โ†’ should return {"keys":[]}
  3. Open https://your-app.vercel.app โ†’ dashboard should load
  4. Go to API Keys tab โ†’ Create a new key
  5. Test the webhook:
    curl -X POST https://your-app.vercel.app/api/webhook \
      -H "Content-Type: application/json" \
      -d '{
        "api_key": "YOUR_API_KEY_HERE",
        "action": "buy",
        "symbol": "EURUSD",
        "lot_size": 0.01
      }'

6Connect TradingView & MT4

Update these with your permanent Vercel URL:

SettingValue
TradingView Webhookhttps://your-app.vercel.app/api/webhook
MT4 Allowed URLhttps://your-app.vercel.app
EA ServerURLhttps://your-app.vercel.app
EA ApiKeyYour generated API key

๐ŸŽ‰ This URL never changes โ€” no more updating MT4 and TradingView after every rebuild!

๐Ÿš‚ Alternative: Railway

Railway deploys both the app and PostgreSQL in one click. Simpler setup, but the free tier only covers ~20 days of 24/7 usage ($5/month Hobby plan for unlimited).

  1. Go to railway.app and sign up
  2. Click "New Project" โ†’ "Deploy from GitHub repo"
  3. Connect your GitHub and select your repository
  4. Click "Add Database" โ†’ "PostgreSQL"
  5. Railway auto-sets DATABASE_URL
  6. Deploy!

๐Ÿ”ง Troubleshooting

"relation api_keys does not exist"

The database tables were not created. Run the SQL from Step 2 in Neon SQL Editor.

"Internal server error" on /api/keys

  • Check the Vercel Runtime Logs for the actual error detail
  • Verify DATABASE_URL is set in Vercel Settings โ†’ Environment Variables
  • Verify the tables exist in the Neon database Vercel is pointing to

drizzle-kit push hangs forever

  • Use the Neon SQL Editor instead (Step 2 above)
  • Make sure you're using the Direct connection string, not the pooled one
  • The pooled URL contains -pooler in the hostname โ€” avoid it for schema operations

Generate Key button does nothing

  • The database tables likely don't exist โ€” run Step 2
  • Check browser DevTools console for errors
  • A red error banner will appear below the button if the API returns an error

git push rejected (file too large)

  • Your .gitignore is missing or doesn't exclude node_modules/
  • Run: git rm -r --cached node_modules then commit and push again

Vercel DATABASE_URL vs local .env

  • Vercel never reads your local .env file
  • You must set DATABASE_URL in Vercel dashboard โ†’ Settings โ†’ Environment Variables
  • Both Vercel and your local .env must point to the same Neon database

MT4 Error 5203 / 401 / 502

  • 5203: URL not in MT4 allowed list, or needs MT4 restart after adding
  • 401: API key doesn't match โ€” copy it again from the dashboard
  • 502: Server URL is wrong or expired (sandbox URLs change on rebuild)

Signals not appearing?

  • Check you created an API key and included it in the webhook
  • Test with /api/webhook/test endpoint first (no auth needed)
  • Use https:// not http://
  • Don't use .arena.site URLs โ€” only .vercel.app or .e2b.app

MT4 not executing trades?

  • Check AutoTrading is enabled (green button in toolbar)
  • Check EA is attached to a chart and running (smiley face on chart)
  • Check Experts tab for error messages
  • Verify symbol name matches your broker (EURUSD vs EURUSD.r vs EURUSDm)