DEV Community

AlgoHand
AlgoHand

Posted on Fully Autonomous

Adding MetaTrader controls to a VPS hosting panel with AlgoHand

A VPS can answer a ping while MetaTrader is disconnected from its broker. The terminal can be connected while its control component is missing. Neither condition is visible in a hosting panel that only reports CPU, RAM and whether Windows is running.

AlgoHand adds a view of the terminals and a customer-facing control interface. A customer can request an EA parameter change through chat, review the proposed values and confirm it. A provider can inspect terminal health across its fleet without opening every desktop. The integration connects those two sides to the provider's existing customer and server records.

This walkthrough covers the API, Windows installation and support workflow. The IDs and request bodies are examples, not production credentials or an instruction to change an existing customer's VPS.

Start with a provider workspace

The integration needs a provisioned provider tenant and a tenant-level backend API key. Provider Dashboard access also needs an operator-assigned mapping. Selecting Business in an ordinary user's profile does not grant access to other customers.

Keep the tenant key in the hosting backend. It has broad authority within the provider tenant; it is not a read-only monitoring credential. Do not distribute it to customers, browser JavaScript or Windows VM images.

Three credentials serve different purposes:

Credential Where it belongs Purpose
Provider API key Hosting backend Provision customers/VPS records and access provider operations
One-use enrolment token One machine's installation process Register that Windows machine with AlgoHand
Customer chat code That customer's authenticated panel session Open chat scoped to the customer's AlgoHand client

The Windows agent polls outbound over HTTPS. AlgoHand does not require an inbound control port on each VPS. Initial Windows setup and broker login still need to be handled; outbound polling does not remove those steps.

Provision with your own stable IDs

Use the hosting system's customer and server IDs, rather than an IP address that may change or be reassigned. Store the internal AlgoHand IDs returned by the API alongside them.

First create or update the customer:

PUT /v1/provisioning/clients/customer-1042 HTTP/1.1
Host: api.algohand.com
Authorization: Bearer <PROVIDER_BACKEND_KEY>
Content-Type: application/json

{
  "name": "Example customer",
  "metadata": { "service": "windows-trading-vps" }
}
Enter fullscreen mode Exit fullscreen mode

Then register one VPS for that customer:

PUT /v1/provisioning/clients/customer-1042/vps/server-7781 HTTP/1.1
Host: api.algohand.com
Authorization: Bearer <PROVIDER_BACKEND_KEY>
Content-Type: application/json

{ "label": "Trading VPS - Frankfurt" }
Enter fullscreen mode Exit fullscreen mode

These PUT operations are idempotent. Retrying the same active mapping returns the same internal record. A server ID already assigned to a different active customer is rejected.

The first VPS response includes enroll_token, its expiry, bootstrap_url, bootstrap_arguments and bootstrap_environment. The token is usable once and expires after 24 hours. Treat the response as sensitive: do not write it wholesale to job logs.

A retry does not reveal the original token. If the first response was lost, append /enrollment-token to the VPS resource path and POST { "replace_existing": false } to issue a fresh one. An already enrolled machine is refused by this recovery request. Do not turn a lost HTTP response into another customer or VPS record.

Install in the Windows session that owns the terminals

The current installer supports Windows Server 2016 or newer and Windows 10/11; Server 2012/R2 is not supported by this package. Run setup elevated under the intended terminal user. Keep the agent and the intended MT4/MT5 instances in that user's interactive-session workflow. Running installation as SYSTEM in a VM provisioning job is not equivalent to completing this setup.

For unattended installation, the provisioning response supplies -NoPrompt -AttachRestart window and the token through ALGOHAND_ENROLL_TOKEN. Your provisioning runner should download the returned official HTTPS bootstrap and inject that environment only into the installation process. For example, after saving the bootstrap at the path below:

# Run elevated as the intended terminal user.
# The provisioning runner supplies ALGOHAND_ENROLL_TOKEN to this process.
$ErrorActionPreference = 'Stop'
if (-not $env:ALGOHAND_ENROLL_TOKEN) {
    throw 'Missing one-use enrolment token'
}
try {
    & 'C:\Provisioning\algohand-install.ps1' -NoPrompt -AttachRestart window
} finally {
    Remove-Item Env:\ALGOHAND_ENROLL_TOKEN -ErrorAction SilentlyContinue
}
Enter fullscreen mode Exit fullscreen mode

The bootstrap downloads the EXE installer and checks its Authenticode publisher and timestamp before running it. The token is passed to that installer through its environment, rather than in command-line arguments. Do not bake an enrolled agent, its keys or a used token into a reusable VM image.

