openapi: 3.1.0
info:
  title: MetaPortAPI for MetaTrader 5
  version: 2.1.0
  description: 'Local REST API served by the MetaPortAPI Expert Advisor inside MetaTrader 5.


    Every reply carries `ERROR_ID` (0 = success) and `ERROR_DESCRIPTION`. Streams are delivered over WebSocket at `ws://127.0.0.1:81`
    and on the legacy TCP port 78.'
  contact:
    name: MetaPortAPI support
    url: https://www.metaportapi.com/support/
servers:
- url: http://127.0.0.1:81
  description: EA on this computer (default port)
tags:
- name: Market data
- name: Trading
- name: Account & terminal
- name: Indicators
- name: Streaming
paths:
  /v1/quote:
    get:
      tags:
      - Market data
      summary: Quote
      description: Current bid/ask of a symbol. The symbol is added to Market Watch if needed.
      operationId: Quote
      parameters:
      - &id001
        name: symbol
        in: query
        required: true
        description: Symbol name as your broker spells it
        schema:
          type: string
        example: EURUSD
      responses:
        '200':
          description: Reply (check ERROR_ID)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Quote'
  /v1/symbol/list:
    get:
      tags:
      - Market data
      summary: Symbol list
      description: Every symbol offered by the broker.
      operationId: SymbolList
      parameters: []
      responses:
        '200':
          description: Reply (check ERROR_ID)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SymbolList'
  /v1/symbol/info:
    get:
      tags:
      - Market data
      summary: Symbol information
      description: Full specification of a symbol, including quote and trade sessions.
      operationId: SymbolInfo
      parameters:
      - *id001
      responses:
        '200':
          description: Reply (check ERROR_ID)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SymbolInfo'
  /v1/history/prices:
    get:
      tags:
      - Market data
      summary: Price history
      description: OHLC candles between two dates. If MT5 is still downloading history an error is returned — ask again.
      operationId: PriceHistory
      parameters:
      - *id001
      - &id006
        name: timeframe
        in: query
        required: true
        description: Timeframe
        schema:
          $ref: '#/components/schemas/Timeframe'
        example: PERIOD_H1
      - &id002
        name: from_date
        in: query
        required: true
        description: Start date, server time (YYYY.MM.DD HH:MI:SS)
        schema:
          type: string
        example: 2026.10.01 00:00:00
      - &id003
        name: to_date
        in: query
        required: true
        description: End date, server time (YYYY.MM.DD HH:MI:SS)
        schema:
          type: string
        example: 2026.10.28 23:59:59
      responses:
        '200':
          description: Reply (check ERROR_ID)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PriceHistory'
  /v1/history/ticks:
    get:
      tags:
      - Market data
      summary: Tick history
      description: Ticks between two dates.
      operationId: TickHistory
      parameters:
      - *id001
      - name: flags
        in: query
        required: true
        description: Which ticks to return
        schema:
          $ref: '#/components/schemas/TickFlags'
        example: COPY_TICKS_ALL
      - *id002
      - *id003
      responses:
        '200':
          description: Reply (check ERROR_ID)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TickHistory'
  /v1/calendar:
    get:
      tags:
      - Market data
      summary: Economic calendar
      description: Calendar events between two dates, optionally filtered.
      operationId: Calendar
      parameters:
      - *id002
      - *id003
      - name: currency
        in: query
        required: false
        description: Currency code
        schema:
          type: string
        example: USD
      - name: country_code
        in: query
        required: false
        description: ISO 3166-1 alpha-2 country code
        schema:
          type: string
        example: US
      responses:
        '200':
          description: Reply (check ERROR_ID)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Calendar'
  /v1/order:
    post:
      tags:
      - Trading
      summary: Send order
      description: Market or pending order. PRICE is required for pending orders; EXPIRATION must be at least a few minutes
        in the future (server time).
      operationId: OrderSend
      parameters:
      - *id001
      - name: volume
        in: query
        required: true
        description: Lots
        schema:
          type: number
          format: double
        example: 0.01
      - name: type
        in: query
        required: true
        description: Order type
        schema:
          $ref: '#/components/schemas/OrderType'
        example: ORDER_TYPE_BUY
      - name: price
        in: query
        required: false
        description: Price for limit/stop orders
        schema:
          type: number
          format: double
      - name: sl
        in: query
        required: false
        description: Stop loss
        schema:
          type: number
          format: double
      - name: tp
        in: query
        required: false
        description: Take profit
        schema:
          type: number
          format: double
      - name: slippage
        in: query
        required: false
        description: Max deviation in points (default 10)
        schema:
          type: integer
      - name: comment
        in: query
        required: false
        description: Order comment
        schema:
          type: string
      - name: magic
        in: query
        required: false
        description: Magic number
        schema:
          type: integer
      - name: expiration
        in: query
        required: false
        description: Pending order expiry (YYYY.MM.DD HH:MI)
        schema:
          type: string
      - name: type_filling
        in: query
        required: false
        description: Filling mode (auto if omitted)
        schema:
          $ref: '#/components/schemas/TypeFilling'
      - &id004
        name: async
        in: query
        required: false
        description: Send asynchronously (do not wait for the trade server)
        schema:
          type: boolean
      responses:
        '200':
          description: Reply (check ERROR_ID)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderSend'
  /v1/order/modify:
    post:
      tags:
      - Trading
      summary: Modify order
      description: Change SL/TP of an open position, or price/SL/TP/expiration of a pending order.
      operationId: OrderModify
      parameters:
      - &id005
        name: ticket
        in: query
        required: true
        description: Order or position ticket
        schema:
          type: integer
          format: int64
        example: 3262274114
      - name: price
        in: query
        required: false
        description: New price (pending orders)
        schema:
          type: number
          format: double
      - name: sl
        in: query
        required: false
        description: New stop loss
        schema:
          type: number
          format: double
      - name: tp
        in: query
        required: false
        description: New take profit
        schema:
          type: number
          format: double
      - name: expiration
        in: query
        required: false
        description: New expiry (pending orders)
        schema:
          type: string
      - *id004
      responses:
        '200':
          description: Reply (check ERROR_ID)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderModify'
  /v1/order/close:
    post:
      tags:
      - Trading
      summary: Close order
      description: Close a position fully or partially, or delete a pending order.
      operationId: OrderClose
      parameters:
      - *id005
      - name: volume
        in: query
        required: false
        description: Lots to close (partial close); omit to close all
        schema:
          type: number
          format: double
      - name: price
        in: query
        required: false
        description: Close price
        schema:
          type: number
          format: double
      - name: slippage
        in: query
        required: false
        description: Max deviation in points
        schema:
          type: integer
      - *id004
      responses:
        '200':
          description: Reply (check ERROR_ID)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderClose'
  /v1/order/list:
    get:
      tags:
      - Trading
      summary: Order list
      description: Open positions and pending orders.
      operationId: OrderList
      parameters: []
      responses:
        '200':
          description: Reply (check ERROR_ID)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderList'
  /v1/order/info:
    get:
      tags:
      - Trading
      summary: Order information
      description: One open position or pending order.
      operationId: OrderInfo
      parameters:
      - *id005
      responses:
        '200':
          description: Reply (check ERROR_ID)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderInfo'
  /v1/history/orders:
    get:
      tags:
      - Trading
      summary: Trade history
      description: Closed positions, deals, orders, or orders with their deals.
      operationId: TradeHistory
      parameters:
      - *id002
      - *id003
      - name: mode
        in: query
        required: true
        description: What to return
        schema:
          $ref: '#/components/schemas/HistoryMode'
        example: POSITIONS
      responses:
        '200':
          description: Reply (check ERROR_ID)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TradeHistory'
  /v1/account:
    get:
      tags:
      - Account & terminal
      summary: Account information
      description: Balance, equity, margin and permissions of the logged-in account.
      operationId: AccountStatus
      parameters: []
      responses:
        '200':
          description: Reply (check ERROR_ID)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountStatus'
  /v1/license:
    get:
      tags:
      - Account & terminal
      summary: License information
      description: Active MetaPortAPI plan and its limits. Without a paid license, live accounts get ERROR_ID 9001; Free sessions
        end after 7 hours with ERROR_ID 9002.
      operationId: LicenseInfo
      parameters: []
      responses:
        '200':
          description: Reply (check ERROR_ID)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LicenseInfo'
  /v1/terminal:
    get:
      tags:
      - Account & terminal
      summary: Terminal information
      description: Build, paths, connection and resources of the MT5 terminal.
      operationId: TerminalInfo
      parameters: []
      responses:
        '200':
          description: Reply (check ERROR_ID)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TerminalInfo'
  /v1/indicator/ma:
    get:
      tags:
      - Indicators
      summary: Moving average
      description: Moving average values, newest first.
      operationId: MovingAverage
      parameters:
      - *id001
      - *id006
      - name: ma_period
        in: query
        required: true
        description: Averaging period
        schema:
          type: integer
        example: 21
      - name: ma_shift
        in: query
        required: true
        description: Horizontal shift
        schema:
          type: integer
        example: 0
      - name: ma_method
        in: query
        required: true
        description: MODE_SMA, MODE_EMA, MODE_SMMA or MODE_LWMA
        schema:
          type: string
          enum:
          - MODE_SMA
          - MODE_EMA
          - MODE_SMMA
          - MODE_LWMA
        example: MODE_EMA
      - name: applied_price
        in: query
        required: true
        description: Applied price
        schema:
          type: string
          enum:
          - PRICE_CLOSE
          - PRICE_OPEN
          - PRICE_HIGH
          - PRICE_LOW
          - PRICE_MEDIAN
          - PRICE_TYPICAL
          - PRICE_WEIGHTED
        example: PRICE_CLOSE
      - name: num
        in: query
        required: false
        description: How many values (default 1)
        schema:
          type: integer
        example: 1
      responses:
        '200':
          description: Reply (check ERROR_ID)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MovingAverage'
  /v1/indicator/atr:
    get:
      tags:
      - Indicators
      summary: Average true range
      description: ATR value at a bar shift.
      operationId: AverageTrueRange
      parameters:
      - *id001
      - *id006
      - name: period
        in: query
        required: true
        description: ATR period
        schema:
          type: integer
        example: 14
      - name: shift
        in: query
        required: true
        description: Bar index (0 = current)
        schema:
          type: integer
        example: 0
      responses:
        '200':
          description: Reply (check ERROR_ID)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AverageTrueRange'
  /v1/indicator/custom:
    get:
      tags:
      - Indicators
      summary: Custom indicator
      description: Values of any indicator in MQL5\Indicators. Parameters may be numbers, true/false, enum names (e.g. PRICE_CLOSE)
        or strings.
      operationId: CustomIndicator
      parameters:
      - *id001
      - *id006
      - name: indicator_name
        in: query
        required: true
        description: Path under MQL5\Indicators
        schema:
          type: string
        example: Examples\OsMA
      - name: param1
        in: query
        required: false
        description: Parameter 1
        schema:
          type: string
        example: '12'
      - name: param2
        in: query
        required: false
        description: Parameter 2
        schema:
          type: string
        example: '26'
      - name: param3
        in: query
        required: false
        description: Parameter 3
        schema:
          type: string
        example: '9'
      - name: param4
        in: query
        required: false
        description: Parameter 4
        schema:
          type: string
        example: PRICE_CLOSE
      - name: num
        in: query
        required: false
        description: How many values
        schema:
          type: integer
        example: 1
      - name: index
        in: query
        required: false
        description: Indicator buffer index
        schema:
          type: integer
        example: 0
      responses:
        '200':
          description: Reply (check ERROR_ID)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomIndicator'
  /v1/track/prices:
    post:
      tags:
      - Streaming
      summary: Track prices
      description: Start (or stop, with an empty list) streaming ticks to WebSocket clients on ws://127.0.0.1:81 and to TCP
        78.
      operationId: TrackPrices
      parameters:
      - &id007
        name: symbols
        in: query
        required: false
        description: Comma-separated symbols. Empty = stop streaming.
        schema:
          type: string
        example: EURUSD,XAUUSD
      responses:
        '200':
          description: Reply (check ERROR_ID)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TrackPrices'
  /v1/track/ohlc:
    post:
      tags:
      - Streaming
      summary: Track OHLC
      description: Stream the latest DEPTH bars every time the current bar changes. Send an empty OHLC array to stop.
      operationId: TrackOHLC
      parameters: []
      responses:
        '200':
          description: Reply (check ERROR_ID)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TrackOHLC'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TrackOHLCRequest'
  /v1/track/mbook:
    post:
      tags:
      - Streaming
      summary: Track depth of market
      description: Stream market depth (if the broker provides it).
      operationId: TrackMBOOK
      parameters:
      - *id007
      responses:
        '200':
          description: Reply (check ERROR_ID)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TrackMBOOK'
  /v1/track/orders:
    post:
      tags:
      - Streaming
      summary: Track trade events
      description: Stream every trade transaction (order added, filled, modified, SL/TP hit…).
      operationId: TrackTradeEvents
      parameters:
      - name: enabled
        in: query
        required: false
        description: true to start, false to stop; omit to read the state
        schema:
          type: boolean
        example: true
      responses:
        '200':
          description: Reply (check ERROR_ID)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TrackTradeEvents'
