BullionDocs

Getting Started

How It Works

Bullion separates cloud orchestration from local trade execution. The backend never touches your broker. The agent does — and only from your own machine.

System flow
  TradingView alert fires
          │
          ▼
  ┌──────────────────┐
  │  Bullion Backend │  ← receives webhook, validates, deduplicates
  │  (cloud VPS)     │
  └────────┬─────────┘
           │  gRPC bidirectional stream (outbound from agent)
           ▼
  ┌──────────────────┐
  │  Bullion Agent   │  ← your Windows machine
  │  (Windows)       │
  └────────┬─────────┘
           │  Python MT5 bindings
           ▼
  ┌──────────────────┐
  │  MT5 Terminal    │  ← places the broker-side order
  └──────────────────┘
           │
           ▼
  Trade confirmed → backend persists → dashboard updates

01The alert path

When a TradingView alert fires, it sends an HTTP POST to your backend webhook endpoint. The backend validates the JSON payload, checks for duplicates using a 5-minute idempotency window, and creates an execution job. The entire path from webhook receipt to agent command dispatch is logged in the database.

02The gRPC connection

The agent on your Windows machine initiates a persistent outbound gRPC stream to the backend. Because the connection is outbound from the agent, you don't need to open any firewall ports or configure inbound rules on your trading machine. The backend pushes commands over this stream the moment an alert clears validation.

No inbound ports required. The agent connects out to the backend. Your Windows machine needs only a normal internet connection.

03Trade execution

The agent receives the command and calls the MT5 Python bindings (mt5.order_send()) to place the order with your broker. The result — filled, rejected, or errored — is sent back over the same gRPC stream, persisted in the backend database, and pushed to the dashboard in real time over WebSocket.

04Reconciliation & sync

Every 30 seconds the agent runs a reconciliation loop: it calls mt5.positions_get(), mt5.orders_get(), and mt5.account_info(), then sends the results to the backend. This keeps the dashboard in sync with the true broker state even if a trade was opened manually in MT5 or a connection hiccup caused a missed event.

05Watchdog & heartbeat

The agent sends a heartbeat to the backend every 15 seconds. Separately, a watchdog process checks MT5 health every 10 seconds — if it detects a freeze or disconnect it kills the MT5 process, restarts the terminal, and reconnects the session without any manual intervention.

One agent, one account

Each agent manages exactly one MT5 terminal and one broker login. This keeps sessions isolated, simplifies debugging, and prevents one account's issues from affecting another. For multiple accounts, deploy one agent per Windows machine (or per MT5 terminal instance).