Trade#
About#
Executes a trade on a connected MetaTrader account
POST /users/current/accounts/:accountId/trade
For more information see Swagger documentation. Note, that this URL is valid for new-york region only. You can find URLs for other regions on API access page.
Headers#
Name | Type | Required | Description |
---|---|---|---|
auth-token | string | Yes | authorization token. See Authentication & authorization |
Path parameters#
Name | Type | Required | Description |
---|---|---|---|
accountId | string | Yes | MetaTrader account id. You can retrieve account id from Web application after you add your MetaTrader account to our platform. The account id can also be obtained via Provisioning API |
Body#
To execute the command, it is necessary to supply the request body in the format of the MetatraderTrade model.
The following describes schemas for each type of command.
ORDER_TYPE_SELL or ORDER_TYPE_BUY#
Submits market order to the trading terminal
Name | Type | Required | Description |
---|---|---|---|
actionType | string | Yes | action type, enum: ORDER_TYPE_SELL , ORDER_TYPE_BUY |
symbol | string | Yes | symbol to trade |
volume | number | Yes | order volume, min: 0 |
stopLoss | number | stop loss price, min: 0 |
|
takeProfit | number | take profit price, min: 0 |
|
stopLossUnits | string | stop loss units. ABSOLUTE_PRICE means the that the value of stopLoss field is a final stop loss value. RELATIVE_* means that the stopLoss field value contains relative stop loss expressed either in price, points, pips, account currency or balance percentage. Default is ABSOLUTE_PRICE. enum: ABSOLUTE_PRICE , RELATIVE_PRICE , RELATIVE_POINTS , RELATIVE_PIPS , RELATIVE_CURRENCY , RELATIVE_BALANCE_PERCENTAGE |
|
takeProfitUnits | string | take profit units. ABSOLUTE_PRICE means the that the value of takeProfit field is a final take profit value. RELATIVE_* means that the takeProfit field value contains relative take profit expressed either in price, points, pips, account currency or balance percentage. Default is ABSOLUTE_PRICE. enum: ABSOLUTE_PRICE , RELATIVE_PRICE , RELATIVE_POINTS , RELATIVE_PIPS , RELATIVE_CURRENCY , RELATIVE_BALANCE_PERCENTAGE |
|
trailingStopLoss | TrailingStopLoss | distance trailing stop loss configuration | |
comment | string | order comment. The sum of the line lengths of the comment and the clientId must be less than or equal to 26. For more information see clientId usage |
|
clientId | string | client-assigned id. The id value will be present on position, history orders and history deals related to this order. You can use this field to bind your trades to objects in your application and then track trade progress. The sum of the line lengths of the comment and the clientId must be less than or equal to 26. For more information see clientId usage |
|
magic | number | magic number (expert adviser id) | |
slippage | number | slippage in points. Should be greater or equal to zero. In not set, default value specified in account entity will be used. Slippage is ignored on position modification, order modification and order cancellation calls. Slippage is also ignored if execution mode set in symbol specification is SYMBOL_TRADE_EXECUTION_MARKET. | |
fillingModes | array |
allowed filling modes in the order of priority. Default is to allow all filling modes and prefer ORDER_FILLING_FOK over ORDER_FILLING_IOC. See https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties#enum_order_type_filling for extra explanation. |
Examples#
Example request:
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'auth-token: token' -d '{
"actionType": "ORDER_TYPE_SELL",
"symbol":"AUDNZD",
"volume": 0.01,
"takeProfit": 1.03
}' 'https://mt-client-api-v1.new-york.agiliumtrade.ai/users/current/accounts/865d3a4d-3803-486d-bdf3-a85679d9fad2/trade'
Example response:
{
"numericCode": 10009,
"stringCode": "TRADE_RETCODE_DONE",
"message": "Request completed",
"orderId": "47137555"
}
ORDER_TYPE_BUY_LIMIT or ORDER_TYPE_SELL_LIMIT or ORDER_TYPE_BUY_STOP or ORDER_TYPE_SELL_STOP#
Submits pending order to the trading terminal
Name | Type | Required | Description |
---|---|---|---|
actionType | string | Yes | action type, enum: ORDER_TYPE_BUY_LIMIT , ORDER_TYPE_SELL_LIMIT , ORDER_TYPE_BUY_STOP , ORDER_TYPE_SELL_STOP |
symbol | string | Yes | symbol to trade |
volume | number | Yes | order volume, min: 0 |
openPrice | number | Yes | order limit or stop price, min: 0 |
stopLoss | number | stop loss price, min: 0 |
|
takeProfit | number | take profit price, min: 0 |
|
stopLossUnits | string | stop loss units. ABSOLUTE_PRICE means the that the value of stopLoss field is a final stop loss value. RELATIVE_* means that the stopLoss field value contains relative stop loss expressed either in price, points, pips, account currency or balance percentage. Default is ABSOLUTE_PRICE. enum: ABSOLUTE_PRICE , RELATIVE_PRICE , RELATIVE_POINTS , RELATIVE_PIPS , RELATIVE_CURRENCY , RELATIVE_BALANCE_PERCENTAGE |
|
takeProfitUnits | string | take profit units. ABSOLUTE_PRICE means the that the value of takeProfit field is a final take profit value. RELATIVE_* means that the takeProfit field value contains relative take profit expressed either in price, points, pips, account currency or balance percentage. Default is ABSOLUTE_PRICE. enum: ABSOLUTE_PRICE , RELATIVE_PRICE , RELATIVE_POINTS , RELATIVE_PIPS , RELATIVE_CURRENCY , RELATIVE_BALANCE_PERCENTAGE |
|
stopPriceBase | string | defined the base price to calculate SL/TP relative to for *_MODIFY and pending order requests. Default is OPEN_PRICE. enum: CURRENT_PRICE , OPEN_PRICE |
|
trailingStopLoss | TrailingStopLoss | distance trailing stop loss configuration | |
openPriceUnits | string | open price units. ABSOLUTE_PRICE means the that the value of openPrice field is a final open price value. RELATIVE_* means that the openPrice field value contains relative open price expressed either in price, points, pips, account currency or balance percentage. Default is ABSOLUTE_PRICE. enum: ABSOLUTE_PRICE , RELATIVE_PRICE , RELATIVE_POINTS , RELATIVE_PIPS , RELATIVE_CURRENCY , RELATIVE_BALANCE_PERCENTAGE |
|
comment | string | order comment. The sum of the line lengths of the comment and the clientId must be less than or equal to 26. For more information see clientId usage |
|
clientId | string | client-assigned id. The id value will be present on position, history orders and history deals related to this order. You can use this field to bind your trades to objects in your application and then track trade progress. The sum of the line lengths of the comment and the clientId must be less than or equal to 26. For more information see clientId usage |
|
magic | number | magic number (expert adviser id) | |
slippage | number | slippage in points. Should be greater or equal to zero. In not set, default value specified in account entity will be used. Slippage is ignored on position modification, order modification and order cancellation calls. Slippage is also ignored if execution mode set in symbol specification is SYMBOL_TRADE_EXECUTION_MARKET. | |
expiration | object | pending order expiration settings. See Pending order expiration settings section. |
Pending order expiration settings#
Name | Type | Required | Description |
---|---|---|---|
type | string | Yes | pending order expiration type. See https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties#enum_order_type_time for the list of possible options. MetaTrader4 platform supports only ORDER_TIME_SPECIFIED expiration type. enum: ORDER_TIME_GTC , ORDER_TIME_DAY , ORDER_TIME_SPECIFIED , ORDER_TIME_SPECIFIED_DAY . |
time | datetime | pending order expiration time. Ignored if expiration type is not one of ORDER_TIME_DAY or ORDER_TIME_SPECIFIED |
Examples#
Example request:
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'auth-token: token' -d '{
"actionType": "ORDER_TYPE_BUY_LIMIT",
"symbol":"AUDNZD",
"volume": 0.01,
"openPrice": 1.03
}' 'https://mt-client-api-v1.new-york.agiliumtrade.ai/users/current/accounts/865d3a4d-3803-486d-bdf3-a85679d9fad2/trade'
Example response:
{
"numericCode": 10009,
"stringCode": "TRADE_RETCODE_DONE",
"message": "Request completed",
"orderId": "47067192"
}
ORDER_TYPE_BUY_STOP_LIMIT or ORDER_TYPE_SELL_STOP_LIMIT#
Submits pending stop limit order to the trading terminal
Name | Type | Required | Description |
---|---|---|---|
actionType | string | Yes | action type, enum: ORDER_TYPE_BUY_STOP_LIMIT , ORDER_TYPE_SELL_STOP_LIMIT |
symbol | string | Yes | symbol to trade |
volume | number | Yes | order volume, min: 0 |
openPrice | number | Yes | order limit or stop price, min: 0 |
stopLimitPrice | string | Yes | price at which the StopLimit order will be placed, min: 0 |
stopLoss | number | stop loss price, min: 0 |
|
takeProfit | number | take profit price, min: 0 |
|
stopLossUnits | string | stop loss units. ABSOLUTE_PRICE means the that the value of stopLoss field is a final stop loss value. RELATIVE_* means that the stopLoss field value contains relative stop loss expressed either in price, points, pips, account currency or balance percentage. Default is ABSOLUTE_PRICE. enum: ABSOLUTE_PRICE , RELATIVE_PRICE , RELATIVE_POINTS , RELATIVE_PIPS , RELATIVE_CURRENCY , RELATIVE_BALANCE_PERCENTAGE |
|
takeProfitUnits | string | take profit units. ABSOLUTE_PRICE means the that the value of takeProfit field is a final take profit value. RELATIVE_* means that the takeProfit field value contains relative take profit expressed either in price, points, pips, account currency or balance percentage. Default is ABSOLUTE_PRICE. enum: ABSOLUTE_PRICE , RELATIVE_PRICE , RELATIVE_POINTS , RELATIVE_PIPS , RELATIVE_CURRENCY , RELATIVE_BALANCE_PERCENTAGE |
|
stopPriceBase | string | defined the base price to calculate SL/TP relative to for *_MODIFY and pending order requests. Default is OPEN_PRICE. enum: CURRENT_PRICE , OPEN_PRICE |
|
trailingStopLoss | TrailingStopLoss | distance trailing stop loss configuration | |
openPriceBase | string | defined the base price to calculate open price relative to for ORDER_MODIFY and pending order requests. Default is CURRENT_PRICE for pending orders or STOP_LIMIT_PRICE for stop limit orders. enum: CURRENT_PRICE , STOP_LIMIT_PRICE |
|
openPriceUnits | string | open price units. ABSOLUTE_PRICE means the that the value of openPrice field is a final open price value. RELATIVE_* means that the openPrice field value contains relative open price expressed either in price, points, pips, account currency or balance percentage. Default is ABSOLUTE_PRICE. enum: ABSOLUTE_PRICE , RELATIVE_PRICE , RELATIVE_POINTS , RELATIVE_PIPS , RELATIVE_CURRENCY , RELATIVE_BALANCE_PERCENTAGE |
|
stopLimitPriceUnits | string | stop limit price units. ABSOLUTE_PRICE means the that the value of stopLimitPrice field is a final stop limit price value. RELATIVE_* means that the stopLimitPrice field value contains relative stop limit price expressed either in price, points, pips, account currency or balance percentage. Default is ABSOLUTE_PRICE. enum: ABSOLUTE_PRICE , RELATIVE_PRICE , RELATIVE_POINTS , RELATIVE_PIPS , RELATIVE_CURRENCY , RELATIVE_BALANCE_PERCENTAGE |
|
comment | string | order comment. The sum of the line lengths of the comment and the clientId must be less than or equal to 26. For more information see clientId usage |
|
clientId | string | client-assigned id. The id value will be present on position, history orders and history deals related to this order. You can use this field to bind your trades to objects in your application and then track trade progress. The sum of the line lengths of the comment and the clientId must be less than or equal to 26. For more information see clientId usage |
|
magic | number | magic number (expert adviser id) | |
slippage | number | slippage in points. Should be greater or equal to zero. In not set, default value specified in account entity will be used. Slippage is ignored on position modification, order modification and order cancellation calls. Slippage is also ignored if execution mode set in symbol specification is SYMBOL_TRADE_EXECUTION_MARKET. | |
expiration | object | pending order expiration settings. See Pending order expiration settings section. |
Pending order expiration settings#
Name | Type | Required | Description |
---|---|---|---|
type | string | Yes | pending order expiration type. See https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties#enum_order_type_time for the list of possible options. MetaTrader4 platform supports only ORDER_TIME_SPECIFIED expiration type. enum: ORDER_TIME_GTC , ORDER_TIME_DAY , ORDER_TIME_SPECIFIED , ORDER_TIME_SPECIFIED_DAY . |
time | datetime | pending order expiration time. Ignored if expiration type is not one of ORDER_TIME_DAY or ORDER_TIME_SPECIFIED |
Examples#
Example request:
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'auth-token: token' -d '{
"actionType": "ORDER_TYPE_BUY_STOP_LIMIT",
"symbol":"AUDNZD",
"volume": 0.01,
"openPrice": 1.03,
"stopLimitPrice": "1.01"
}' 'https://mt-client-api-v1.new-york.agiliumtrade.ai/users/current/accounts/865d3a4d-3803-486d-bdf3-a85679d9fad2/trade'
Example response:
{
"numericCode": 10009,
"stringCode": "TRADE_RETCODE_DONE",
"message": "Request completed",
"orderId": "47067192"
}
POSITION_MODIFY#
Modifies a position TP/SL price
Name | Type | Required | Description |
---|---|---|---|
actionType | string | Yes | action type, enum: POSITION_MODIFY |
positionId | string | Yes | position id (ticket number) |
stopLoss | number | stop loss price, min: 0 |
|
takeProfit | number | take profit price, min: 0 |
|
stopLossUnits | string | stop loss units. ABSOLUTE_PRICE means the that the value of stopLoss field is a final stop loss value. RELATIVE_* means that the stopLoss field value contains relative stop loss expressed either in price, points, pips, account currency or balance percentage. Default is ABSOLUTE_PRICE. enum: ABSOLUTE_PRICE , RELATIVE_PRICE , RELATIVE_POINTS , RELATIVE_PIPS , RELATIVE_CURRENCY , RELATIVE_BALANCE_PERCENTAGE |
|
takeProfitUnits | string | take profit units. ABSOLUTE_PRICE means the that the value of takeProfit field is a final take profit value. RELATIVE_* means that the takeProfit field value contains relative take profit expressed either in price, points, pips, account currency or balance percentage. Default is ABSOLUTE_PRICE. enum: ABSOLUTE_PRICE , RELATIVE_PRICE , RELATIVE_POINTS , RELATIVE_PIPS , RELATIVE_CURRENCY , RELATIVE_BALANCE_PERCENTAGE |
|
stopPriceBase | string | defined the base price to calculate SL/TP relative to for POSITION_MODIFY requests. STOP_PRICE means the SL/TP is relative to previous SL/TP value. Default is OPEN_PRICE. enum: CURRENT_PRICE , OPEN_PRICE , STOP_PRICE |
|
trailingStopLoss | TrailingStopLoss | distance trailing stop loss configuration |
Examples#
Example request:
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'auth-token: token' -d '{
"actionType": "POSITION_MODIFY",
"positionId":"46648037",
"takeProfit": 1.06
}' 'https://mt-client-api-v1.new-york.agiliumtrade.ai/users/current/accounts/865d3a4d-3803-486d-bdf3-a85679d9fad2/trade'
Example response:
{
"numericCode": 10009,
"stringCode": "TRADE_RETCODE_DONE",
"message": "Request completed",
"positionId": "46648037"
}
POSITION_PARTIAL#
Partially closes a position
Name | Type | Required | Description |
---|---|---|---|
actionType | string | Yes | action type, enum: POSITION_PARTIAL |
positionId | string | Yes | position id |
volume | number | Yes | volume to close, min: 0 |
comment | string | order comment. The sum of the line lengths of the comment and the clientId must be less than or equal to 26. For more information see clientId usage |
|
clientId | string | client-assigned id. The id value will be present on history orders and history deals related to this order. You can use this field to bind your trades to objects in your application and then track trade progress. The sum of the line lengths of the comment and the clientId must be less than or equal to 26. For more information see clientId usage |
|
magic | number | magic number (expert adviser id) | |
slippage | number | slippage in points. Should be greater or equal to zero. In not set, default value specified in account entity will be used. Slippage is ignored on position modification, order modification and order cancellation calls. Slippage is also ignored if execution mode set in symbol specification is SYMBOL_TRADE_EXECUTION_MARKET. | |
fillingModes | array |
allowed filling modes in the order of priority. Default is to allow all filling modes and prefer ORDER_FILLING_FOK over ORDER_FILLING_IOC. See https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties#enum_order_type_filling for extra explanation. |
Examples#
Example request:
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'auth-token: token' -d '{
"actionType": "POSITION_PARTIAL",
"positionId":"46648037",
"volume": 0.01
}' 'https://mt-client-api-v1.new-york.agiliumtrade.ai/users/current/accounts/865d3a4d-3803-486d-bdf3-a85679d9fad2/trade'
Example response:
{
"numericCode": 10009,
"stringCode": "TRADE_RETCODE_DONE",
"message": "Request completed",
"orderId": "47138322",
"positionId": "46648037"
}
POSITION_CLOSE_ID#
Closes a position fully
Name | Type | Required | Description |
---|---|---|---|
actionType | string | Yes | action type, enum: POSITION_CLOSE_ID |
positionId | string | Yes | position id |
comment | string | order comment. The sum of the line lengths of the comment and the clientId must be less than or equal to 26. For more information see clientId usage |
|
clientId | string | client-assigned id. The id value will be present on history orders and history deals related to this order. You can use this field to bind your trades to objects in your application and then track trade progress. The sum of the line lengths of the comment and the clientId must be less than or equal to 26. For more information see clientId usage |
|
magic | number | magic number (expert adviser id) | |
slippage | number | slippage in points. Should be greater or equal to zero. In not set, default value specified in account entity will be used. Slippage is ignored on position modification, order modification and order cancellation calls. Slippage is also ignored if execution mode set in symbol specification is SYMBOL_TRADE_EXECUTION_MARKET. | |
fillingModes | array |
allowed filling modes in the order of priority. Default is to allow all filling modes and prefer ORDER_FILLING_FOK over ORDER_FILLING_IOC. See https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties#enum_order_type_filling for extra explanation. |
Examples#
Example request:
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'auth-token: token' -d '{
"actionType": "POSITION_CLOSE_ID",
"positionId":"46648037"
}' 'https://mt-client-api-v1.new-york.agiliumtrade.ai/users/current/accounts/865d3a4d-3803-486d-bdf3-a85679d9fad2/trade'
Example response:
{
"numericCode": 10009,
"stringCode": "TRADE_RETCODE_DONE",
"message": "Request completed",
"orderId": "47138393",
"positionId": "46648037"
}
POSITIONS_CLOSE_SYMBOL#
Close positions by symbol
Name | Type | Required | Description |
---|---|---|---|
actionType | string | Yes | action type, enum: POSITIONS_CLOSE_SYMBOL |
symbol | string | Yes | symbol to trade |
comment | string | order comment. The sum of the line lengths of the comment and the clientId must be less than or equal to 26. For more information see clientId usage |
|
clientId | string | client-assigned id. The id value will be present on history orders and history deals related to this order. You can use this field to bind your trades to objects in your application and then track trade progress. The sum of the line lengths of the comment and the clientId must be less than or equal to 26. For more information see clientId usage |
|
magic | number | magic number (expert adviser id) | |
slippage | number | slippage in points. Should be greater or equal to zero. In not set, default value specified in account entity will be used. Slippage is ignored on position modification, order modification and order cancellation calls. Slippage is also ignored if execution mode set in symbol specification is SYMBOL_TRADE_EXECUTION_MARKET. | |
fillingModes | array |
allowed filling modes in the order of priority. Default is to allow all filling modes and prefer ORDER_FILLING_FOK over ORDER_FILLING_IOC. See https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties#enum_order_type_filling for extra explanation. |
Examples#
Example request:
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'auth-token: token' -d '{
"actionType": "POSITIONS_CLOSE_SYMBOL",
"symbol": "AUDNZD"
}' 'https://mt-client-api-v1.new-york.agiliumtrade.ai/users/current/accounts/865d3a4d-3803-486d-bdf3-a85679d9fad2/trade'
Example response:
{
"numericCode": 10009,
"stringCode": "TRADE_RETCODE_DONE",
"message": "Request completed",
"orderId": "46879076",
"positionId": "46732826"
}
Response example for an account that does not support this feature:
{
"numericCode": 10006,
"stringCode": "TRADE_RETCODE_REJECT",
"message": "Request rejected",
}
POSITION_CLOSE_BY#
Closes a position by an opposite position
Name | Type | Required | Description |
---|---|---|---|
actionType | string | Yes | action type, enum: POSITION_CLOSE_BY |
positionId | string | Yes | position id |
closeByPositionId | string | Yes | identifier of an opposite position used for closing by order |
comment | string | order comment. The sum of the line lengths of the comment and the clientId must be less than or equal to 26. For more information see clientId usage |
|
clientId | string | client-assigned id. The id value will be present on history orders and history deals related to this order. You can use this field to bind your trades to objects in your application and then track trade progress. The sum of the line lengths of the comment and the clientId must be less than or equal to 26. For more information see clientId usage |
|
magic | number | magic number (expert adviser id) | |
fillingModes | array |
allowed filling modes in the order of priority. Default is to allow all filling modes and prefer ORDER_FILLING_FOK over ORDER_FILLING_IOC. See https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties#enum_order_type_filling for extra explanation. |
Examples#
Example request:
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'auth-token: token' -d '{
"actionType": "POSITION_CLOSE_ID",
"positionId":"46648037",
"closeByPositionId":"46648046"
}' 'https://mt-client-api-v1.new-york.agiliumtrade.ai/users/current/accounts/865d3a4d-3803-486d-bdf3-a85679d9fad2/trade'
Example response:
{
"numericCode": 10009,
"stringCode": "TRADE_RETCODE_DONE",
"message": "Request completed",
"orderId": "47138393",
"positionId": "46648037",
"closeByPositionId":"46648046"
}
ORDER_MODIFY#
Modifies a pending order
Name | Type | Required | Description |
---|---|---|---|
actionType | string | Yes | action type, enum: ORDER_MODIFY |
orderId | string | Yes | order id (ticket number) |
openPrice | number | Yes | limit or stop price, required for a pending order, min: 0 |
stopLoss | number | stop loss price, min: 0 |
|
takeProfit | number | take profit price, min: 0 |
|
stopLossUnits | string | stop loss units. ABSOLUTE_PRICE means the that the value of stopLoss field is a final stop loss value. RELATIVE_* means that the stopLoss field value contains relative stop loss expressed either in price, points, pips, account currency or balance percentage. Default is ABSOLUTE_PRICE. enum: ABSOLUTE_PRICE , RELATIVE_PRICE , RELATIVE_POINTS , RELATIVE_PIPS , RELATIVE_CURRENCY , RELATIVE_BALANCE_PERCENTAGE |
|
takeProfitUnits | string | take profit units. ABSOLUTE_PRICE means the that the value of takeProfit field is a final take profit value. RELATIVE_* means that the takeProfit field value contains relative take profit expressed either in price, points, pips, account currency or balance percentage. Default is ABSOLUTE_PRICE. enum: ABSOLUTE_PRICE , RELATIVE_PRICE , RELATIVE_POINTS , RELATIVE_PIPS , RELATIVE_CURRENCY , RELATIVE_BALANCE_PERCENTAGE |
|
stopPriceBase | string | defined the base price to calculate SL/TP relative to for POSITION_MODIFY requests. STOP_PRICE means the SL/TP is relative to previous SL/TP value. Default is OPEN_PRICE. enum: CURRENT_PRICE , OPEN_PRICE , STOP_PRICE |
|
trailingStopLoss | TrailingStopLoss | distance trailing stop loss configuration | |
openPriceUnits | string | open price units. ABSOLUTE_PRICE means the that the value of openPrice field is a final open price value. RELATIVE_* means that the openPrice field value contains relative open price expressed either in price, points, pips, account currency or balance percentage. Default is ABSOLUTE_PRICE. enum: ABSOLUTE_PRICE , RELATIVE_PRICE , RELATIVE_POINTS , RELATIVE_PIPS , RELATIVE_CURRENCY , RELATIVE_BALANCE_PERCENTAGE |
|
openPriceBase | string | defined the base price to calculate open price relative to for ORDER_MODIFY and pending order requests. Default is CURRENT_PRICE for pending orders or STOP_LIMIT_PRICE for stop limit orders. enum: CURRENT_PRICE , OPEN_PRICE , STOP_LIMIT_PRICE |
|
stopLimitPriceUnits | string | stop limit price units. ABSOLUTEPRICE means the that the value of stopLimitPrice field is a final stop limit price value. RELATIVE_* means that the stopLimitPrice field value contains relative stop limit price expressed either in price, points, pips, account currency or balance percentage. Default is ABSOLUTE_PRICE. enum: ABSOLUTE_PRICE , RELATIVE_PRICE , RELATIVE_POINTS , RELATIVE_PIPS , RELATIVE_CURRENCY , RELATIVE_BALANCE_PERCENTAGE |
|
stopLimitPriceBase | string | defined the base price to calculate stop limit price relative to for ORDER_MODIFY requests. enum: CURRENT_PRICE , STOP_LIMIT_PRICE |
Examples#
Example request:
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'auth-token: token' -d '{
"actionType": "ORDER_MODIFY",
"orderId":"47067192",
"openPrice": 1.03,
"stopLoss": 1.05
}' 'https://mt-client-api-v1.new-york.agiliumtrade.ai/users/current/accounts/865d3a4d-3803-486d-bdf3-a85679d9fad2/trade'
Example response:
{
"numericCode": 10009,
"stringCode": "TRADE_RETCODE_DONE",
"message": "Request completed",
"orderId": "47067192"
}
ORDER_CANCEL#
Cancels an order
Name | Type | Required | Description |
---|---|---|---|
actionType | string | Yes | action type, enum: ORDER_CANCEL |
orderId | string | Yes | order id (ticket number) |
Examples#
Example request:
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'auth-token: token' -d '{
"actionType": "ORDER_CANCEL",
"orderId":"47067192"
}' 'https://mt-client-api-v1.new-york.agiliumtrade.ai/users/current/accounts/865d3a4d-3803-486d-bdf3-a85679d9fad2/trade'
Example response:
{
"numericCode": 10009,
"stringCode": "TRADE_RETCODE_DONE",
"message": "Request completed",
"orderId": "47067192"
}
Response#
Possible error response codes are listed here.
Responses:
- 200 - Trade executed successfully for a specified MetaTrader account. Response schema: MetatraderTradeResponse
- 400 - Payload is not valid. Response schema: Error
- 401 - Authorization failed. Response schema: Error
- 404 - MetaTrader account not found or not provisioned yet. Response schema: Error