Files
MT5-EA-Sniper-Strategy/build.ps1
T

61 lines
2.0 KiB
PowerShell
Raw Normal View History

param(
[Parameter(Mandatory=$true)]
[string]$FilePath,
[switch]$Deploy
)
# Configuration
$MetaEditorPath = "C:\Program Files\MetaTrader 5\MetaEditor64.exe"
$MT5Directory = "C:\Users\$\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5"
Write-Host "=== MQL5 Build Script ===" -ForegroundColor Green
Write-Host "File: $FilePath" -ForegroundColor Yellow
# Check if file exists
if (-not (Test-Path $FilePath)) {
Write-Host "✗ Error: File not found: $FilePath" -ForegroundColor Red
exit 1
}
# Check if MetaEditor exists
if (-not (Test-Path $MetaEditorPath)) {
Write-Host "✗ Error: MetaEditor not found at: $MetaEditorPath" -ForegroundColor Red
exit 1
}
Write-Host "✓ Starting compilation..." -ForegroundColor Green
# Compile the file
$process = Start-Process -FilePath $MetaEditorPath -ArgumentList "/compile", "`"$FilePath`"" -Wait -PassThru -WindowStyle Hidden
if ($process.ExitCode -eq 0) {
Write-Host "✓ Compilation successful!" -ForegroundColor Green
# Check if .ex5 file was created
$ex5File = $FilePath -replace '\.mq5$', '.ex5'
if (Test-Path $ex5File) {
Write-Host "✓ Generated: $ex5File" -ForegroundColor Green
if ($Deploy) {
# Deploy to MT5 directory
$fileName = Split-Path $ex5File -Leaf
$targetPath = Join-Path $MT5Directory "Experts\$fileName"
try {
Copy-Item $ex5File $targetPath -Force
Write-Host "✓ Deployed to: $targetPath" -ForegroundColor Green
}
catch {
Write-Host "⚠ Warning: Could not deploy to MT5 directory: $_" -ForegroundColor Yellow
}
}
} else {
Write-Host "⚠ Warning: .ex5 file not found after compilation" -ForegroundColor Yellow
}
} else {
Write-Host "✗ Compilation failed with exit code: $($process.ExitCode)" -ForegroundColor Red
exit 1
}
Write-Host "=== Build Complete ===" -ForegroundColor Green