CPlugin

MT5 :: Trade Databases :: Orders

API v1 (stable) · MT5 · 12 operations · base URL https://cloud.mywebapi.com · OpenAPI v1 (JSON) · Redoc

Every call needs Authorization: Bearer $TOKEN — an OAuth 2.0 client-credentials token from https://auth.cplugin.net/connect/token (scope webapi). $TRADE_PLATFORM_ID is the id of a trade platform registered in Toolbox.

Operations

Orders (unfulfilled) by user group mask (pumping)

GET /api/MT5/{tradePlatform}/OrderGetByGroup/{mask}

Timeout: 10 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes
mask path string yes The groups for which orders are requested. You can specify one group, several groups (comma separated) or a group mask. The mask is specified using * (any value) and ! (exception). For example: demo*,!demoforex - all groups with the names beginning with 'demo', except for the group demoforex.
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 10 s (read). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Responses

Example

curl "https://cloud.mywebapi.com/api/MT5/$TRADE_PLATFORM_ID/OrderGetByGroup/$MASK" \
  -H "Authorization: Bearer $TOKEN"

Orders (unfulfilled) by user group mask and symbol (pumping)

GET /api/MT5/{tradePlatform}/OrderGetBySymbol/{mask}/{symbol}

Timeout: 10 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes
mask path string yes The groups for which orders are requested. You can specify one group, several groups (comma separated) or a group mask. The mask is specified using * (any value) and ! (exception). For example: demo*,!demoforex - all groups with the names beginning with 'demo', except for the group demoforex.
symbol path string yes The symbol for which you need to get orders. You can specify multiple symbols separated by commas.
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 10 s (read). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Responses

Example

curl "https://cloud.mywebapi.com/api/MT5/$TRADE_PLATFORM_ID/OrderGetBySymbol/$MASK/$SYMBOL" \
  -H "Authorization: Bearer $TOKEN"

Orders by user group mask

GET /api/MT5/{tradePlatform}/OrderRequestByGroup/{mask}

Timeout: 10 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes
mask path string yes The groups for which orders are requested. You can specify one group, several groups (comma separated) or a group mask. The mask is specified using * (any value) and ! (exception). For example: demo*,!demoforex - all groups with the names beginning with 'demo', except for the group demoforex.
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 10 s (read). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Responses

Example

curl "https://cloud.mywebapi.com/api/MT5/$TRADE_PLATFORM_ID/OrderRequestByGroup/$MASK" \
  -H "Authorization: Bearer $TOKEN"

Orders by user group mask and symbol

GET /api/MT5/{tradePlatform}/OrderRequestByGroupSymbol/{mask}/{symbol}

Timeout: 10 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes
mask path string yes The groups for which orders are requested. You can specify one group, several groups (comma separated) or a group mask. The mask is specified using * (any value) and ! (exception). For example: demo*,!demoforex - all groups with the names beginning with 'demo', except for the group demoforex.
symbol path string yes The symbol for which you need to get orders. You can specify multiple symbols separated by commas.
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 10 s (read). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Responses

Example

curl "https://cloud.mywebapi.com/api/MT5/$TRADE_PLATFORM_ID/OrderRequestByGroupSymbol/$MASK/$SYMBOL" \
  -H "Authorization: Bearer $TOKEN"

Delete orders from the server database in bulk

POST /api/MT5/{tradePlatform}/OrderDeleteBatch

Orders can only be deleted from the applications connected to the trade server, on which the orders have been created. For all other applications, the response code MT_RET_ERR_NOTMAIN is returned. If the object is not found, the response code MT_RET_ERR_NOTFOUND is returned.

Bulk deletion is executed faster than deletion of the same number of orders in a cycle one by one, using IMTManagerAPI::OrderDelete.The acceleration can be especially noticeable when deleting orders belonging to one account.

To improve performance, it is recommended to create arrays and perform group operations separately for each trading account.

Timeout: 5 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: The operation may still be completed by the server (X-Request-Outcome: unknown): check its result before repeating it.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 5 s (trade operation). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Request body

integer (int64)[] (application/json)

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/MT5/$TRADE_PLATFORM_ID/OrderDeleteBatch" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '[0]'