components:
  schemas:
    Timeframe:
      type: string
      enum:
      - PERIOD_M1
      - PERIOD_M2
      - PERIOD_M3
      - PERIOD_M4
      - PERIOD_M5
      - PERIOD_M6
      - PERIOD_M10
      - PERIOD_M12
      - PERIOD_M15
      - PERIOD_M20
      - PERIOD_M30
      - PERIOD_H1
      - PERIOD_H2
      - PERIOD_H3
      - PERIOD_H4
      - PERIOD_H6
      - PERIOD_H8
      - PERIOD_H12
      - PERIOD_D1
      - PERIOD_W1
      - PERIOD_MN1
    OrderType:
      type: string
      enum:
      - ORDER_TYPE_BUY
      - ORDER_TYPE_SELL
      - ORDER_TYPE_BUY_LIMIT
      - ORDER_TYPE_SELL_LIMIT
      - ORDER_TYPE_BUY_STOP
      - ORDER_TYPE_SELL_STOP
    TypeFilling:
      type: string
      enum:
      - ORDER_FILLING_FOK
      - ORDER_FILLING_IOC
      - ORDER_FILLING_BOC
      - ORDER_FILLING_RETURN
    HistoryMode:
      type: string
      enum:
      - POSITIONS
      - DEALS
      - ORDERS
      - ORDERS_DEALS
    TickFlags:
      type: string
      enum:
      - COPY_TICKS_ALL
      - COPY_TICKS_INFO
      - COPY_TICKS_TRADE
    Error:
      type: object
      properties:
        MSG:
          type: string
        ERROR_ID:
          type: integer
        ERROR_DESCRIPTION:
          type: string
      example:
        MSG: QUOTE
        ERROR_ID: 4301
        ERROR_DESCRIPTION: Unknown symbol
    Quote:
      type: object
      properties:
        MSG:
          type: string
        SYMBOL:
          type: string
        ASK:
          type: number
        BID:
          type: number
        FLAGS:
          type: integer
        TIME:
          type: string
        VOLUME:
          type: integer
        ERROR_ID:
          type: integer
        ERROR_DESCRIPTION:
          type: string
      example:
        MSG: QUOTE
        SYMBOL: EURUSD
        ASK: 1.11214
        BID: 1.11208
        FLAGS: 6
        TIME: 2026.10.28 08:04:55.523
        VOLUME: 0
        ERROR_ID: 0
        ERROR_DESCRIPTION: The operation completed successfully
    OrderSend:
      type: object
      properties:
        MSG:
          type: string
        TYPE:
          type: string
        RETCODE:
          type: integer
        DEAL:
          type: integer
        ORDER:
          type: integer
        VOLUME:
          type: number
        PRICE:
          type: number
        BID:
          type: number
        ASK:
          type: number
        REQUEST_ID:
          type: integer
        RETCODE_EXTERNAL:
          type: integer
        ERROR_ID:
          type: integer
        ERROR_DESCRIPTION:
          type: string
      example:
        MSG: ORDER_SEND
        TYPE: ORDER_TYPE_BUY
        RETCODE: 10009
        DEAL: 3223069202
        ORDER: 3262274114
        VOLUME: 0.05
        PRICE: 4047.716
        BID: 4047.548
        ASK: 4047.716
        REQUEST_ID: 651348425
        RETCODE_EXTERNAL: 0
        ERROR_ID: 0
        ERROR_DESCRIPTION: The operation completed successfully
    OrderModify:
      type: object
      properties:
        MSG:
          type: string
        TICKET:
          type: integer
        TYPE:
          type: string
        RETCODE:
          type: integer
        DEAL:
          type: integer
        ORDER:
          type: integer
        VOLUME:
          type: number
        PRICE:
          type: number
        BID:
          type: number
        ASK:
          type: number
        REQUEST_ID:
          type: integer
        RETCODE_EXTERNAL:
          type: integer
        ERROR_ID:
          type: integer
        ERROR_DESCRIPTION:
          type: string
      example:
        MSG: ORDER_MODIFY
        TICKET: 3262274114
        TYPE: SL_UPDATED
        RETCODE: 10009
        DEAL: 0
        ORDER: 0
        VOLUME: 0
        PRICE: 0
        BID: 0
        ASK: 0
        REQUEST_ID: 651348436
        RETCODE_EXTERNAL: 0
        ERROR_ID: 0
        ERROR_DESCRIPTION: The operation completed successfully
    OrderClose:
      type: object
      properties:
        MSG:
          type: string
        TICKET:
          type: integer
        TYPE:
          type: string
          enum:
          - FULLY_CLOSED
          - PARTIALLY_CLOSED
        RETCODE:
          type: integer
        DEAL:
          type: integer
        ORDER:
          type: integer
        VOLUME:
          type: number
        PRICE:
          type: number
        BID:
          type: number
        ASK:
          type: number
        REQUEST_ID:
          type: integer
        RETCODE_EXTERNAL:
          type: integer
        ERROR_ID:
          type: integer
        ERROR_DESCRIPTION:
          type: string
      example:
        MSG: ORDER_CLOSE
        TICKET: 3262274114
        TYPE: FULLY_CLOSED
        RETCODE: 10009
        DEAL: 3228142867
        ORDER: 3267331998
        VOLUME: 0.05
        PRICE: 4049.1
        BID: 4049.1
        ASK: 4049.27
        REQUEST_ID: 651348438
        RETCODE_EXTERNAL: 0
        ERROR_ID: 0
        ERROR_DESCRIPTION: The operation completed successfully
    OpenedOrder:
      type: object
      properties:
        TICKET: &id008
          type: integer
        OPEN_TIME: &id009
          type: string
        TIME_UPDATE: &id010
          type: string
        TYPE: &id011
          type: string
        MAGIC: &id012
          type: integer
        IDENTIFIER: &id013
          type: integer
        REASON: &id014
          type: integer
        VOLUME: &id015
          type: number
        PRICE_OPEN: &id016
          type: number
        SL: &id017
          type: number
        TP: &id018
          type: number
        PRICE_CURRENT: &id019
          type: number
        SWAP: &id020
          type: number
        PROFIT: &id021
          type: number
        SYMBOL: &id022
          type: string
        COMMENT: &id023
          type:
          - string
          - 'null'
        EXTERNAL_ID: &id024
          type:
          - string
          - 'null'
        CHANGE: &id025
          type: number
      example: &id026
        TICKET: 3262274114
        OPEN_TIME: 2026.10.28 08:10:02.415
        TIME_UPDATE: 2026.10.28 08:10:02.415
        TYPE: ORDER_TYPE_BUY
        MAGIC: 0
        IDENTIFIER: 3262274114
        REASON: 3
        VOLUME: 0.05
        PRICE_OPEN: 4047.716
        SL: 0
        TP: 0
        PRICE_CURRENT: 4049.102
        SWAP: 0
        PROFIT: 6.93
        SYMBOL: XAUUSD
        COMMENT: null
        EXTERNAL_ID: null
        CHANGE: 0.03
    PendingOrder:
      type: object
      properties:
        TICKET: *id008
        OPEN_TIME: *id009
        TIME_UPDATE: *id010
        TYPE: *id011
        MAGIC: *id012
        IDENTIFIER: *id013
        REASON: *id014
        VOLUME: *id015
        PRICE_OPEN: *id016
        SL: *id017
        TP: *id018
        PRICE_CURRENT: *id019
        SWAP: *id020
        PROFIT: *id021
        SYMBOL: *id022
        COMMENT: *id023
        EXTERNAL_ID: *id024
        CHANGE: *id025
        TIME_DONE:
          type: string
        TIME_SETUP:
          type: string
        ORDER_REASON:
          type: integer
        POSITION_ID:
          type: integer
        POSITION_BYID:
          type: integer
        VOLUME_INITIAL:
          type: number
        VOLUME_CURRENT:
          type: number
        PRICE_STOPLIMIT:
          type: number
      example: &id027
        TICKET: 3262280001
        OPEN_TIME: 2026.10.28 08:10:02.415
        TIME_UPDATE: 2026.10.28 08:10:02.415
        TYPE: ORDER_TYPE_BUY_LIMIT
        MAGIC: 0
        IDENTIFIER: 3262280001
        REASON: 3
        VOLUME: 0.05
        PRICE_OPEN: 4030
        SL: 0
        TP: 0
        PRICE_CURRENT: 4049.102
        SWAP: 0
        PROFIT: 0
        SYMBOL: XAUUSD
        COMMENT: null
        EXTERNAL_ID: null
        CHANGE: 0.47
        TIME_DONE: 1970.01.01 00:00:00.0
        TIME_SETUP: 2026.10.28 08:12:40.120
        ORDER_REASON: 3
        POSITION_ID: 0
        POSITION_BYID: 0
        VOLUME_INITIAL: 0.05
        VOLUME_CURRENT: 0.05
        PRICE_STOPLIMIT: 0
    OrderList:
      type: object
      properties:
        MSG:
          type: string
        COUNT:
          type: integer
        OPENED:
          type: array
          items:
            $ref: '#/components/schemas/OpenedOrder'
        PENDING:
          type: array
          items:
            $ref: '#/components/schemas/PendingOrder'
        ERROR_ID:
          type: integer
        ERROR_DESCRIPTION:
          type: string
      example:
        MSG: ORDER_LIST
        COUNT: 2
        OPENED:
        - *id026
        PENDING:
        - *id027
        ERROR_ID: 0
        ERROR_DESCRIPTION: The operation completed successfully
    OrderInfo:
      type: object
      properties:
        MSG:
          type: string
        OPENED:
          type: array
          items:
            $ref: '#/components/schemas/OpenedOrder'
        PENDING:
          type: array
          items:
            $ref: '#/components/schemas/PendingOrder'
        ERROR_ID:
          type: integer
        ERROR_DESCRIPTION:
          type: string
      example:
        MSG: ORDER_INFO
        OPENED:
        - *id026
        PENDING: []
        ERROR_ID: 0
        ERROR_DESCRIPTION: The operation completed successfully
    AccountStatus:
      type: object
      properties:
        MSG:
          type: string
        COMPANY:
          type: string
        CURRENCY:
          type: string
        NAME:
          type: string
        SERVER:
          type: string
        LOGIN:
          type: integer
        TRADE_MODE:
          type: integer
        LEVERAGE:
          type: integer
        LIMIT_ORDERS:
          type: integer
        MARGIN_SO_MODE:
          type: integer
        TRADE_ALLOWED:
          type: integer
        TRADE_EXPERT:
          type: integer
        MARGIN_MODE:
          type: integer
        CURRENCY_DIGITS:
          type: integer
        FIFO_CLOSE:
          type: integer
        HEDGE_ALLOWED:
          type: integer
        BALANCE:
          type: number
        CREDIT:
          type: number
        PROFIT:
          type: number
        EQUITY:
          type: number
        MARGIN:
          type: number
        MARGIN_FREE:
          type: number
        MARGIN_LEVEL:
          type: number
        MARGIN_SO_CAL:
          type: number
        MARGIN_SO_SO:
          type: number
        ERROR_ID:
          type: integer
        ERROR_DESCRIPTION:
          type: string
      example:
        MSG: ACCOUNT_STATUS
        COMPANY: Example Broker Ltd.
        CURRENCY: USD
        NAME: Demo User
        SERVER: ExampleBroker-Demo
        LOGIN: 12345678
        TRADE_MODE: 0
        LEVERAGE: 500
        LIMIT_ORDERS: 500
        MARGIN_SO_MODE: 0
        TRADE_ALLOWED: 1
        TRADE_EXPERT: 1
        MARGIN_MODE: 2
        CURRENCY_DIGITS: 2
        FIFO_CLOSE: 0
        HEDGE_ALLOWED: 1
        BALANCE: 10000
        CREDIT: 0
        PROFIT: 6.93
        EQUITY: 10006.93
        MARGIN: 40.48
        MARGIN_FREE: 9966.45
        MARGIN_LEVEL: 24720.67
        MARGIN_SO_CAL: 100
        MARGIN_SO_SO: 50
        ERROR_ID: 0
        ERROR_DESCRIPTION: The operation completed successfully
    SymbolList:
      type: object
      properties:
        MSG:
          type: string
        SYMBOLS:
          type: array
          items:
            type: object
            properties:
              NAME:
                type: string
              TRADE_MODE:
                type: integer
              DESCRIPTION:
                type: string
              PATH:
                type: string
            example:
              NAME: EURUSD
              TRADE_MODE: 4
              DESCRIPTION: Euro vs US Dollar
              PATH: Forex\EURUSD
        ERROR_ID:
          type: integer
        ERROR_DESCRIPTION:
          type: string
      example:
        MSG: SYMBOL_LIST
        SYMBOLS:
        - NAME: EURUSD
          TRADE_MODE: 4
          DESCRIPTION: Euro vs US Dollar
          PATH: Forex\EURUSD
        - NAME: XAUUSD
          TRADE_MODE: 4
          DESCRIPTION: Gold vs US Dollar
          PATH: Metals\XAUUSD
        ERROR_ID: 0
        ERROR_DESCRIPTION: The operation completed successfully
    SymbolInfo:
      type: object
      properties:
        MSG:
          type: string
        NAME:
          type: string
        TIME:
          type: string
        DIGITS:
          type: number
        SPREAD_FLOAT:
          type: number
        SPREAD:
          type: number
        TRADE_CALC_MODE:
          type: number
        TRADE_MODE:
          type: number
        START_TIME:
          type: number
        EXPIRATION_TIME:
          type: number
        TRADE_STOPS_LEVEL:
          type: number
        TRADE_FREEZE_LEVEL:
          type: number
        TRADE_EXEMODE:
          type: number
        SWAP_MODE:
          type: number
        SWAP_ROLLOVER3DAYS:
          type: number
        POINT:
          type: number
        TRADE_TICK_VALUE:
          type: number
        TRADE_TICK_VALUE_PROFIT:
          type: number
        TRADE_TICK_VALUE_LOSS:
          type: number
        TRADE_TICK_SIZE:
          type: number
        TRADE_CONTRACT_SIZE:
          type: number
        VOLUME_MIN:
          type: number
        VOLUME_MAX:
          type: number
        VOLUME_STEP:
          type: number
        VOLUME_LIMIT:
          type: number
        SWAP_LONG:
          type: number
        SWAP_SHORT:
          type: number
        MARGIN_INITIAL:
          type: number
        MARGIN_MAINTENANCE:
          type: number
        CURRENCY_BASE:
          type: string
        CURRENCY_PROFIT:
          type: string
        CURRENCY_MARGIN:
          type: string
        DESCRIPTION:
          type: string
        PATH:
          type: string
        SESSION_QUOTE: &id028
          type: array
          items:
            type: object
            additionalProperties:
              type: string
        SESSION_TRADE: *id028
        ERROR_ID:
          type: integer
        ERROR_DESCRIPTION:
          type: string
      example:
        MSG: SYMBOL_INFO
        NAME: XAUUSD
        TIME: 2026.10.28 08:05:01
        DIGITS: 3
        SPREAD_FLOAT: 1
        SPREAD: 168
        TRADE_CALC_MODE: 2
        TRADE_MODE: 4
        START_TIME: 0
        EXPIRATION_TIME: 0
        TRADE_STOPS_LEVEL: 0
        TRADE_FREEZE_LEVEL: 0
        TRADE_EXEMODE: 2
        SWAP_MODE: 1
        SWAP_ROLLOVER3DAYS: 3
        POINT: 0.001
        TRADE_TICK_VALUE: 0.1
        TRADE_TICK_VALUE_PROFIT: 0.1
        TRADE_TICK_VALUE_LOSS: 0.1
        TRADE_TICK_SIZE: 0.001
        TRADE_CONTRACT_SIZE: 100
        VOLUME_MIN: 0.01
        VOLUME_MAX: 100
        VOLUME_STEP: 0.01
        VOLUME_LIMIT: 0
        SWAP_LONG: -45.2
        SWAP_SHORT: 18.6
        MARGIN_INITIAL: 0
        MARGIN_MAINTENANCE: 0
        CURRENCY_BASE: XAU
        CURRENCY_PROFIT: USD
        CURRENCY_MARGIN: XAU
        DESCRIPTION: Gold vs US Dollar
        PATH: Metals\XAUUSD
        SESSION_QUOTE: &id029
        - MONDAY: 00:05-23:55
        - TUESDAY: 00:05-23:55
        - WEDNESDAY: 00:05-23:55
        - THURSDAY: 00:05-23:55
        - FRIDAY: 00:05-23:55
        SESSION_TRADE: *id029
        ERROR_ID: 0
        ERROR_DESCRIPTION: The operation completed successfully
    TerminalInfo:
      type: object
      properties:
        MSG:
          type: string
        LANGUAGE:
          type: string
        COMPANY:
          type: string
        NAME:
          type: string
        PATH:
          type: string
        DATA_PATH:
          type: string
        COMMONDATA_PATH:
          type: string
        BUILD:
          type: integer
        COMMUNITY_ACCOUNT:
          type: integer
        COMMUNITY_CONNECTION:
          type: integer
        CONNECTED:
          type: integer
        DLLS_ALLOWED:
          type: integer
        TRADE_ALLOWED:
          type: integer
        EMAIL_ENABLED:
          type: integer
        FTP_ENABLED:
          type: integer
        NOTIFICATIONS_ENABLED:
          type: integer
        MAXBARS:
          type: integer
        MQID:
          type: integer
        CODEPAGE:
          type: integer
        CPU_CORES:
          type: integer
        DISK_SPACE:
          type: integer
        MEMORY_PHYSICAL:
          type: integer
        MEMORY_TOTAL:
          type: integer
        MEMORY_AVAILABLE:
          type: integer
        MEMORY_USED:
          type: integer
        SCREEN_DPI:
          type: integer
        PING_LAST:
          type: integer
        ERROR_ID:
          type: integer
        ERROR_DESCRIPTION:
          type: string
      example:
        MSG: TERMINAL_INFO
        LANGUAGE: English
        COMPANY: Example Broker Ltd.
        NAME: MetaTrader 5
        PATH: C:\Program Files\MetaTrader 5
        DATA_PATH: C:\Users\you\AppData\Roaming\MetaQuotes\Terminal\0123456789ABCDEF
        COMMONDATA_PATH: C:\Users\you\AppData\Roaming\MetaQuotes\Terminal\Common
        BUILD: 5100
        COMMUNITY_ACCOUNT: 0
        COMMUNITY_CONNECTION: 0
        CONNECTED: 1
        DLLS_ALLOWED: 1
        TRADE_ALLOWED: 1
        EMAIL_ENABLED: 0
        FTP_ENABLED: 0
        NOTIFICATIONS_ENABLED: 0
        MAXBARS: 100000
        MQID: 0
        CODEPAGE: 1252
        CPU_CORES: 8
        DISK_SPACE: 210000
        MEMORY_PHYSICAL: 16000
        MEMORY_TOTAL: 32000
        MEMORY_AVAILABLE: 31200
        MEMORY_USED: 800
        SCREEN_DPI: 96
        PING_LAST: 42000
        ERROR_ID: 0
        ERROR_DESCRIPTION: The operation completed successfully
    TradeHistory:
      type: object
      properties:
        MSG:
          type: string
        MODE:
          type: string
        POSITIONS:
          type: array
          items:
            type: object
            properties:
              OPEN_TIME:
                type: string
              SYMBOL:
                type: string
              TICKET:
                type: integer
              TYPE:
                type: string
              VOLUME:
                type: number
              PRICE_OPEN:
                type: number
              MAGIC:
                type: integer
              COMMENT:
                type:
                - string
                - 'null'
              CLOSE_TIME:
                type: string
              PRICE_CLOSE:
                type: number
              PROFIT:
                type: number
              COMMISSION:
                type: number
              SWAP:
                type: number
              SL:
                type: number
              TP:
                type: number
              CHANGE:
                type: number
            example: &id030
              OPEN_TIME: 2026.10.27 15:40:39.45
              SYMBOL: EURUSD
              TICKET: 3253135542
              TYPE: BUY
              VOLUME: 0.01
              PRICE_OPEN: 1.11038
              MAGIC: 0
              COMMENT: null
              CLOSE_TIME: 2026.10.27 15:45:05.891
              PRICE_CLOSE: 1.11023
              PROFIT: -0.15
              COMMISSION: 0
              SWAP: 0
              SL: 0
              TP: 0
              CHANGE: -0.01
        DEALS:
          type: array
          items:
            type: object
            properties:
              TIME:
                type: string
              DEAL:
                type: integer
              SYMBOL:
                type: string
              ORDER:
                type: integer
              POSITION:
                type: integer
              TYPE:
                type: string
              REASON:
                type: string
              DIRECTION:
                type: string
              PRICE:
                type: number
              VOLUME:
                type: number
              SL:
                type: number
              TP:
                type: number
              MAGIC:
                type: integer
              SWAP:
                type: number
              COMMENT:
                type:
                - string
                - 'null'
              COMMISSION:
                type: number
              PROFIT:
                type: number
        ORDERS:
          type: array
          items:
            type: object
            properties:
              TIME_SETUP:
                type: string
              SYMBOL:
                type: string
              TICKET:
                type: integer
              TYPE:
                type: string
              VOLUME_INITIAL:
                type: number
              VOLUME_CURRENT:
                type: number
              PRICE:
                type: number
              MAGIC:
                type: integer
              COMMENT:
                type:
                - string
                - 'null'
              SL:
                type: number
              TP:
                type: number
              STATE:
                type: string
              TIME_DONE:
                type: string
              POSITION:
                type: integer
        ORDERS_DEALS:
          type: array
          items:
            type: object
            properties:
              TIME:
                type: string
              TICKET:
                type: integer
              SYMBOL:
                type: string
              TYPE:
                type: string
              VOLUME:
                type: number
              PRICE:
                type: number
              MAGIC:
                type: integer
              COMMENT:
                type:
                - string
                - 'null'
              DEALS:
                type: array
                items:
                  type: object
                  properties:
                    TIME:
                      type: string
                    TICKET:
                      type: integer
                    TYPE:
                      type: string
                    REASON:
                      type: string
                    VOLUME:
                      type: number
                    PRICE:
                      type: number
                    COMMISSION:
                      type: number
                    PROFIT:
                      type: number
                    MAGIC:
                      type: integer
                    SWAP:
                      type: number
                    COMMENT:
                      type:
                      - string
                      - 'null'
        ERROR_ID:
          type: integer
        ERROR_DESCRIPTION:
          type: string
      example:
        MSG: TRADE_HISTORY
        MODE: POSITIONS
        POSITIONS:
        - *id030
        ERROR_ID: 0
        ERROR_DESCRIPTION: The operation completed successfully
      description: Only the array named by MODE is present.
    PriceHistory:
      type: object
      properties:
        MSG:
          type: string
        SYMBOL:
          type: string
        TIMEFRAME:
          type: string
        RATES:
          type: array
          items:
            type: object
            properties:
              TIME:
                type: string
              OPEN:
                type: number
              HIGH:
                type: number
              LOW:
                type: number
              CLOSE:
                type: number
              REAL_VOLUME:
                type: number
              TICK_VOLUME:
                type: number
              SPREAD:
                type: number
        ERROR_ID:
          type: integer
        ERROR_DESCRIPTION:
          type: string
      example:
        MSG: PRICE_HISTORY
        SYMBOL: EURUSD
        TIMEFRAME: PERIOD_D1
        RATES:
        - TIME: 2026.10.27 00:00:00
          OPEN: 1.10953
          HIGH: 1.11258
          LOW: 1.10899
          CLOSE: 1.11138
          REAL_VOLUME: 0
          TICK_VOLUME: 15957
          SPREAD: 0
        ERROR_ID: 0
        ERROR_DESCRIPTION: The operation completed successfully
    TickHistory:
      type: object
      properties:
        MSG:
          type: string
        SYMBOL:
          type: string
        TICKS:
          type: array
          items:
            type: object
            properties:
              TIME:
                type: string
              TIME_MSC:
                type: string
              ASK:
                type: number
              BID:
                type: number
              FLAGS:
                type: integer
              LAST:
                type: number
              VOLUME:
                type: integer
              VOLUME_REAL:
                type: number
        ERROR_ID:
          type: integer
        ERROR_DESCRIPTION:
          type: string
      example:
        MSG: TICK_HISTORY
        SYMBOL: EURUSD
        TICKS:
        - TIME: 2026.10.28 08:05:00
          TIME_MSC: 2026.10.28 08:05:00.117
          ASK: 1.11216
          BID: 1.1121
          FLAGS: 6
          LAST: 0
          VOLUME: 0
          VOLUME_REAL: 0
        ERROR_ID: 0
        ERROR_DESCRIPTION: The operation completed successfully
    Calendar:
      type: object
      properties:
        MSG:
          type: string
        EVENTS:
          type: array
          description: '*_VALUE fields are present only when MT5 has the value'
          items:
            type: object
            properties:
              TIME:
                type: string
              EVENT_COUNTRY_ID:
                type: integer
              EVENT_DIGITS:
                type: integer
              EVENT_CODE:
                type: string
              EVENT_FREQUENCY:
                type: string
              EVENT_ID:
                type: integer
              EVENT_IMPORTANCE:
                type: string
              EVENT_MULTIPLIER:
                type: string
              EVENT_NAME:
                type: string
              EVENT_SECTOR:
                type: string
              EVENT_SOURCE_URL:
                type: string
              EVENT_TIME_MODE:
                type: string
              EVENT_TYPE:
                type: string
              EVENT_UNIT:
                type: string
              ACTUAL_VALUE:
                type: number
              FORECAST_VALUE:
                type: number
              PREVIOUS_VALUE:
                type: number
              REVISED_VALUE:
                type: number
              IMPACT_TYPE:
                type: string
              REVISION:
                type: integer
              PERIOD:
                type: string
        ERROR_ID:
          type: integer
        ERROR_DESCRIPTION:
          type: string
      example:
        MSG: CALENDAR_LIST
        EVENTS:
        - TIME: 2026.10.17 15:30:00
          EVENT_COUNTRY_ID: 840
          EVENT_DIGITS: 3
          EVENT_CODE: housing-starts
          EVENT_FREQUENCY: CALENDAR_FREQUENCY_MONTH
          EVENT_ID: 840020004
          EVENT_IMPORTANCE: CALENDAR_IMPORTANCE_MODERATE
          EVENT_MULTIPLIER: CALENDAR_MULTIPLIER_MILLIONS
          EVENT_NAME: Housing Starts
          EVENT_SECTOR: CALENDAR_SECTOR_HOUSING
          EVENT_SOURCE_URL: https://www.census.gov
          EVENT_TIME_MODE: CALENDAR_TIMEMODE_DATETIME
          EVENT_TYPE: CALENDAR_TYPE_INDICATOR
          EVENT_UNIT: CALENDAR_UNIT_NONE
          ACTUAL_VALUE: 1.499
          FORECAST_VALUE: 1.313
          PREVIOUS_VALUE: 1.289
          IMPACT_TYPE: CALENDAR_IMPACT_POSITIVE
          REVISION: 0
          PERIOD: 2026.09.01 00:00:00
        ERROR_ID: 0
        ERROR_DESCRIPTION: The operation completed successfully
    MovingAverage:
      type: object
      properties:
        MSG:
          type: string
        DATA_VALUES:
          type: array
          items:
            type:
            - number
            - 'null'
          description: Newest value first
        ERROR_ID:
          type: integer
        ERROR_DESCRIPTION:
          type: string
      example:
        MSG: MA_INDICATOR
        DATA_VALUES:
        - 1.11182
        - 1.11176
        ERROR_ID: 0
        ERROR_DESCRIPTION: The operation completed successfully
    AverageTrueRange:
      type: object
      properties:
        MSG:
          type: string
        DATA_VALUES:
          type: array
          items:
            type:
            - number
            - 'null'
          description: Newest value first
        ERROR_ID:
          type: integer
        ERROR_DESCRIPTION:
          type: string
      example:
        MSG: ATR_INDICATOR
        DATA_VALUES:
        - 0.00837
        ERROR_ID: 0
        ERROR_DESCRIPTION: The operation completed successfully
    CustomIndicator:
      type: object
      properties:
        MSG:
          type: string
        DATA_VALUES:
          type: array
          items:
            type:
            - number
            - 'null'
          description: Newest value first
        ERROR_ID:
          type: integer
        ERROR_DESCRIPTION:
          type: string
      example:
        MSG: CUSTOM_INDICATOR
        DATA_VALUES:
        - 0.0002985
        ERROR_ID: 0
        ERROR_DESCRIPTION: The operation completed successfully
    TrackPrices:
      type: object
      properties:
        MSG:
          type: string
        SUCCESS:
          type: array
          items:
            type: string
          description: Symbols now being streamed
        ERROR_ID:
          type: integer
        ERROR_DESCRIPTION:
          type: string
      example:
        MSG: TRACK_PRICES
        SUCCESS:
        - EURUSD
        - XAUUSD
        ERROR_ID: 0
        ERROR_DESCRIPTION: The operation completed successfully
    TrackOHLC:
      type: object
      properties:
        MSG:
          type: string
        SUCCESS:
          type: array
          items:
            type: string
          description: Symbols now being streamed
        ERROR_ID:
          type: integer
        ERROR_DESCRIPTION:
          type: string
      example:
        MSG: TRACK_OHLC
        SUCCESS:
        - EURUSD
        - XAUUSD
        ERROR_ID: 0
        ERROR_DESCRIPTION: The operation completed successfully
    TrackMBOOK:
      type: object
      properties:
        MSG:
          type: string
        SUCCESS:
          type: array
          items:
            type: string
          description: Symbols now being streamed
        ERROR_ID:
          type: integer
        ERROR_DESCRIPTION:
          type: string
      example:
        MSG: TRACK_MBOOK
        SUCCESS:
        - EURUSD
        - XAUUSD
        ERROR_ID: 0
        ERROR_DESCRIPTION: The operation completed successfully
    TrackTradeEvents:
      type: object
      properties:
        MSG:
          type: string
        ENABLED:
          type: boolean
        ERROR_ID:
          type: integer
        ERROR_DESCRIPTION:
          type: string
      example:
        MSG: TRACK_TRADE_EVENTS
        ENABLED: true
        ERROR_ID: 0
        ERROR_DESCRIPTION: The operation completed successfully
    LicenseInfo:
      type: object
      properties:
        MSG:
          type: string
        PLAN:
          type: string
          enum:
          - FREE
          - RETAIL
          - PROFESSIONAL
          - UNLIMITED
        STATUS:
          type: string
        LICENSED_TO:
          type:
          - string
          - 'null'
        LICENSE_LOGIN:
          type:
          - string
          - 'null'
        EXPIRES:
          type:
          - string
          - 'null'
        ACCOUNT:
          type: integer
        DEMO_ACCOUNT:
          type: boolean
        LIVE_ALLOWED:
          type: boolean
        REMOTE_ALLOWED:
          type: boolean
        SESSION_SECONDS_LEFT:
          type:
          - integer
          - 'null'
          description: 'Free plan only: seconds left in this 7-hour session'
        ERROR_ID:
          type: integer
        ERROR_DESCRIPTION:
          type: string
      example:
        MSG: LICENSE_INFO
        PLAN: PROFESSIONAL
        STATUS: PROFESSIONAL license for account 12345678, valid until 2027.10.28
        LICENSED_TO: Your Name
        LICENSE_LOGIN: '12345678'
        EXPIRES: 2027.10.28
        ACCOUNT: 12345678
        DEMO_ACCOUNT: false
        LIVE_ALLOWED: true
        REMOTE_ALLOWED: true
        SESSION_SECONDS_LEFT: null
        ERROR_ID: 0
        ERROR_DESCRIPTION: The operation completed successfully
    TrackOHLCRequest:
      type: object
      required:
      - OHLC
      properties:
        OHLC:
          type: array
          items:
            type: object
            required:
            - TIMEFRAME
            - SYMBOL
            properties:
              TIMEFRAME:
                $ref: '#/components/schemas/Timeframe'
              SYMBOL:
                type: string
              DEPTH:
                type: integer
                default: 1
                minimum: 1
      example:
        OHLC:
        - TIMEFRAME: PERIOD_M1
          SYMBOL: EURUSD
          DEPTH: 2
        - TIMEFRAME: PERIOD_H1
          SYMBOL: XAUUSD
          DEPTH: 1
