Profiles (profiles.json
)¶
What it Does¶
Profiles act as connection presets for MT5 accounts.
Each entry in profiles.json
stores credentials and server details, so you donβt have to type them every time.
Structure π¶
Typical profiles.json
:
{
"default": {
"ServerName": "MetaQuotes-Demo",
"Host": "mt5.mrpc.pro",
"Port": 443,
"Login": 21455,
"Password": "demo-pass"
},
"live": {
"ServerName": "MyBroker-Live",
"Host": "live.broker.com",
"Port": 443,
"Login": 123456,
"Password": "super-secret"
}
}
default
β fallback profile (used if you donβt specify--profile
).live
β second profile for a real account.
Input Parameters β¬οΈ¶
When you run commands (info
, quote
, buy
, sell
, etc.):
Parameter | Description | Example |
---|---|---|
--profile |
Name of the profile from profiles.json . |
--profile default |
use-pf |
PowerShell shortcut for switching profiles. | use-pf live |
Why Profiles β¶
- Convenience: No need to retype login/password/server each time.
- Safety: Store creds in one file (never hardcode them in scripts).
- Flexibility: Switch instantly between demo/live environments.
- Automation: CI/CD pipelines can swap profiles without touching code.
How to Use π οΈ¶
CLI¶
dotnet run -- info --profile default
dotnet run -- quote --profile live --symbol EURUSD
PowerShell Shortcuts¶
. .\ps\shortcasts.ps1
use-pf default # selects default profile
info # runs with that profile
use-pf live # instantly switch
info # now runs on live account
Code Reference π§©¶
// Validate and select profile
Validators.EnsureProfile(profile);
_selectedProfile = profile;
// later used in ConnectAsync()
await ConnectAsync();
π In short:
β profiles.json
= your connection catalog.
β --profile
or use-pf
= the switch.
β In code always via Validators.EnsureProfile
β _selectedProfile
.