Orders history

GET /api/MT5/{tradePlatform}/HistoryRequest/{login}/{fromTime}/{toTime}

Timeout: 30 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes
login path integer (int64) yes
fromTime path string (date-time) no Default: 0.ToUnixTime64() (01.01.1970) will be used
toTime path string (date-time) no Default: UInt64.MaxValue.ToUnixTime64() will be used
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 30 s (history or report). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Responses

Example

curl "https://cloud.mywebapi.com/api/MT5/$TRADE_PLATFORM_ID/HistoryRequest/$LOGIN/$FROM_TIME/$TO_TIME" \
  -H "Authorization: Bearer $TOKEN"

Orders history by group mask

GET /api/MT5/{tradePlatform}/HistoryRequestByGroup/{mask}/{fromTime}/{toTime}

Timeout: 30 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes
mask path string yes The groups for which orders are requested. You can specify one group, several groups (comma separated) or a group mask. The mask is specified using * (any value) and ! (exception). For example: demo*,!demoforex - all groups with the names beginning with 'demo', except for the group demoforex.
fromTime path string (date-time) no Default: 0.ToUnixTime64() (01.01.1970) will be used
toTime path string (date-time) no Default: UInt64.MaxValue.ToUnixTime64() will be used
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 30 s (history or report). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Responses

Example

curl "https://cloud.mywebapi.com/api/MT5/$TRADE_PLATFORM_ID/HistoryRequestByGroup/$MASK/$FROM_TIME/$TO_TIME" \
  -H "Authorization: Bearer $TOKEN"

(Request) Orders history by list of ticket

POST /api/MT5/{tradePlatform}/HistoryRequestByTickets

Timeout: 30 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 30 s (history or report). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Request body

integer (int64)[] (application/json) — Array of orders

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/MT5/$TRADE_PLATFORM_ID/HistoryRequestByTickets" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '[0]'

Order (unfulfilled) by a ticket (pumping)

GET /api/MT5/{tradePlatform}/OrderGet/{ticket}

Timeout: 10 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes
ticket path integer (int64) yes
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 10 s (read). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Responses

Example

curl "https://cloud.mywebapi.com/api/MT5/$TRADE_PLATFORM_ID/OrderGet/$TICKET" \
  -H "Authorization: Bearer $TOKEN"

Orders (unfulfilled) by the list of logins (pumping)

GET /api/MT5/{tradePlatform}/OrderGetByLogins

Timeout: 10 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes
logins query integer (int64)[] no
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 10 s (read). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Responses

Example

curl "https://cloud.mywebapi.com/api/MT5/$TRADE_PLATFORM_ID/OrderGetByLogins" \
  -H "Authorization: Bearer $TOKEN"

Orders (unfulfilled) by the list of tickets (pumping)

GET /api/MT5/{tradePlatform}/OrderGetByTickets

Timeout: 10 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes
tickets query integer (int64)[] no
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 10 s (read). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Responses

Example

curl "https://cloud.mywebapi.com/api/MT5/$TRADE_PLATFORM_ID/OrderGetByTickets" \
  -H "Authorization: Bearer $TOKEN"

(Request) Orders by the list of tickets

POST /api/MT5/{tradePlatform}/OrderRequestByTickets

Similar to the GET version, but using request body, you can send a much longer list of ticket

Timeout: 15 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: The operation may still be completed by the server (X-Request-Outcome: unknown): check its result before repeating it.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 15 s (change). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Request body

integer (int64)[] (application/json)

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/MT5/$TRADE_PLATFORM_ID/OrderRequestByTickets" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '[0]'

Schemas

Types the operations above take and return, with their first-level properties; * marks a required one. The full graph is in the OpenAPI specification.

MT5Order

