Skip to content

MT4Service — 1. Account Information

Account snapshot and performance statistics, with simpler arguments than the raw layer (the rarely-used fromUtc parameter is dropped). Each method delegates to the matching MT4Account call and returns the same typed …Data.

svc := mt4.NewMT4Service(acc)

AccountSummary(ctx)

func (s *MT4Service) AccountSummary(ctx context.Context) (*pb.AccountSummaryData, error)

Full account snapshot — balance, equity, leverage, currency, trade mode.

Returns — *pb.AccountSummaryData (key getters): GetAccountLogin(), GetAccountBalance(), GetAccountEquity(), GetAccountLeverage(), GetAccountCurrency(), GetAccountCredit(), GetAccountTradeMode() (see EnumAccountTradeMode).

a, err := svc.AccountSummary(ctx)
if err != nil { return err }
fmt.Printf("equity %.2f %s\n", a.GetAccountEquity(), a.GetAccountCurrency())

TradeStats(ctx, from)

func (s *MT4Service) TradeStats(ctx context.Context, from *string) (*pb.StatsData, error)

Aggregated performance statistics. from is an optional server-time string "yyyy-MM-ddTHH:mm:ss" (nil = since account start).

Returns: *pb.StatsData → GetTrades(), GetProfitFactor(), GetSharpeRatio(), drawdown getters, …

st, _ := svc.TradeStats(ctx, nil)
fmt.Printf("trades=%d PF=%.2f\n", st.GetTrades(), st.GetProfitFactor())

TradeStatsEquityHistory(ctx, from, excludeSameBars)

func (s *MT4Service) TradeStatsEquityHistory(ctx context.Context, from *string, excludeSameBars *bool) (*pb.StatsWithChartsData, error)

Stats plus equity-curve points and the trade list in one call. excludeSameBars = &true collapses consecutive equal-equity points.

excl := true
d, _ := svc.TradeStatsEquityHistory(ctx, nil, &excl)

EquityHistory(ctx, from, excludeSameBars)

func (s *MT4Service) EquityHistory(ctx context.Context, from *string, excludeSameBars *bool) (*pb.EquityHistoryData, error)

Just the equity-curve points (no stats).

Returns: *pb.EquityHistoryData → GetPoints() (each point carries time, balance, equity, realized/unrealized P/L).

eq, _ := svc.EquityHistory(ctx, nil, nil)
fmt.Println("points:", len(eq.GetPoints()))

TradeUnrealizedPL(ctx, from)

func (s *MT4Service) TradeUnrealizedPL(ctx context.Context, from *string) (*pb.TradeUnrealizedPLData, error)

Per-open-order unrealized-P/L extrema (max/min floating P/L reached and when).

upl, _ := svc.TradeUnrealizedPL(ctx, nil)

See also: MT4Service — Overview · 2. Orders & History · MT4Account overview