MT5Account Β· Additional Methods - OverviewΒΆ
Advanced symbol information, trading sessions, margin rates, batch operations. Use this page to choose the right API for advanced queries.
π What lives hereΒΆ
Advanced Symbol InformationΒΆ
- SymbolInfoMarginRate - margin rates for symbol and order type.
- SymbolInfoSessionQuote - quote session times.
- SymbolInfoSessionTrade - trade session times.
- SymbolParamsMany - detailed parameters for multiple symbols (112 fields!).
- TickValueWithSize - tick value and size information for symbols.
π Step-by-step tutorialsΒΆ
Want detailed explanations with line-by-line code breakdown? Check these guides:
- SymbolInfoMarginRate - How it works
- SymbolInfoSessionQuote - How it works
- SymbolInfoSessionTrade - How it works
- SymbolParamsMany - How it works
- TickValueWithSize - How it works
π§ Plain EnglishΒΆ
- SymbolInfoMarginRate β get margin multiplier for different order types.
- SymbolInfoSessionQuote β get quote session times (when quotes are available).
- SymbolInfoSessionTrade β get trading session times (when trading is allowed).
- SymbolParamsMany β get complete symbol specifications for multiple symbols in one call (most efficient).
- TickValueWithSize β get tick value and contract size for position value and P&L calculations.
Rule of thumb: need session times β use Session methods; need complete symbol data β use
SymbolParamsMany; need margin rates β useSymbolInfoMarginRate; need tick value/P&L data β useTickValueWithSize.
Quick chooseΒΆ
| If you need⦠| Use | Returns | Key inputs |
|---|---|---|---|
| Margin rates for order type | SymbolInfoMarginRate |
MarginRates | Symbol, order type |
| Quote session times | SymbolInfoSessionQuote |
SessionInfo | Symbol, day of week, session index |
| Trading session times | SymbolInfoSessionTrade |
SessionInfo | Symbol, day of week, session index |
| Complete specs for multiple symbols | SymbolParamsMany |
Array of SymbolParams | Symbol list, optional filters |
| Tick value and size for P&L calculations | TickValueWithSize |
TickSizeSymbol array | Symbol names array |
β Crossβrefs & gotchasΒΆ
- SymbolParamsMany - THE MOST EFFICIENT way to get complete symbol data (112 fields per symbol).
- Session times - In seconds from day start (0-86400).
- Day of week - SUNDAY=0, MONDAY=1, ..., SATURDAY=6.
- Session index - Most symbols have 1 session, some have multiple (e.g., 24h = 1 session, day+night = 2 sessions).
- Margin rates - Different rates for BUY/SELL, LONG/SHORT positions.
- SymbolParamsMany filters - Can filter by Bid, Ask, Point, Volume to reduce data size.
- Batch operations - SymbolParamsMany can query 100+ symbols in one call.
π’ Minimal snippetsΒΆ
// Get margin rates for symbol
rates, err := account.SymbolInfoMarginRate(ctx, &pb.SymbolInfoMarginRateRequest{
Symbol: "EURUSD",
OrderType: pb.ENUM_ORDER_TYPE_ORDER_TYPE_BUY,
})
if err != nil {
log.Fatalf("Failed: %v", err)
}
fmt.Printf("EURUSD BUY margin rates:\n")
fmt.Printf(" Initial: %.2f\n", rates.InitialMarginRate)
fmt.Printf(" Maintenance: %.2f\n", rates.MaintenanceMarginRate)
// Get trading session times for Monday
sessionInfo, _ := account.SymbolInfoSessionTrade(ctx, &pb.SymbolInfoSessionTradeRequest{
Symbol: "EURUSD",
DayOfWeek: 1, // Monday
SessionIndex: 0,
})
fromTime := sessionInfo.From.AsTime()
toTime := sessionInfo.To.AsTime()
fromSeconds := fromTime.Hour()*3600 + fromTime.Minute()*60 + fromTime.Second()
toSeconds := toTime.Hour()*3600 + toTime.Minute()*60 + toTime.Second()
fmt.Printf("EURUSD Monday trading session:\n")
fmt.Printf(" From: %d seconds (%.2f hours)\n",
fromSeconds, float64(fromSeconds)/3600)
fmt.Printf(" To: %d seconds (%.2f hours)\n",
toSeconds, float64(toSeconds)/3600)
// Get complete symbol parameters for multiple symbols
symbols := []string{"EURUSD", "GBPUSD", "USDJPY"}
params, err := account.SymbolParamsMany(ctx, &pb.SymbolParamsManyRequest{
Symbols: symbols,
})
if err != nil {
log.Fatalf("Failed: %v", err)
}
for _, symbolParam := range params.SymbolParams {
fmt.Printf("\n%s:\n", symbolParam.Name)
fmt.Printf(" Bid: %.5f, Ask: %.5f\n", symbolParam.Bid, symbolParam.Ask)
fmt.Printf(" Digits: %d, Point: %.5f\n", symbolParam.Digits, symbolParam.Point)
fmt.Printf(" Volume: %.2f - %.2f (step: %.2f)\n",
symbolParam.VolumeMin, symbolParam.VolumeMax, symbolParam.VolumeStep)
fmt.Printf(" Contract size: %.0f\n", symbolParam.TradeContractSize)
fmt.Printf(" Spread: %d points\n", symbolParam.Spread)
}
// Get all trading sessions for a week
symbol := "EURUSD"
days := []int32{1, 2, 3, 4, 5} // Monday through Friday
dayNames := []string{"Monday", "Tuesday", "Wednesday", "Thursday", "Friday"}
fmt.Printf("%s Trading Schedule:\n", symbol)
fmt.Println("βββββββββββββββββββββββββββββββββββββ")
for i, day := range days {
session, err := account.SymbolInfoSessionTrade(ctx, &pb.SymbolInfoSessionTradeRequest{
Symbol: symbol,
DayOfWeek: day,
SessionIndex: 0,
})
if err != nil {
continue
}
fromTime := session.From.AsTime()
toTime := session.To.AsTime()
fromHours := float64(fromTime.Hour()*3600 + fromTime.Minute()*60 + fromTime.Second()) / 3600
toHours := float64(toTime.Hour()*3600 + toTime.Minute()*60 + toTime.Second()) / 3600
fmt.Printf("%s: %.2f:00 - %.2f:00\n",
dayNames[i], fromHours, toHours)
}
// Batch query all forex majors with SymbolParamsMany
majors := []string{
"EURUSD", "GBPUSD", "USDJPY", "USDCHF",
"AUDUSD", "USDCAD", "NZDUSD",
}
params, _ := account.SymbolParamsMany(ctx, &pb.SymbolParamsManyRequest{
Symbols: majors,
})
fmt.Println("Forex Majors Summary:")
fmt.Println("βββββββββββββββββββββββββββββββββββββββββββββββββββββ")
fmt.Printf("%-8s %-10s %-10s %-8s\n", "Symbol", "Bid", "Ask", "Spread")
fmt.Println("βββββββββββββββββββββββββββββββββββββββββββββββββββββ")
for _, sp := range params.SymbolParams {
fmt.Printf("%-8s %-10.5f %-10.5f %-8d\n",
sp.Name, sp.Bid, sp.Ask, sp.Spread)
}
See alsoΒΆ
- Basic symbol info: SymbolInfoTick - get current prices
- Symbol properties: SymbolInfoDouble - get single property
- Trading: OrderCalcMargin - uses margin rates internally