PropertyTypeDescription
order integer (int64), nullable order ticket
externalID string, nullable order ticket in external system (exchange, ECN, etc)
login integer (int64), nullable client login
dealer integer (int64), nullable processed dealer login (0-means auto)
partyID integer (int64), nullable counterparty identification
symbol string, nullable order symbol
digits integer (int32), nullable price digits
digitsCurrency integer (int32), nullable currency digits
contractSize number (double), nullable contract size
state OrderState OrderState
reason OrderReason OrderReason
timeSetup string (date-time), nullable order setup time
timeExpiration string (date-time), nullable order expiration
timeDone string (date-time), nullable order filling/cancel time
type OrderType OrderType
typeFill OrderFilling OrderFilling
typeTime OrderTime OrderTime
priceOrder number (double), nullable order price
priceTrigger number (double), nullable order trigger price (stop-limit price)
priceCurrent number (double), nullable order current price
priceSL number (double), nullable order SL
priceTP number (double), nullable order TP
volumeInitial integer (int64), nullable order initial volume
volumeCurrent integer (int64), nullable order current volume
expertID integer (int64), nullable expert id (filled by expert advisor)
positionID integer (int64), nullable position id
comment string, nullable order comment
activationMode integer (int32), nullable Has No Setter In ManagerAPI, so all you can is to read this value. order activation state, time and price
activationTime string (date-time), nullable Has No Setter In ManagerAPI, so all you can is to read this value.
activationPrice number (double), nullable Has No Setter In ManagerAPI, so all you can is to read this value. Gets the price, at which the order was activated
activationFlags TradeActivationFlags Has No Setter In ManagerAPI, so all you can is to read this value.
timeSetupMsc string (date-time), nullable Gets and sets the order placing time in milliseconds, since 1970.01.01 If the value of this field is specified, the TimeSetup value will be filled in automatically.
timeDoneMsc string (date-time), nullable Gets and sets the order execution time in milliseconds, since 1970.01.01 If the value of this field is specified, the TimeDone value will be filled in automatically.
rateMargin number (double), nullable margin conversion rate (from symbol margin currency to deposit currency)
positionByID integer (int64), nullable position by id
modificationFlags integer (int32), nullable modification flags
volumeInitialExt integer (int64), nullable order initial volume with extended accuracy
volumeCurrentExt integer (int64), nullable order current volume with extended accuracy

MT5Error

PropertyTypeDescription
errorDescription string, nullable MT5 ManagerAPI response code description.
errorCode MT5Result MT5 ManagerAPI response code
errorType MT5ResultType type of error described here
requestId string (uuid) Unique request tracking ID

MT5Result

