CPlugin

MT4 :: Trades

API v1 (stable) · MT4 · 8 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

All open trades (pumping)

GET /api/MT4/{tradePlatform}/TradesGet

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 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: 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/MT4/$TRADE_PLATFORM_ID/TradesGet" \
  -H "Authorization: Bearer $TOKEN"

Open trade by ticket (pumping)

GET /api/MT4/{tradePlatform}/TradesGet/{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 Trade platform id
ticket path integer (int32) yes ticket number
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/MT4/$TRADE_PLATFORM_ID/TradesGet/$TICKET" \
  -H "Authorization: Bearer $TOKEN"

All trades by group name (admin)

GET /api/MT4/{tradePlatform}/AdmTradesRequest/{group}/{openOnly}

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 Trade platform id
group path string yes account group name
openOnly path boolean yes request only open trades
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/MT4/$TRADE_PLATFORM_ID/AdmTradesRequest/$GROUP/$OPEN_ONLY" \
  -H "Authorization: Bearer $TOKEN"

Open trades by login and group

GET /api/MT4/{tradePlatform}/TradesGetByLogin/{login}/{group}

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 Trade platform id
login path integer (int32) yes Account Login
group path string yes Account Group name
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/MT4/$TRADE_PLATFORM_ID/TradesGetByLogin/$LOGIN/$GROUP" \
  -H "Authorization: Bearer $TOKEN"

Modify order (admin)

POST /api/MT4/{tradePlatform}/AdmTradeRecordModify

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

TradeRecordDTO (application/json)

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/MT4/$TRADE_PLATFORM_ID/AdmTradeRecordModify" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "order": 0, "login": 0, "digits": 0, "volume": 0, "openPrice": 0, "sl": 0 }'

Trades by ticket

GET /api/MT4/{tradePlatform}/TradeRecordsRequest

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 Trade platform id
orders query integer (int32)[] no Ticket numbers
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/MT4/$TRADE_PLATFORM_ID/TradeRecordsRequest" \
  -H "Authorization: Bearer $TOKEN"

Execute 'Trade Transaction'

POST /api/MT4/{tradePlatform}/TradeTransaction

Initiate trade transaction in MT4 server on behalf of manager (open/close/modify/delete order, balance/credit)

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

TradeTransInfo (application/json) — Trade transaction description

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/MT4/$TRADE_PLATFORM_ID/TradeTransaction" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "order": 0, "orderBy": 0, "volume": 0, "price": 0, "sl": 0, "tp": 0 }'

Trade history

GET /api/MT4/{tradePlatform}/TradesUserHistory/{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 Trade platform id
login path integer (int32) yes Account login
fromTime path string (date-time) no Starting from time
toTime path string (date-time) no Ending to time
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/MT4/$TRADE_PLATFORM_ID/TradesUserHistory/$LOGIN/$FROM_TIME/$TO_TIME" \
  -H "Authorization: Bearer $TOKEN"

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.

TradeRecordDTO

PropertyTypeDescription
order integer (int32) order ticket
login integer (int32) owner's login
digits integer (int32) security precision
volume integer (int32) it stores 100 times more volue than it is, for example value of 15 means 10/100=0.15 lots
openPrice number (double) reserved
sl number (double)
tp number (double)
gatewayVolume integer (int32)
commission number (double)
commissionAgent number (double) agent commission
storage number (double) order swaps
closePrice number (double)
profit number (double)
taxes number (double)
magic integer (int32) special value used by client experts
gatewayOrder integer (int32) trade order ticket on master server in STP
gatewayOpenPrice integer (int32) gateway order price deviation (pips) from order open price
gatewayClosePrice integer (int32) gateway order price deviation (pips) from order close price
marginRate number (double) margin convertation rate (rate of convertation from margin currency to deposit one)
symbol string, nullable security
tradeCommand TradeCommand trade command (buy, sell, pending, balance, etc)
tradeRecordState TradeRecordState
gatewayVolumeLots number (double) Volume in lots, for convenience
tradeRecordReason TradeRecordReason
convReserv string (byte), nullable
convRates number (double)[] conversation rates from profit currency to group deposit currency (first element-for open time, second element-for close time)
comment string, nullable
activationType ActivationType
timeStamp string (date-time)
apiData integer (int32)[]
openTime string (date-time)
closeTime string (date-time)
expiration string (date-time) pending order's expiration time
volumeLots number (double) Volume in lots, for convenience
updateType TransactionType add - order opened, delete - order closed, Update - IF login==0 THEN order deleted ELSE order updated

HTTPError

PropertyTypeDescription
errorType HttpStatusCodeType type of error described here
errorCode HttpStatusCode If ErrorType is MT4API, it contains MT4 ManagerAPI response code. If ErrorType is MT5API, it contains MT5 ManagerAPI response code.
errorDescription string, nullable If ErrorType is MT4API, it contains MT4 ManagerAPI response code description. If ErrorType is MT5API, it contains MT5 ManagerAPI response code description.
requestId string (uuid) Unique request tracking ID

TradeTransInfo

PropertyTypeDescription
order integer (int32)
orderBy integer (int32)
volume integer (int32)
price number (double)
sl number (double)
tp number (double)
ieDeviation integer (int32)
crc integer (int32)
tradeTransactionType TradeTransactionType
tradeRequestFlags TradeRequestFlags
tradeCommand TradeCommand
symbol string, nullable
comment string, nullable
expiration string (date-time)
volumeLots number (double)

TradeCommand

Values: Buy, Sell, BuyLimit, SellLimit, BuyStop, SellStop, Balance, Credit

TradeRecordState

Values: OpenNormal, OpenRemand, OpenRestored, ClosedNormal, ClosedPart, ClosedBy, Deleted

TradeRecordReason

Values: Client, Expert, Dealer, Signal, Gateway, Mobile, Web, API

ActivationType

Values: None, SL, TP, Pending, Stopout, StopOutRollback, PendingRollback, TPRollback, SLRollback

TransactionType

Values: Add, Delete, Update, ChangeGrp

HttpStatusCodeType

type of error described here

Values: HTTP, MT4API, MT5API

HttpStatusCode

Values: Continue, SwitchingProtocols, Processing, EarlyHints, OK, Created, Accepted, NonAuthoritativeInformation, NoContent, ResetContent, PartialContent, MultiStatus, AlreadyReported, IMUsed, MultipleChoices, MovedPermanently, Found, SeeOther, NotModified, UseProxy, Unused, RedirectKeepVerb, PermanentRedirect, BadRequest, Unauthorized, PaymentRequired, Forbidden, NotFound, MethodNotAllowed, NotAcceptable, ProxyAuthenticationRequired, RequestTimeout, Conflict, Gone, LengthRequired, PreconditionFailed, RequestEntityTooLarge, RequestUriTooLong, UnsupportedMediaType, RequestedRangeNotSatisfiable, ExpectationFailed, MisdirectedRequest, UnprocessableEntity, Locked, FailedDependency, UpgradeRequired, PreconditionRequired, TooManyRequests, RequestHeaderFieldsTooLarge, UnavailableForLegalReasons, InternalServerError, NotImplemented, BadGateway, ServiceUnavailable, GatewayTimeout, HttpVersionNotSupported, VariantAlsoNegotiates, InsufficientStorage, LoopDetected, NotExtended, NetworkAuthenticationRequired

TradeTransactionType

Values: PricesGet, PricesRequote, OpenInstant, OpenRequest, OpenMarket, PendingOpen, CloseInstant, CloseRequest, CloseMarket, Modify, Delete, CloseBy, CloseAll, BrOpen, BrClose, BrDelete, BrCloseBy, BrCloseAll, BrModify, BrActivate, BrComment, BrBalance

TradeRequestFlags

Flags: names of the set bits joined by ", " ("Signal, Expert"), "None" when none is set; a set bit without a name is "Bit<n>" (bit number). Bits: Signal = 0x1, Expert = 0x2, Gateway = 0x4, Mobile = 0x8, Web = 0x10, API = 0x20.