window defers a required restart of an already-running terminal to the configured maintenance window. It does not mean the terminal is immediately controllable. An interactive installation can offer Connect now; use that only with agreement to restart the selected terminals. Installation must not become an excuse to force-close a customer's work.

After setup, compare the platform, broker login and server reported by AlgoHand with the intended terminal. Check the executable and data-directory mapping when several installations exist. A broker account number alone is not enough, and an agent heartbeat does not prove that it found the correct account.

Plan for Windows sign-in after a reboot. An RDP disconnect and a Windows sign-out are different events. Do not promise uninterrupted terminal operation merely because an installer returned success.

Put the customer's chat inside your panel

The provider backend can create a customer-scoped chat session:

POST /v1/clients/cl_example/chat-codes HTTP/1.1
Host: api.algohand.com
Authorization: Bearer <PROVIDER_BACKEND_KEY>
Content-Type: application/json

{
  "label": "Hosting panel session",
  "ttl_hours": 1,
  "lang": "en"
}
Enter fullscreen mode Exit fullscreen mode

Replace cl_example with the internal client_id returned during provisioning. Derive it from your authenticated customer record, not a client ID supplied unchecked by the browser.

The response provides embed_url for an iframe and widget_snippet for a chat widget. The chat code grants access to that client, so treat it as a credential. Keep it out of analytics and shared caches, use an appropriate lifetime, and revoke it with DELETE /v1/chat-codes/{code} when the panel session ends. Closing an iframe alone does not revoke a code.

This is where the customer can ask to change a supported EA's inputs. An onboarded EA profile supplies the parameter meanings and permissions. The customer reviews the proposed change before applying it; provisioning a VPS does not onboard every EA or authorize trading changes.

A provider building its own command interface instead of embedding chat must implement approval itself. Use explicit dry_run: true previews, preserve the approved plan, and inspect the eventual command result. HTTP 202 means accepted, not completed. The API walkthrough covers preview hashes, idempotency and result polling.

Give support staff terminal-level evidence

Business Dashboard offers fleet operations, readiness checks, tags, notes, incident triage, version exports and optional daily summaries. The corresponding API can feed an existing support panel:

Request Use
GET /v1/business/fleet?attention=true&limit=100 Find machines needing inspection; follow pagination
GET /v1/fleet/{vps_id}/diagnostics Inspect one machine's agent, terminal and manager evidence
GET /v1/business/incidents Read operational incidents and their current triage state
GET /v1/business/versions.csv Export reported agent and manager versions

Check freshness as well as status. Missing or stale evidence is not proof of health. AutoTrading OFF is a separate state and does not, by itself, mean the terminal is degraded.

The diagnostics response omits balances, positions, orders and EA input values. It can reference an existing customer screenshot; requesting diagnostics does not capture a new one. Do not assume a screenshot is redacted just because the structured response excludes those fields.

Fleet inspection and incident notes do not issue terminal commands. Marking an incident in progress records support activity; it does not repair the terminal. A provider API key's authority is broader than these read-only endpoints, so enforce staff permissions in your own backend too.

Connect events to your support workflow

Register a public HTTPS receiver with POST /v1/webhooks and select events such as vps.offline, terminal.not_responding or agent.update_stalled. The endpoint secret is returned once.

Verify the AlgoHand-Signature header against the exact raw body before parsing or acting on it. Its format is t=<timestamp>,v1=<hex digest>; the digest is HMAC-SHA256 over the ASCII timestamp, a dot and the raw request bytes. Use a constant-time comparison and a bounded timestamp tolerance.

Persist accepted events before returning success, and deduplicate using the signed body's event ID. Delivery can be retried and events can arrive out of order. Use the delivery log to investigate failures and fetch current state before making an operational decision. An outage event should not automatically become permission to restart a customer's terminal.

For rebuilds, the enrolment-token endpoint requires replace_existing: true before replacing an enrolled machine; that revokes the old agent key immediately. On cancellation, decommission the VPS mapping. The agent removes its local AlgoHand state on its next request; decommissioning does not shut down MetaTrader or cancel the hosting subscription.

A useful first pilot is one customer with an MT4 and an MT5 demo terminal. Check account mapping, manager readiness, sign-in after reboot, reconnect behaviour, duplicate provisioning requests, token recovery, webhook retries and one confirmed parameter change on a non-trading test EA. This is a rollout checklist, not a claim that every Windows image and broker combination has been qualified.

The API reference and OpenAPI document describe the request and response formats. Keep the boundary clear in the hosting UI: monitoring shows what is happening; a separate, authorized command changes it.

Top comments (0)