Values: Ok, OkNone, Error, ErrParams, ErrData, ErrDisk, ErrMem, ErrNetwork, ErrPermissions, ErrTimeout, ErrConnection, ErrNoService, ErrFrequent, ErrNotfound, ErrPartial, ErrShutdown, ErrCancel, ErrDuplicate, AuthClientInvalid, AuthAccountInvalid, AuthAccountDisabled, AuthAdvanced, AuthCertificate, AuthCertificateBad, AuthNotConfirmed, AuthServerInternal, AuthServerBad, AuthUpdateOnly, AuthClientOld, AuthManagerNoConfig, AuthManagerIPBlock, AuthGroupInvalid, AuthCaDisabled, AuthInvalidID, AuthInvalidIp, AuthInvalidType, AuthServerBusy, AuthServerCert, AuthAccountUnknown, AuthServerOld, AuthServerLimit, AuthMobileDisabled, AuthManagerType, AuthDemoDisabled, AuthResetPassword, AuthOTPInvalid, AuthOTPNeedSecret, AuthMigrationMT4, AuthMigrationMT5, AuthInvalidVerify, AuthVerifyBadEmail, AuthVerifyBadPhone, AuthAPIDisabled, CfgLastAdmin, CfgLastAdminGroup, CfgNotEmpty, CfgInvalidRange, CfgNotManagerLogin, CfgBuiltin, CfgDuplicate, CfgLimitReached, CfgNoAccessToMain, CfgDealerIDExist, CfgBindAddressExist, CfgWorkingTrade, CfgGatewayNameExist, CfgSwitchToBackup, CfgNoBackupModule, CfgNoTradeModule, CfgNoHistoryModule, CfgAnotherSwitch, CfgNoLicenseFile, CfgGatewayLoginExist, CfgInvalidCompany, UsrLastAdmin, UsrLoginExhausted, UsrLoginProhibited, UsrLoginExist, UsrSuicide, UsrInvalidPassword, UsrLimitReached, UsrHasTrades, UsrDifferentServers, UsrDifferentCurrency, UsrImportBalance, UsrImportGroup, UsrAccountExist, UsrImportAccount, UsrImportPositions, UsrImportOrders, UsrImportDeals, UsrImportHistory, UsrAPILimitReached, TradeLimitReached, TradeOrderExist, TradeOrderExhausted, TradeDealExhausted, TradeMaxMoney, TradeDealExist, TradeOrderProhibited, TradeDealProhibited, TradeSplitVolume, ReportSnapshot, ReportNotSupported, ReportNodata, ReportTemplateBad, ReportTemplateEnd, ReportInvalidRow, ReportLimitRepeat, ReportLimitReport, HstSymbolNotfound, RequestInWay, RequestAccepted, RequestProcess, RequestRequote, RequestPrices, RequestReject, RequestCancel, RequestPlaced, RequestDone, RequestDonePartial, RequestError, RequestTimeout, RequestInvalid, RequestInvalidVolume, RequestInvalidPrice, RequestInvalidStops, RequestTradeDisabled, RequestMarketClosed, RequestNoMoney, RequestPriceChanged, RequestPriceOff, RequestInvalidExp, RequestOrderChanged, RequestTooMany, RequestNoChanges, RequestAtDisabledServer, RequestAtDisabledClient, RequestLocked, RequestFrozen, RequestInvalidFill, RequestConnection, RequestOnlyReal, RequestLimitOrders, RequestLimitVolume, RequestInvalidOrder, RequestPositionClosed, RequestExecutionSkipped, RequestInvalidCloseVolume, RequestCloseOrderExist, RequestLimitPositions, RequestRejectCancel, RequestLongOnly, RequestShortOnly, RequestCloseOnly, RequestProhibitedByFifo, RequestHedgeProhibited, RequestReturn, RequestDoneCancel, RequestRequoteReturn, ErrNotImplement, ErrNotMain, ErrNotSupported, ErrDeadlock, ErrLocked, MessengerInvalidPhone, MessengerNotMobile, SubsNotFound, SubsNotFoundCfg, SubsNotFoundUser, SubsDisabled, SubsPermissionUser, SubsPermissionSubscribe, SubsPermissionUnsubscribe, SubsRealOnly, SubsPaymentMethod, PayRealOnly, PayInvalidAmount, PayNotAllowedDeposit, PayNotAllowedWithdrawal, PayNotAllowedGroup, PayNotAllowedCountry, PayDeclineByRules, PayDeclineByAml, PayLimitDepositMin, PayLimitDepositMax, PayLimitWithdrawalMin, PayLimitWithdrawalMax, PayProviderPayment, PayProviderStatus, PayConversion, PayNotWaiting, PayVerification, PayInvoice, PayInvalidCurrency, PayLimitReached, PayProviderRefund, PayDeclineByCardholderName

OrderState

Values: Started, Placed, Canceled, Partial, Filled, Rejected, Expired, RequestAdd, RequestModify, RequestCancel

OrderReason

Values: Client, Expert, Dealer, SL, TP, SO, Rollover, ExternalClient, VMargin, Gateway, Signal, Settlement, Transfer, Sync, ExternalService, Migration, Mobile, Web, Split, CorporateAction

OrderType

Values: Buy, Sell, BuyLimit, SellLimit, BuyStop, SellStop, BuyStopLimit, SellStopLimit, CloseBy

OrderFilling

Values: FoK, IoC, Return, BoC

OrderTime

Values: GtC, Day, Specified, SpecifiedDay

TradeActivationFlags

Flags: names of the set bits joined by ", " ("NoLimit, NoStop"), "None" when none is set; a set bit without a name is "Bit<n>" (bit number). Bits: NoLimit = 0x1, NoStop = 0x2, NoSLimit = 0x4, NoSL = 0x8, NoTP = 0x10, NoSO = 0x20, NoExpiration = 0x40. Accepted on input, never written: All = NoLimit, NoStop, NoSLimit, NoSL, NoTP, NoSO, NoExpiration.

MT5ResultType

type of error described here

Values: HTTP, MT4API, MT5API