💻 Setup & Environment (Windows, GoMT4 Project)¶
Audience: beginner-friendly. Comments in code are English only.
📦 1) Prerequisites¶
- Windows 10/11 recommended (Windows 7/8 may work but not tested)
- Git (https://git-scm.com/download/win)
- Go ≥ 1.21 (https://go.dev/dl/)
- VS Code + Go extension (by Google)
👉 Why: Go builds and runs the project; VS Code is the recommended IDE.
📂 2) Where the pb files live¶
- The generated protobuf stubs are published as a Go module:
git.mtapi.io/root/mrpc-proto/mt4/libraries/go
.git suffix:
import pb "git.mtapi.io/root/mrpc-proto/mt4/libraries/go"
⚙️ 3) How Go manages pb files¶
-
go mod tidywill: -
Download missing modules (including pb).
- Update
go.sumwith checksums. - It does not overwrite your code, just ensures deps exist.
go get -u→ updates to newer pb version.
📦 4) Working offline: go mod vendor¶
go mod vendor→ copies all deps intovendor/.- Project can then build offline.
- Useful for CI/CD builds without internet.
⚙️ 5) Configuration with config.json¶
Config file path:
examples/config/config.json
Example:
{
"Login": 501401178,
"Password": "v8gctta",
"Server": "RoboForex-Demo",
"DefaultSymbol": "EURUSD"
}
🔑 Use investor password for read-only unless you need trading.
▶️ 6) Project checkout & first run¶
# Clone ONLY your GoMT4 repo
cd C:\Users\malin
git clone <YOUR-GoMT4-REPO-URL> GoMT4
cd GoMT4
# Install deps
go mod tidy
# Run example (entrypoint: examples/main.go)
go run ./examples/main.go
Expected: logs + first RPC interactions.
🐞 7) VS Code debug configuration¶
File: .vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Go: Run main example",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/examples/main.go",
"cwd": "${workspaceFolder}"
}
]
}
File: .vscode/settings.json
{
"go.toolsManagement.autoUpdate": true,
"go.useLanguageServer": true,
"gopls": {
"ui.semanticTokens": true
},
"editor.formatOnSave": true
}
✅ 8) First run checklist¶
-
Start MT4 terminal manually once (initializes data).
-
Firewall: allow port if connecting externally. For local
127.0.0.1, not needed. -
Run:
cd C:\Users\malin\GoMT4
go run ./examples/main.go
- You should see logs like
listening on 127.0.0.1:50051.
⚠️ 9) Common pitfalls¶
- Timeouts / no connection → Check
config.json, firewall, MT4 connectivity. - Symbol not found (
EURUSD) → Broker may add suffix (e.g.,EURUSD.m). Ensure symbol is visible. - Volume or price rejected → Always round with
DigitsandLotStepvalues.