Skip to content

TickValueWithSize

Tick value, tick size and contract size for one or more symbols โ€” the money-math inputs for risk sizing.

API Information:

  • Low-level API: MT4Account.TickValueWithSize(ctx, symbolNames) (defined in mt4/MT4Account.go)
  • gRPC service: mt4_term_api.AccountHelper
  • RPC: TickValueWithSize(TickValueWithSizeRequest) โ†’ TickValueWithSizeReply
  • Payload: TickValueWithSizeData โ†’ GetInfos() โ†’ SymbolTickValueWithSizeInfo

๐Ÿ’ฌ Just the essentials

  • What it is. The per-symbol tick value / tick size / contract size โ€” a focused subset of SymbolParams.
  • Why you need it. Convert a pip distance into money for position sizing.
  • When to use. Risk calculators, exposure/value math.

๐ŸŽฏ Purpose

  • Read tick value (money per tick per lot)
  • Read tick size (price per tick)
  • Read contract size
  • Compute pip value โ†’ size a lot by cash risk

Method Signature

func (a *MT4Account) TickValueWithSize(ctx context.Context, symbolNames []string) (*pb.TickValueWithSizeData, error)

Request message:

message TickValueWithSizeRequest { repeated string symbol_names = 1; }

Payload message:

message TickValueWithSizeData { repeated SymbolTickValueWithSizeInfo infos = 1; }

message SymbolTickValueWithSizeInfo {
  int32  index = ...;
  string symbol_name = ...;
  double trade_tick_value = ...;
  double trade_tick_size = ...;
  double trade_contract_size = ...;
}

๐Ÿ”ฝ Input

Parameter Type Required Description
ctx context.Context yes Cancellation / timeout.
symbolNames []string yes Symbols to describe, e.g. []string{"EURUSD"}.

โฌ†๏ธ Output โ€” *pb.TickValueWithSizeData

GetInfos() returns []*pb.SymbolTickValueWithSizeInfo:

Field Proto Type Go getter Description
symbol_name string GetSymbolName() string Symbol
trade_tick_value double GetTradeTickValue() float64 Money value of one tick per lot
trade_tick_size double GetTradeTickSize() float64 Price size of one tick
trade_contract_size double GetTradeContractSize() float64 Contract size
index int32 GetIndex() int32 Server index

On failure the call returns a non-nil error (text "API error (code=โ€ฆ): โ€ฆ") โ€” see the Return Codes Reference.


๐Ÿงฉ Notes & Tips

  • Pip value per lot โ‰ˆ GetTradeTickValue() ร— (pipSize / GetTradeTickSize()).
  • Lighter than SymbolParams if money math is all you need โ€” but SymbolParams already includes these.
  • Match by GetSymbolName(), not slice index.

๐Ÿ”— Usage Examples

1) Print the money-math inputs

func tickInfo(ctx context.Context, acc *mt4.MT4Account, symbols []string) error {
    d, err := acc.TickValueWithSize(ctx, symbols)
    if err != nil { return err }
    for _, i := range d.GetInfos() {
        fmt.Printf("%-8s tickVal=%.5f tickSize=%.5f contract=%.0f\n",
            i.GetSymbolName(), i.GetTradeTickValue(), i.GetTradeTickSize(), i.GetTradeContractSize())
    }
    return nil
}

2) Pip value per lot

func pipValue(ctx context.Context, acc *mt4.MT4Account, symbol string, pipSize float64) (float64, error) {
    d, err := acc.TickValueWithSize(ctx, []string{symbol})
    if err != nil { return 0, err }
    for _, i := range d.GetInfos() {
        if i.GetSymbolName() == symbol && i.GetTradeTickSize() > 0 {
            return i.GetTradeTickValue() * (pipSize / i.GetTradeTickSize()), nil
        }
    }
    return 0, fmt.Errorf("no tick info for %s", symbol)
}

3) Lot for a cash risk over a stop

func lotForRisk(ctx context.Context, acc *mt4.MT4Account, symbol string, pipSize, riskCash, slPips float64) (float64, error) {
    pv, err := pipValue(ctx, acc, symbol, pipSize)
    if err != nil || pv <= 0 || slPips <= 0 { return 0, err }
    return riskCash / (slPips * pv), nil
}

โš ๏ธ Pitfalls

  • Divide-by-zero. Guard GetTradeTickSize() > 0 before dividing.
  • Missing symbols. Unknown names may be omitted โ€” match by name.
  • Still normalize the resulting lot with SymbolParams's volume step.

๐Ÿงช Testing Suggestions

  • Happy path (demo). For a liquid FX symbol, GetTradeTickValue() > 0 and GetTradeTickSize() > 0.
  • Pip value. pipValue is positive and matches the figure derived from SymbolParams.
  • Risk lot. lotForRisk scales inversely with slPips.

๐Ÿ“š See also