VPS ?????????????????? MQL5 ?????????????????????
VPS (Virtual Private Server) ?????????????????? MQL5 ????????? server ????????????????????????????????????????????? MetaTrader 5 (MT5) platform ???????????? 24 ????????????????????? ???????????????????????? Expert Advisors (EA) ???????????? trading robots ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
MQL5 (MetaQuotes Language 5) ?????????????????????????????????????????????????????????????????????????????? Expert Advisors, Custom Indicators ????????? Scripts ?????? MetaTrader 5 ??????????????????????????? automated trading ?????? Forex, Stocks, Commodities ????????? Crypto
????????????????????????????????? VPS Uptime 24/7 ???????????????????????????????????? (???????????? Forex ???????????? 24/5), Latency ????????? ???????????????????????????????????? broker server ???????????????????????? (1-5ms), ????????????????????????????????? internet/????????????????????????????????????, ????????? resource ???????????? (????????????????????????????????? PC ????????????), ????????? EA ??????????????????????????????????????????????????? VPS ???????????????
????????????????????? VPS ?????????????????? MetaTrader 5
?????????????????????????????????????????? VPS ?????????????????? trading
# === VPS Setup for MetaTrader 5 ===
# 1. ??????????????? VPS Specs ?????????????????????
cat > vps_requirements.yaml << 'EOF'
vps_specs:
minimum:
cpu: "1 vCPU"
ram: "1 GB"
storage: "20 GB SSD"
os: "Windows Server 2019/2022"
bandwidth: "Unlimited"
suitable_for: "EA 1-2 ?????????, 1 MT5 instance"
price: "$10-20/???????????????"
recommended:
cpu: "2 vCPU"
ram: "2-4 GB"
storage: "40 GB SSD"
os: "Windows Server 2022"
bandwidth: "Unlimited"
suitable_for: "EA 3-5 ?????????, 1-2 MT5 instances"
price: "$20-40/???????????????"
professional:
cpu: "4+ vCPU"
ram: "8+ GB"
storage: "80+ GB SSD"
os: "Windows Server 2022"
bandwidth: "Unlimited"
suitable_for: "EA 10+ ?????????, multiple MT5 instances, backtesting"
price: "$40-100/???????????????"
location:
description: "??????????????? VPS ???????????? broker server ??????????????????"
popular_locations:
- "New York (US brokers, Equinix NY4/NY5)"
- "London (UK/EU brokers, Equinix LD4)"
- "Tokyo (Asian brokers)"
- "Amsterdam (EU brokers)"
tip: "???????????? ping ????????? VPS ?????? broker server ????????? < 5ms"
EOF
# 2. Setup Script (Windows VPS via RDP)
cat > setup_mt5.ps1 << 'POWERSHELL'
# PowerShell Script for MT5 VPS Setup
# Disable Windows Update auto-restart
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" `
-Name "NoAutoRebootWithLoggedOnUsers" -Value 1 -Force
# Set high performance power plan
powercfg /setactive SCHEME_MIN
# Disable screen saver and sleep
powercfg /change monitor-timeout-ac 0
powercfg /change standby-timeout-ac 0
# Download MetaTrader 5
$mt5Url = "https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mt5setup.exe"
$mt5Path = "$env:TEMP\mt5setup.exe"
Invoke-WebRequest -Uri $mt5Url -OutFile $mt5Path
# Install MT5 silently
Start-Process -FilePath $mt5Path -ArgumentList "/auto" -Wait
# Create scheduled task to auto-start MT5
$action = New-ScheduledTaskAction -Execute "C:\Program Files\MetaTrader 5\terminal64.exe"
$trigger = New-ScheduledTaskTrigger -AtLogOn
$settings = New-ScheduledTaskSettingsSet -RestartCount 3 -RestartInterval (New-TimeSpan -Minutes 1)
Register-ScheduledTask -TaskName "AutoStartMT5" -Action $action -Trigger $trigger -Settings $settings
Write-Host "MT5 VPS setup complete"
POWERSHELL
# 3. Firewall rules
cat > firewall_setup.ps1 << 'POWERSHELL'
# Allow MT5 through firewall
New-NetFirewallRule -DisplayName "MetaTrader 5" `
-Direction Outbound `
-Program "C:\Program Files\MetaTrader 5\terminal64.exe" `
-Action Allow
# Allow RDP (if not already)
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
# Block unnecessary inbound
New-NetFirewallRule -DisplayName "Block All Inbound" `
-Direction Inbound -Action Block -Enabled False
POWERSHELL
echo "VPS setup scripts ready"
??????????????? Expert Advisor (EA) ???????????? MQL5
???????????????????????? EA ?????????????????? automated trading
//+------------------------------------------------------------------+
//| SimpleMA_EA.mq5 ??? Moving Average Crossover Expert Advisor |
//+------------------------------------------------------------------+
#property copyright "MyTrading"
#property version "1.00"
#property strict
// Input parameters
input int FastMA_Period = 10; // Fast MA Period
input int SlowMA_Period = 50; // Slow MA Period
input ENUM_MA_METHOD MA_Method = MODE_EMA; // MA Method
input double LotSize = 0.01; // Lot Size
input int StopLoss = 100; // Stop Loss (points)
input int TakeProfit = 200; // Take Profit (points)
input int MagicNumber = 12345; // Magic Number
input int MaxSpread = 30; // Max Spread (points)
// Global variables
int fastMA_Handle, slowMA_Handle;
double fastMA_Buffer[], slowMA_Buffer[];
//+------------------------------------------------------------------+
int OnInit()
{
// Create MA indicators
fastMA_Handle = iMA(_Symbol, PERIOD_CURRENT, FastMA_Period, 0, MA_Method, PRICE_CLOSE);
slowMA_Handle = iMA(_Symbol, PERIOD_CURRENT, SlowMA_Period, 0, MA_Method, PRICE_CLOSE);
if(fastMA_Handle == INVALID_HANDLE || slowMA_Handle == INVALID_HANDLE)
{
Print("Error creating indicators");
return INIT_FAILED;
}
ArraySetAsSeries(fastMA_Buffer, true);
ArraySetAsSeries(slowMA_Buffer, true);
Print("EA initialized: FastMA=", FastMA_Period, " SlowMA=", SlowMA_Period);
return INIT_SUCCEEDED;
}
//+------------------------------------------------------------------+
void OnTick()
{
// Check spread
double spread = SymbolInfoInteger(_Symbol, SYMBOL_SPREAD);
if(spread > MaxSpread) return;
// Get MA values
if(CopyBuffer(fastMA_Handle, 0, 0, 3, fastMA_Buffer) < 3) return;
if(CopyBuffer(slowMA_Handle, 0, 0, 3, slowMA_Buffer) < 3) return;
// Check for crossover
bool buySignal = fastMA_Buffer[1] <= slowMA_Buffer[1] && fastMA_Buffer[0] > slowMA_Buffer[0];
bool sellSignal = fastMA_Buffer[1] >= slowMA_Buffer[1] && fastMA_Buffer[0] < slowMA_Buffer[0];
// Check existing positions
int posType = GetPositionType();
if(buySignal && posType != POSITION_TYPE_BUY)
{
if(posType == POSITION_TYPE_SELL) ClosePosition();
OpenBuy();
}
else if(sellSignal && posType != POSITION_TYPE_SELL)
{
if(posType == POSITION_TYPE_BUY) ClosePosition();
OpenSell();
}
}
//+------------------------------------------------------------------+
void OpenBuy()
{
MqlTradeRequest request = {};
MqlTradeResult result = {};
double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
double point = SymbolInfoDouble(_Symbol, SYMBOL_POINT);
request.action = TRADE_ACTION_DEAL;
request.symbol = _Symbol;
request.volume = LotSize;
request.type = ORDER_TYPE_BUY;
request.price = ask;
request.sl = ask - StopLoss * point;
request.tp = ask + TakeProfit * point;
request.magic = MagicNumber;
request.comment = "MA Cross Buy";
if(!OrderSend(request, result))
Print("Buy error: ", GetLastError());
else
Print("Buy opened at ", ask, " SL=", request.sl, " TP=", request.tp);
}
//+------------------------------------------------------------------+
void OpenSell()
{
MqlTradeRequest request = {};
MqlTradeResult result = {};
double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
double point = SymbolInfoDouble(_Symbol, SYMBOL_POINT);
request.action = TRADE_ACTION_DEAL;
request.symbol = _Symbol;
request.volume = LotSize;
request.type = ORDER_TYPE_SELL;
request.price = bid;
request.sl = bid + StopLoss * point;
request.tp = bid - TakeProfit * point;
request.magic = MagicNumber;
request.comment = "MA Cross Sell";
if(!OrderSend(request, result))
Print("Sell error: ", GetLastError());
else
Print("Sell opened at ", bid, " SL=", request.sl, " TP=", request.tp);
}
//+------------------------------------------------------------------+
int GetPositionType()
{
for(int i = PositionsTotal() - 1; i >= 0; i--)
{
if(PositionGetSymbol(i) == _Symbol && PositionGetInteger(POSITION_MAGIC) == MagicNumber)
return (int)PositionGetInteger(POSITION_TYPE);
}
return -1;
}
//+------------------------------------------------------------------+
void ClosePosition()
{
for(int i = PositionsTotal() - 1; i >= 0; i--)
{
if(PositionGetSymbol(i) == _Symbol && PositionGetInteger(POSITION_MAGIC) == MagicNumber)
{
MqlTradeRequest request = {};
MqlTradeResult result = {};
request.action = TRADE_ACTION_DEAL;
request.symbol = _Symbol;
request.volume = PositionGetDouble(POSITION_VOLUME);
request.type = (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY) ? ORDER_TYPE_SELL : ORDER_TYPE_BUY;
request.price = (request.type == ORDER_TYPE_SELL) ? SymbolInfoDouble(_Symbol, SYMBOL_BID) : SymbolInfoDouble(_Symbol, SYMBOL_ASK);
request.position = PositionGetInteger(POSITION_TICKET);
OrderSend(request, result);
}
}
}
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
IndicatorRelease(fastMA_Handle);
IndicatorRelease(slowMA_Handle);
Print("EA deinitialized, reason: ", reason);
}
Optimization ????????? Performance Tuning
???????????????????????? VPS ????????? EA ????????????????????????????????????????????????
# === VPS Optimization for Trading ===
# 1. Windows Optimization Script
cat > optimize_vps.ps1 << 'POWERSHELL'
# Disable unnecessary Windows services
$servicesToDisable = @(
"WSearch", # Windows Search
"Spooler", # Print Spooler
"TabletInputService", # Touch Keyboard
"WMPNetworkSvc", # Windows Media
"DiagTrack", # Diagnostics Tracking
"SysMain" # Superfetch
)
foreach ($svc in $servicesToDisable) {
Stop-Service -Name $svc -Force -ErrorAction SilentlyContinue
Set-Service -Name $svc -StartupType Disabled -ErrorAction SilentlyContinue
Write-Host "Disabled: $svc"
}
# Set processor scheduling for background services
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\PriorityControl" `
-Name "Win32PrioritySeparation" -Value 24
# Optimize network settings
netsh int tcp set global autotuninglevel=normal
netsh int tcp set global chimney=enabled
netsh int tcp set global dca=enabled
netsh int tcp set global netdma=enabled
# Disable visual effects
$path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects"
Set-ItemProperty -Path $path -Name "VisualFXSetting" -Value 2
Write-Host "VPS optimization complete"
POWERSHELL
# 2. MT5 Optimization Settings
cat > mt5_optimization.yaml << 'EOF'
mt5_settings:
chart_settings:
max_bars_in_chart: 5000
max_bars_in_window: 500
disable_chart_shift: true
disable_auto_scroll: false
memory:
tip: "?????? max bars ???????????????????????????????????? RAM"
recommended_per_chart: 5000
disable_news: true
network:
enable_proxy: false
connection_timeout: 30
retry_interval: 5
ea_optimization:
tips:
- "????????? OnTimer() ????????? OnTick() ?????????????????? logic ?????????????????????????????? tick-by-tick"
- "Cache indicator values ????????????????????? recalculate ????????? tick"
- "????????? MagicNumber ????????? EA ????????????????????????"
- "???????????? MaxSpread ????????????????????? trade ????????? spread ???????????????"
- "Log ?????????????????????????????????????????? ?????? disk I/O"
- "????????? ArrayResize() ???????????? reserve parameter"
EOF
# 3. Latency test script
cat > latency_test.ps1 << 'POWERSHELL'
# Test latency to broker servers
$brokerServers = @(
"mt5-demo.broker.com",
"mt5-live.broker.com"
)
foreach ($server in $brokerServers) {
Write-Host "Testing: $server"
$result = Test-Connection -ComputerName $server -Count 10 -ErrorAction SilentlyContinue
if ($result) {
$avg = ($result | Measure-Object -Property ResponseTime -Average).Average
$min = ($result | Measure-Object -Property ResponseTime -Minimum).Minimum
$max = ($result | Measure-Object -Property ResponseTime -Maximum).Maximum
Write-Host " Avg: $($avg)ms, Min: $($min)ms, Max: $($max)ms"
} else {
Write-Host " UNREACHABLE"
}
}
POWERSHELL
echo "Optimization scripts ready"
????????????????????????????????? VPS Providers
????????????????????????????????? VPS providers ?????????????????? trading
#!/usr/bin/env python3
# vps_comparison.py ??? VPS Provider Comparison for Trading
import json
import logging
from typing import Dict, List
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("vps")
class VPSComparison:
def __init__(self):
pass
def providers(self):
return {
"forex_vps_specialized": {
"forexvps_net": {
"name": "ForexVPS.net",
"price": "$30-50/???????????????",
"locations": ["NY4", "LD4", "TY3"],
"latency": "1-2ms to major brokers",
"specs": "2 vCPU, 4GB RAM, 40GB SSD",
"pros": ["Ultra-low latency", "Pre-installed MT5", "24/7 support"],
"cons": ["????????????????????? general VPS", "Windows only"],
},
"beeks_financial": {
"name": "Beeks Financial Cloud",
"price": "$25-60/???????????????",
"locations": ["NY5", "LD4", "TY3", "SG1"],
"latency": "< 1ms (co-located)",
"specs": "1-4 vCPU, 1-8GB RAM",
"pros": ["Co-location with brokers", "Professional-grade", "API access"],
"cons": ["?????????????????????", "Overkill ?????????????????? retail traders"],
},
"metaquotes_vps": {
"name": "MetaQuotes VPS (built-in MT5)",
"price": "$10-15/???????????????",
"locations": ["NY", "London", "Asia"],
"latency": "< 3ms",
"specs": "Managed (????????????????????? specs)",
"pros": ["?????????????????????????????? (1-click setup)", "?????????????????????", "Integrated ????????? MT5"],
"cons": ["Customization ???????????????", "??????????????????????????? RDP ????????????", "??????????????? resources"],
},
},
"general_vps": {
"contabo": {
"name": "Contabo",
"price": "$7-15/??????????????? (Windows +$5)",
"specs": "4 vCPU, 8GB RAM, 200GB SSD",
"pros": ["?????????????????????????????? specs ?????????", "Locations ????????????????????????"],
"cons": ["Latency ????????????????????? specialized VPS", "Support ?????????"],
},
"vultr": {
"name": "Vultr",
"price": "$24-48/??????????????? (Windows)",
"specs": "2 vCPU, 4GB RAM, 80GB SSD",
"pros": ["Deploy ????????????", "Locations 32 ????????????", "API ??????"],
"cons": ["Windows license ?????????", "Latency ??????????????????????????? specialized"],
},
},
"recommendation": {
"beginner": "MetaQuotes VPS ($10-15/???????????????, ??????????????????????????????)",
"intermediate": "ForexVPS.net ($30/???????????????, low latency)",
"professional": "Beeks Financial ($50+/???????????????, co-location)",
"budget": "Contabo + Windows ($12/???????????????, ?????? specs ????????? latency ?????????????????????)",
},
}
vps = VPSComparison()
data = vps.providers()
print("VPS Providers for Trading:")
for category, providers in data.items():
if category == "recommendation":
print(f"\nRecommendation:")
for level, rec in providers.items():
print(f" {level}: {rec}")
else:
print(f"\n{category}:")
for pid, info in providers.items():
print(f" {info['name']}: {info['price']}")
print(f" Latency: {info.get('latency', 'varies')}")
Monitoring ????????? Risk Management
???????????????????????????????????????????????????????????????????????????
#!/usr/bin/env python3
# trading_monitor.py ??? Trading VPS Monitor
import json
import logging
from typing import Dict, List
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("monitor")
class TradingMonitor:
def __init__(self):
pass
def dashboard(self):
return {
"vps_status": {
"uptime": "99.97% (30 days)",
"cpu_usage": "15%",
"ram_usage": "45% (1.8GB/4GB)",
"disk_usage": "35% (14GB/40GB)",
"network_latency": "2.1ms to broker",
"mt5_status": "Running",
"ea_count": 3,
},
"trading_performance": {
"today": {"trades": 5, "profit": 45.20, "win_rate": "60%"},
"this_week": {"trades": 28, "profit": 215.80, "win_rate": "57%"},
"this_month": {"trades": 112, "profit": 890.50, "win_rate": "55%"},
"max_drawdown": "-3.2%",
"sharpe_ratio": 1.85,
},
"active_eas": [
{"name": "MA_Cross_EURUSD", "symbol": "EURUSD", "status": "running", "open_trades": 1, "profit": 12.50},
{"name": "RSI_Scalper_GBPUSD", "symbol": "GBPUSD", "status": "running", "open_trades": 0, "profit": 0},
{"name": "Grid_USDJPY", "symbol": "USDJPY", "status": "running", "open_trades": 3, "profit": -8.20},
],
"risk_alerts": [
{"level": "WARNING", "message": "Grid_USDJPY drawdown -2.5% approaching limit -3%"},
{"level": "INFO", "message": "VPS memory usage 45% (normal)"},
],
}
def risk_management_rules(self):
return {
"position_sizing": {
"rule": "Risk ????????????????????? 1-2% ????????? account ????????? trade",
"formula": "Lot Size = (Account * Risk%) / (SL_pips * Pip_value)",
"example": "Account $10,000, Risk 1%, SL 50 pips ??? Lot = (10000*0.01)/(50*10) = 0.20 lots",
},
"max_drawdown": {
"rule": "???????????? EA ??????????????? drawdown ???????????? 10%",
"action": "Auto-close all positions, notify via email/Telegram",
},
"daily_loss_limit": {
"rule": "???????????? trade ????????????????????????????????????????????? 3% ??????????????????",
"action": "Pause EA ???????????????????????????????????????",
},
"correlation": {
"rule": "????????????????????? trades ????????? correlated ????????????????????? 3 positions",
"example": "EURUSD + GBPUSD + AUDUSD = highly correlated",
},
"news_filter": {
"rule": "???????????? trade 30 ????????????????????????/???????????? high-impact news",
"source": "ForexFactory, MQL5 Economic Calendar",
},
}
monitor = TradingMonitor()
dash = monitor.dashboard()
vps = dash["vps_status"]
print(f"Trading VPS Dashboard:")
print(f" VPS: Uptime {vps['uptime']}, CPU {vps['cpu_usage']}, RAM {vps['ram_usage']}")
print(f" MT5: {vps['mt5_status']}, EAs: {vps['ea_count']}, Latency: {vps['network_latency']}")
perf = dash["trading_performance"]
print(f"\nPerformance (Month): {perf['this_month']['trades']} trades, ")
print(f" Win Rate: {perf['this_month']['win_rate']}, Drawdown: {perf['max_drawdown']}")
print(f"\nActive EAs:")
for ea in dash["active_eas"]:
print(f" {ea['name']}: {ea['status']}, Open: {ea['open_trades']}, P/L: ")
rules = monitor.risk_management_rules()
print(f"\nRisk Rules:")
for name, rule in list(rules.items())[:3]:
print(f" {name}: {rule['rule']}")
FAQ ??????????????????????????????????????????
Q: VPS ???????????? Windows ??????????????????????????????????????????????????? MT5?
A: MetaTrader 5 ???????????? Windows application ????????????????????? ????????? Windows VPS ?????????????????????????????? ?????????????????????????????????????????? Linux ????????????????????? Wine (wine mt5setup.exe) ??????????????? Linux ????????????????????????????????? (??????????????? Windows license) ????????? resource ???????????????????????? ?????????????????????????????? ????????????????????? Linux ??????????????????????????????????????????????????????????????? ????????? features ????????????????????????????????? 100% ?????????????????? MT5 ?????????????????????????????? ???????????????????????? ????????? MetaQuotes VPS (built-in MT5) ????????????????????? manage OS ????????? ????????????????????? Docker container ?????????????????? MT5 on Linux ??????????????? ?????????????????? beginner ????????? Windows VPS ????????????????????? ?????????????????? advanced ????????? Linux+Wine ?????????????????????????????? license
Q: Latency ??????????????????????????????????????????????????? trading?
A: ????????????????????? strategy Scalping (trade ???????????? 1-5 ????????????) latency ???????????????????????? ???????????? < 5ms ??????????????? co-located VPS ???????????? broker server (NY4/LD4), Day Trading (trade ????????????????????????) latency < 20ms ????????????????????? VPS ???????????????????????? US/EU ??????????????????, Swing Trading (trade ?????????????????????-?????????????????????) latency ???????????????????????? ????????? 100ms ?????????????????????????????? VPS ????????????????????????????????? ???????????????????????? retail traders ????????????????????? co-location VPS ????????????????????????????????????????????? region ???????????????????????? broker (US/EU) ????????????????????? ????????? latency ?????????????????????????????? (< 1ms) ?????????????????????????????????????????? ??????????????????????????? HFT firms
Q: EA ???????????????????????????????????????????????????????
A: EA ????????????????????????????????? Risk Management ???????????? StopLoss ????????? trade ?????????????????????????????????????????? PositionSizing ????????? risk per trade, Error Handling ?????????????????? requotes, slippage, connection loss retry logic ?????????????????? failed orders, Logging ??????????????????????????? trade reason ????????????/????????? ?????????????????? review, Spread Filter ????????? trade ??????????????? spread ??????????????????????????? threshold, News Filter ???????????? trade ???????????? high-impact news, Backtesting ???????????? backtest ??????????????????????????? 2-3 ?????? data, Forward Testing ??????????????? demo ??????????????????????????? 1-3 ???????????????????????????????????? real money, MagicNumber ????????? MagicNumber ????????? EA ???????????????????????? ???????????? ????????? Martingale (??????????????? lot ?????????????????????????????????) ????????????????????? StopLoss ???????????? trades ????????????????????????
Q: ?????????????????????????????????????????????????????????????????????????????????????
A: ?????????????????????????????????????????? VPS $10-50/??????????????? (????????????????????? specs ????????? provider), Data feed ????????? (MT5 ?????? built-in), EA ????????? (????????????????????????) ???????????? $30-500 (????????????????????? MQL5 Market), VPN (optional) $5-10/??????????????? ?????????????????? security ??????????????????????????? ????????? Budget plan $10-20/??????????????? (MetaQuotes VPS + EA ?????????), Standard plan $30-50/??????????????? (Forex VPS + EA ????????????), Professional plan $60-100+/??????????????? (Co-located VPS + premium EA + monitoring) ??????????????????????????? ????????? VPS ????????????????????????????????????????????????????????????????????????????????????????????? trading capital ??????????????? account $500 ????????????????????????????????? VPS $50/??????????????? ??????????????? capital ??????????????????????????? $2,000-5,000 ??????????????????
