Imagine your PHP application not just running a scriptβbut orchestrating a global fleet of trading terminals, all without a traditional desktop environment. MetaTrader Cloud Engine transforms your Laravel, Symfony, or Yii project into a command-center for MetaTrader 5 terminals, hosted entirely in the cloud.
This is not a simple wrapper. It is an architectural decision: build trading systems that are event-driven, horizontally scalable, and language-agnostic on the frontend, while PHP handles the heavy logic behind the scenes. Think of it as a neural bridge between the rigid world of forex terminals and the flexible universe of modern web development.
- Core Architecture (Mermaid Diagram)
- β‘ Quick Integration β Profile Configuration
- π₯οΈ Console Invocation Example
- π¦ Feature List & Capabilities
- πΊοΈ OS Compatibility Matrix
- π€ AI Integration Modules
- π Multilingual & Responsive UI Support
- π‘οΈ Disclaimer & Risk Clarification
- π License
The system is designed as a three-layer onion architecture with a cloud-burst capability. The following diagram illustrates how a PHP application connects to MetaApi, which in turn provisions cloud MetaTrader instances.
graph TD
A[Your PHP Application] --> B{MetaTrader Cloud Engine SDK}
B -->|REST/WebSocket| C[MetaApi Cloud API]
C --> D[(Provisioned MT5 Terminal)]
D --> E[Market Execution Engine]
D --> F[Historical Data Cache]
C --> G[Account Manager Service]
B --> H[Local Strategy Controller]
H --> I[Signal Generator / ML Model]
subgraph "SDK Internal Modules"
B1[Connection Pooling]
B2[Rate Limiter]
B3[Event Aggregator]
end
B --> B1
B --> B2
B --> B3
The SDK maintains persistent connections to the cloud terminal via WebSocket, ensuring sub-second latency for trade commands while PHP handles the asynchronous orchestration.
Every trading account setup begins with a Profile Configuration Array. This is your digital signature to the cloud MetaTrader environment. Below is a complete configuration example that includes risk parameters, server location preference, and terminal behavior.
// config/trading-profile.php (Laravel style)
return [
'environment' => 'production', // sandbox | production
'metaapi' => [
'token' => env('METAAPI_TOKEN'),
'region' => 'europe-west', // data residency preference
'terminal_type' => 'mt5-cloud',
'connection_timeout'=> 30, // seconds
'enable_heartbeat' => true,
],
'risk_controls' => [
'max_daily_drawdown' => 0.05, // 5% of equity
'max_positions_per_symbol' => 3,
'consecutive_loss_limit'=> 4,
'cooldown_after_loss' => 300, // 5 minutes
],
'execution' => [
'fill_policy' => 'ioc', // fill or kill / immediate or cancel
'slippage_pips' => 2,
'hedging_enabled' => false,
'strategy_mode' => 'continuous',
],
'logging' => [
'channel' => 'cloud-terminal',
'level' => 'debug',
'retention' => 14, // days
],
];This configuration acts as a contract between your application and the cloud terminal. Any deviation in risk parameters triggers a soft-block by the SDKβs internal safety governor.
Once configured, launching a trading session is a single artisan command (or Symfony console command) away. Below demonstrates how you would deploy a strategy to the cloud using the built-in CLI tool.
# Deploy "TrendFollower2026" strategy to a provisioned cloud MetaTrader terminal
php artisan mtcloud:deploy TrendFollower2026 \
--symbol=XAUUSD \
--timeframe=H1 \
--risk=0.02 \
--dry-run=false \
--verboseExpected output during a successful deployment:
[2026-04-15 10:32:14] MTCLOUD.INFO: Connecting to MetaApi cloud node...
[2026-04-15 10:32:16] MTCLOUD.INFO: Terminal provisioned in eu-west-2 region.
[2026-04-15 10:32:17] MTCLOUD.INFO: Strategy "TrendFollower2026" attached to XAUUSD H1.
[2026-04-15 10:32:18] MTCLOUD.INFO: Execution engine ready. Latency: 47ms.
The console reporter includes real-time trade logs if streamed to STDOUT with the --verbose flag. This is particularly useful for debugging or live-monitoring from a CI/CD pipeline.
| # | Feature | Benefit |
|---|---|---|
| 1 | Cloud MetaTrader Provisioning | No desktop app required; terminals spawn in data centers. |
| 2 | Persistent WebSocket Stream | Real-time price ticks, order updates, and account events. |
| 3 | Multi-Terminal Management | Manage 100+ cloud terminals from a single PHP instance. |
| 4 | Graceful Rate Limiting | Avoid MetaApi throttling with adaptive backoff algorithms. |
| 5 | Audit Trail Logger | Every trade decision is timestamped, signed, and stored. |
| 6 | Plugin-Based Strategy Loader | Hot-swap trading strategies without rebooting the terminal. |
| 7 | Historical Backtester Bridge | Feed cloud-harvested data into local PHPMD backtests. |
| 8 | Emergency Circuit Breaker | Automatic shutdown if the system detects anomalies. |
| 9 | Symbol Group Management | Batch operations on correlated instruments (e.g., all DXY pairs). |
| 10 | Webhook Integration | Receive alerts and trigger actions from external systems. |
The PHP SDK runs wherever PHP 8.x runs, but the cloud terminal control layer has specific dependency requirements. The following table details compatibility by operating system.
| Operating System π₯οΈ | Connection Stability | Port Management | Recommended Use |
|---|---|---|---|
| Linux (Ubuntu 22.04+) | β Excellent | β Native | Production servers |
| macOS Ventura+ | β Good | β Via Homebrew | Development & testing |
| Windows Server 2022 | β Good | Corporate back-office | |
| Windows 10/11 (WSL2) | β Good | β Virtualized | Hybrid dev environment |
| Alpine Linux | Lightweight containers | ||
| FreeBSD | β Not tested | β N/A | Future milestone |
π‘ Tip for high-frequency strategies: Deploy on Linux with
libuvenabled for maximum event-loop performance.
The SDK ships with two pre-integrated AI connectors that allow your trading logic to leverage large language models directly from PHP.
use MetaTraderCloud\AI\OpenAIStrategy;
$brain = new OpenAIStrategy([
'model' => 'gpt-4-turbo', // 2026 stable version
'api_key' => env('OPENAI_KEY'),
'context_window' => 8192,
'temperature' => 0.1, // low variation for trading
]);
$signal = $brain->evaluate([
'symbol' => 'EURUSD',
'price' => 1.09234,
'rsi' => 45.2,
'volume' => 12000,
]);use MetaTraderCloud\AI\ClaudeAdvisor;
$advisor = new ClaudeAdvisor([
'model' => 'claude-3-opus-2026',
'api_key' => env('CLAUDE_KEY'),
'max_tokens'=> 200,
]);
$marketSentiment = $advisor->summarize([
'news_headlines' => $latestCentralBankNews,
'economic_calendar' => $nextEightHours,
]);Both connectors cache prompts to reduce API costs and include a fallback to rule-based logic if the AI endpoint is unreachable.
Although this repository focuses on backend logic, the SDK outputs ready-to-integrate JSON responses for multilingual frontends. A companion UI component (React/Vue) can be built using the exposed endpoints.
{
"locale": "de_DE",
"message": "Handelssignal ausgefΓΌhrt. Position erΓΆffnet zu 1.09234.",
"execution_id": "txn_f3a2c8e1-9b01-4d7d-bf12-58a0e34f21cd",
"ui_badge": {
"color": "success",
"icon": "check_circle_outline"
}
}The SDK also supports bidirectional communication for frontend dashboards via Server-Sent Events (SSE). This enables real-time trade status badges on responsive dashboards without WebSocket polyfills.
Supported UI languages: English, German, French, Japanese, Simplified Chinese, Portuguese, and Arabic (RTL ready).
Important: This software is provided as an unofficial MetaApi integration tool and is not affiliated with MetaQuotes Ltd., MetaApi, or any brokerage. Trading financial instruments involves substantial risk of loss. Past performance of any strategy does not guarantee future results.
While the SDK includes circuit breakers and safety limits, no automated system can eliminate the risk of total capital loss. The AI integration modules should not be considered financial advice; they are experimental analysis tools.
By using this SDK, you acknowledge that:
- You are solely responsible for your trading decisions.
- The SDK developers assume zero liability for any financial or data losses.
- You have tested the system in a sandbox environment before live deployment.
- You comply with your jurisdictionβs financial regulations regarding algorithmic trading.
Trade wise, stay curious, and never risk what you cannot afford to lose.
This project is released under the MIT License. You are free to modify, distribute, and integrate the SDK into commercial projects. However, the original MetaApi terms of service still apply to your use of their cloud infrastructure.
Full legal text: https://opensource.org/licenses/MIT
Built with π§© for the PHP trading ecosystem. Version 2026.4.15 β Cloud Engine Build 0x1F4A.