๐งพ ConfigExample (GoMT4)¶
Goal: show the minimal config.json used by this repo and how itโs consumed by the examples.
Real files:
- Config file:
examples/config/config.json- Config loader:
examples/config/config.go(reads JSON into a struct)- Used by:
examples/main.go
๐ Location¶
examples/config/config.json
This file is read at startup by the example app.
๐งฉ Schema (what fields mean)¶
{
"Login": 501401178,
"Password": "v8gctta",
"Server": "RoboForex-Demo",
"DefaultSymbol": "EURUSD"
}
- Login (number) โ MT4 account login.
- Password (string) โ investor or trade password. For demos, prefer investor (readโonly).
- Server (string) โ exact broker server name (e.g.,
RoboForex-Demo). - DefaultSymbol (string) โ instrument to use by default (must match brokerโs name; suffixes like
EURUSD.mare different symbols).
๐ ๏ธ Edit & run¶
- Open
examples/config/config.jsonand fill your values. - Launch the example:
cd GoMT4
go mod tidy
go run ./examples/main.go
If config is valid and MT4 is connected, youโll see logs from the example service.
๐ Validation (quick checks)¶
- Login is numeric, password nonโempty.
- Server name exactly matches MT4 (check in terminal login dialog).
DefaultSymbolexists and is visible in Market Watch (Show All).
Minimal runtime probe (uses real calls):
sum, err := account.AccountSummary(ctx)
if err != nil { return err }
_, err = account.Quote(ctx, cfg.DefaultSymbol)
if err != nil { return err }
๐ Security notes¶
config.jsonin this repo is meant for local development.- Do not commit real trading credentials to a public repo. Use demo creds or keep the repo private.
- If you need secrets isolation, migrate to environment variables or an external secret store (optional; not required by this project).
โ ๏ธ Common errors¶
symbol not foundโ wrong/hidden symbol; check suffix (EURUSD.m) and Show All in Market Watch.invalid login/password/serverโ verify values against MT4 login dialog.- Timeouts on first run โ start MT4 manually once so it initializes data; then retry.
๐ See also¶
EnsureSymbolVisible.mdโ make sureDefaultSymbolis available.AccountSummary.mdโ quick health snapshot after config is loaded.GetQuote.mdโ confirm quotes for the default symbol.