CSharpMT5 CLI β Shortcasts & Live Examples π¶
βοΈ General launch pattern (PowerShell / CMD):
dotnet run -- <command> [options]
π Global Options¶
Option | Meaning | Notes | |
---|---|---|---|
-p, --profile <name> |
Profile from profiles.json (default: default ) |
Switch accounts quickly | |
-s, --symbol <SYM> |
Instrument/ticker, e.g., EURUSD |
Default taken from profile | |
-v, --volume <lots> |
Order volume in lots | ||
--deviation <pts> |
Max slippage in points | ||
`-o, --output text | json` | Output format | text or json (machine-friendly) |
--timeout-ms <ms> |
Per-RPC timeout (default: 30000 ) |
Avoids hangs | |
--dry-run |
Donβt send anything, just show what would be done | Great for testing | |
--verbose / --trace |
Extended logging | Debug / trace everything |
π‘ Tip: set password via environment variable MT5_PASSWORD
instead of hardcoding in files.
π Command Reference (Shortcasts)¶
Format: command β aliases β what it does
π€ Profiles¶
profiles list
βls
β list profile namesprofiles show
βview
β show profile parameters (usesMT5_PASSWORD
)
π General / Info¶
info
βi
β account summaryquote
βq
β one-shot spot quote (Bid/Ask/Time)health
βping
β connectivity diagnosticsstream
βst
β tick/event stream (auto-reconnect)
πΉ Market Orders¶
buy
βb
β market buysell
βs
β market sell
π Closing / Reversing¶
close
βc
β close by ticket (exact/normalized volume)close.percent
βcpp
β close by percentclose.half
βch
β close half (50%)close.partial
βcp
β close exact volumeclose-all
βflatten
β close all open positionsclose-symbol
βcs
β close all positions for a symbolreverse
βrv
β reverse net position (--mode net|flat
)reverse.ticket
βrvt
β reverse a specific ticket
π― SL/TP & Safety¶
position.modify
βposmod
β set SL/TP by priceposition.modify.points
βpmp
β set SL/TP by pointsbreakeven
βbe
β move SL to breakeven Β± offsettrail.start
β start a local trailing stoptrail.stop
β stop trailing
π Pending Orders¶
place
βpl
β place pending (limit/stop/stop-limit)pending.modify
βpm
β change pending paramspending.move
βpmove
β shift price(s) by Β±N ptspending list
βls
β list pending ticketscancel
βx
β delete pending by ticketcancel.all
βca
β delete all pendings (with filters)
π Tickets / Symbols / Lists¶
ticket show
βtsh
β show info for a ticket (open/recent)positions
βpos
β active positionsorders
βord
β open orders + positions ticketssymbol ensure
βen
β make symbol visiblesymbol limits
βlim
β lot min/step/maxsymbol show
βsh
β symbol card (quote + limits)
π History / Tools¶
history
βh
β orders/deals history for N dayshistory.export
βhexport
β export history (CSV/JSON)lot.calc
βlc
β lot size from risk% & SL ptspanic
β close all + cancel all pendings
π Quick Start¶
# Profiles
dotnet run -- profiles list
dotnet run -- profiles show -p demo
# Connectivity
dotnet run -- health -p demo
# One quote
dotnet run -- q -p demo -s EURUSD
π Practical Scenarios¶
1οΈβ£ Open & Manage Position¶
dotnet run -- buy -p demo -s EURUSD -v 0.10 --sl 1.0700 --tp 1.0800 --deviation 10
dotnet run -- breakeven -p demo -t 123456 --offset-points 2
dotnet run -- position.modify.points -p demo -t 123456 --sl-points 150 --tp-points 250
dotnet run -- trail.start -p demo -t 123456 --distance 150 --step 20
dotnet run -- trail.stop -p demo -t 123456
2οΈβ£ Partial Close & Reverse¶
dotnet run -- close.half -p demo -t 123456
dotnet run -- close.percent -p demo -t 123456 --pct 30
dotnet run -- close.partial -p demo -t 123456 --volume 0.05
dotnet run -- reverse -p demo -s EURUSD --mode net --sl 1.0700 --tp 1.0850
dotnet run -- reverse.ticket -p demo -t 123456 --sl 1.0700 --tp 1.0850
3οΈβ£ Pendings¶
dotnet run -- place -p demo --type buylimit -s EURUSD --price 1.0750 --sl 1.0700 --tp 1.0800
dotnet run -- pending.modify -p demo -t 778899 --price 1.0765 --sl 1.0745
dotnet run -- pending.move -p demo -t 778899 --by-points 15
dotnet run -- pending list -p demo
dotnet run -- cancel -p demo -t 778899 -s EURUSD
dotnet run -- cancel.all -p demo --symbol EURUSD
4οΈβ£ Lists & Symbols¶
dotnet run -- positions -p demo -o json
dotnet run -- orders -p demo
dotnet run -- symbol show -p demo -s EURUSD
dotnet run -- symbol ensure -p demo -s GBPUSD
dotnet run -- symbol limits -p demo -s USDJPY
5οΈβ£ Tickets & History¶
dotnet run -- ticket show -p demo -t 123456 --days 30
dotnet run -- history -p demo -d 7
dotnet run -- history.export -p demo -d 30 --to csv --file C:\temp\hist.csv
6οΈβ£ Risk & Panic¶
dotnet run -- lot.calc -s EURUSD --risk-pct 1 --sl-points 150 --balance 1000
dotnet run -- panic -p demo
π Debugging & Tips¶
- Profile not found: check
profiles.json
placement - Hidden symbol: run
symbol ensure
- Timeouts: bump
--timeout-ms
or add--trace