CPlugin

MT5 :: Trade Activity :: Dealing

API v1 (stable) · MT5 · 3 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

Send trade request

POST /api/MT5/{tradePlatform}/DealerSend

Send trade request on behalf of dealer. Only dealer actions (200-255) can be set as a request type in Action (Dealer* etc).

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 Trade platform id
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

MT5Request (application/json) — Request

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/MT5/$TRADE_PLATFORM_ID/DealerSend" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "login": 0, "symbol": "", "action": "Price", "type": "Buy", "volume": 0, "priceOrder": 0 }'

Send balance request

POST /api/MT5/{tradePlatform}/DealerBalance

Send balance request

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 Trade platform id
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

DealerBalanceRequest (application/json) — Request

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/MT5/$TRADE_PLATFORM_ID/DealerBalance" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "login": 0, "value": 0, "type": "Buy", "comment": "" }'

Send raw balance request (bypasses validation)

POST /api/MT5/{tradePlatform}/DealerBalanceRaw

Send balance request without standard credit/margin validation checks. Use for administrative corrections.

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 Trade platform id
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

DealerBalanceRequest (application/json) — Request

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/MT5/$TRADE_PLATFORM_ID/DealerBalanceRaw" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "login": 0, "value": 0, "type": "Buy", "comment": "" }'

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.

MT5Request

PropertyTypeDescription
id integer (int32), nullable Has No Setter In ManagerAPI, so all you can is to read this value. request id
login * integer (int64) client login
group string, nullable Has No Setter In ManagerAPI, so all you can is to read this value.
symbol * string symbol
digits integer (int32), nullable price digits
action * TradeActions TradeActions
timeExpiration string (date-time), nullable order expiration
type * OrderType order type IMTOrder::OrderType
typeFill OrderFilling IMTOrder::OrderFilling
typeTime OrderTime IMTOrder::OrderTime
flags TradeActionFlags additional flags TradeActionFlags
volume * integer (int64) 1 lot = 10_000
order integer (int64), nullable order ticket
orderExternalID string, nullable order ticket in external system (exchange, ECN, etc)
priceOrder * number (double) order price
priceTrigger number (double), nullable order trigger price
priceSL number (double), nullable order SL price
priceTP number (double), nullable order TP price
priceDeviation integer (int64), nullable price deviation details
priceDeviationTop number (double), nullable
priceDeviationBottom number (double), nullable
comment string, nullable comment
resultRetCode MT5Result Has No Setter In ManagerAPI, so all you can is to read this value. request result information
resultDealer integer (int64), nullable request result deal request dealer
resultDeal integer (int64), nullable Has No Setter In ManagerAPI, so all you can is to read this value. request result deal
resultOrder integer (int64), nullable Has No Setter In ManagerAPI, so all you can is to read this value. request result order
resultVolume integer (int64), nullable Has No Setter In ManagerAPI, so all you can is to read this value. request result confirmed volume
resultPrice number (double), nullable Has No Setter In ManagerAPI, so all you can is to read this value. request result confirmed price
resultDealerBid number (double), nullable Has No Setter In ManagerAPI, so all you can is to read this value. request result dealer prices
resultDealerAsk number (double), nullable Has No Setter In ManagerAPI, so all you can is to read this value.
resultDealerLast number (double), nullable Has No Setter In ManagerAPI, so all you can is to read this value.
resultMarketBid number (double), nullable Has No Setter In ManagerAPI, so all you can is to read this value. request result market prices
resultMarketAsk number (double), nullable Has No Setter In ManagerAPI, so all you can is to read this value.
resultMarketLast number (double), nullable Has No Setter In ManagerAPI, so all you can is to read this value.
resultComment string, nullable Has No Setter In ManagerAPI, so all you can is to read this value. request result comment
externalAccount string, nullable external system trade account (exchange, ECN, etc)
idClient integer (int32), nullable Has No Setter In ManagerAPI, so all you can is to read this value. client side request id
ip string, nullable source request ip
sourceLogin integer (int64), nullable source dealer login (for dealer transaction)
position integer (int64), nullable position ticket
positionBy integer (int64), nullable position ticket for close-by
positionExternalID string, nullable position ticket in external system (exchange, ECN, etc)
positionByExternalID string, nullable position ticket in external system (exchange, ECN, etc)
volumeExt integer (int64), nullable volume with extended accuracy, 1 lot = 100_000_000
resultVolumeExt integer (int64), nullable Has No Setter In ManagerAPI, so all you can is to read this value. request result confirmed volume with extended accuracy
volumeCurrent integer (int64), nullable current order volume
volumeCurrentExt integer (int64), nullable current order volume

DealerBalanceRequest

PropertyTypeDescription
login * integer (int64)
value * number (double)
type EnDealAction if none specified - it will be Balance operation. Buy/Sell actions here - pointless.
comment string, nullable

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

TradeActions

Values: Price, Request, Instant, Market, Exchange, Pending, SLTP, Modify, Remove, Transfer, CloseBy, Activate, ActivateSL, ActivateTP, ActivateStopLimit, StopOutOrder, StopOutPosition, Expiration, DealerPosExecute, DealerOrdPending, DealerPosModify, DealerOrdModify, DealerOrdRemove, DealerOrdActivate, DealerBalance, DealerOrdSLimit, DealerCloseBy, End

OrderType

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

OrderFilling

Values: FoK, IoC, Return, BoC

OrderTime

Values: GtC, Day, Specified, SpecifiedDay

TradeActionFlags

Flags: names of the set bits joined by ", " ("Close, Market"), "None" when none is set; a set bit without a name is "Bit<n>" (bit number). Bits: Close = 0x1, Market = 0x2, ChangedPrice = 0x4, ChangedTrigger = 0x8, ChangedSL = 0x10, ChangedTP = 0x20, ChangedExpType = 0x40, ChangedExpTime = 0x80, Expert = 0x100, Signal = 0x200, SkipMarginCheck = 0x400. Accepted on input, never written: All = Close, Market, ChangedPrice, ChangedTrigger, ChangedSL, ChangedTP, ChangedExpType, ChangedExpTime, Expert, Signal, SkipMarginCheck.

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

EnDealAction

Action

Values: Buy, Sell, Balance, Credit, Charge, Correction, Bonus, Commission, CommissionDaily, CommissionMonthly, AgentDaily, AgentMonthly, InterestRate, BuyCanceled, SellCanceled, Dividend, DividendFranked, Tax, Agent, SOCompensation

MT5ResultType

type of error described here

Values: HTTP, MT4API, MT5API