Public JSON examples and payload documentation for automating TradingView alerts on MEXC Futures through AlgoWay.
This repository shows how to automate TradingView alerts to MEXC Futures using AlgoWay as the execution bridge.
It contains public JSON payload examples and documentation for MEXC Futures automation.
It does not contain the private AlgoWay MEXC connector source code.
With these examples, you can understand how to structure TradingView alert payloads for:
- opening long and short positions
- closing positions
- partially closing positions
- using hedge, reverse and opposite trade modes
- passing Stop Loss and Take Profit parameters
- using trailing stops
- using market, limit and stop orders
- sizing positions as a percentage of account equity
- sizing positions by percentage risk at Stop Loss
- closing a percentage of the current open position
TradingView alert or TradingView strategy
→ JSON payload
→ AlgoWay webhook
→ private AlgoWay MEXC connector
→ MEXC Futures order execution
{
"platform_name": "mexc",
"ticker": "BTCUSDT",
"order_action": "buy",
"order_contracts": "0.01"
}platform_name, ticker, order_action and order_contracts are the core fields used by the AlgoWay webhook schema.
buysellflatcloseall
buy and sell open or manage positions according to the selected trade mode.
flat closes all or part of the current position according to order_contracts.
closeall closes the matching open position completely. The order_contracts field is not used to determine the close size for closeall.
hedgereverseopposite
Trade mode can also be configured in AlgoWay account settings. When trade_type is provided in the webhook payload, it is used for that signal where supported by the route.
Without order_size_type, order_contracts is treated as the normal position quantity.
Example:
{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "buy",
"order_contracts": "100"
}For MEXC Futures, AlgoWay converts the requested base-asset quantity to the contract volume required by the selected instrument.
The final executable volume is subject to the MEXC contract size and minimum order rules.
AlgoWay supports percentage-based position sizing through order_size_type.
Available values:
balance_percentrisk_percentposition_percent
Use balance_percent when order_contracts should represent a percentage of current account equity.
Example - open a position using 0.05% of account equity:
{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "buy",
"order_contracts": "0.05",
"order_size_type": "balance_percent",
"leverage": "50"
}In this example:
order_contracts = 0.05
means:
0.05% of current account equity
AlgoWay reads the live account equity and calculates the target position size before converting it to the MEXC contract volume.
Leverage is handled separately and does not multiply the percentage used by balance_percent.
Use risk_percent when order_contracts should represent the percentage of account equity risked at Stop Loss.
Example - risk 0.05% of account equity with a 1% Stop Loss:
{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "buy",
"order_contracts": "0.05",
"order_size_type": "risk_percent",
"sltp_type": "percent",
"stop_loss": "1",
"leverage": "50"
}In this example:
order_contracts = 0.05
means:
risk 0.05% of current account equity
and:
stop_loss = 1
sltp_type = percent
means a Stop Loss distance of 1%.
risk_percent requires either sl_price or stop_loss, because AlgoWay needs the Stop Loss distance to calculate the position size.
Example using an absolute Stop Loss price:
{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "buy",
"order_contracts": "0.05",
"order_size_type": "risk_percent",
"sl_price": "0.29000",
"leverage": "50"
}Use position_percent with flat when order_contracts should represent a percentage of the currently open position.
{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "flat",
"order_contracts": "50",
"order_size_type": "position_percent"
}Here:
order_contracts = 50
means:
close 50% of the current open position
The percentage is calculated from the actual current position size. It does not recalculate the balance_percent or risk_percent that may have been used when the position was opened.
For example:
Current position: 322 contracts
position_percent: 50
Close volume: 161 contracts
The final close size is adjusted according to the executable MEXC contract rules.
{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "flat",
"order_contracts": "25",
"order_size_type": "position_percent",
"close_side": "long"
}{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "flat",
"order_contracts": "25",
"order_size_type": "position_percent",
"close_side": "short"
}In Hedge mode, close_side can be used to select which side should be reduced.
If both LONG and SHORT positions exist and close_side is omitted, the requested percentage is calculated separately for each matching open side.
{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "flat",
"order_contracts": "100",
"order_size_type": "position_percent"
}position_percent must be greater than 0 and not greater than 100.
To close the entire matching position without calculating a percentage, use closeall.
{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "closeall",
"order_contracts": "1"
}For closeall, order_contracts is not used to calculate the closing volume. AlgoWay reads the actual open position size and closes it completely.
In Hedge mode, you can select one side:
{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "closeall",
"order_contracts": "1",
"close_side": "long"
}or:
{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "closeall",
"order_contracts": "1",
"close_side": "short"
}Absolute Stop Loss and Take Profit prices can be sent with:
sl_pricetp_price
Example:
{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "buy",
"order_contracts": "100",
"sl_price": "0.29000",
"tp_price": "0.32000"
}Relative Stop Loss and Take Profit distances can be sent with:
stop_losstake_profitsltp_type
Example using percentages:
{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "buy",
"order_contracts": "100",
"sltp_type": "percent",
"stop_loss": "1",
"take_profit": "2"
}Trailing Stop can be passed with trailing_pips.
Example:
{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "buy",
"order_contracts": "100",
"trailing_pips": "100"
}The value is interpreted using the instrument tick size by the AlgoWay MEXC connector.
AlgoWay supports:
marketlimitstop
Market is the default order type.
{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "buy",
"order_contracts": "100",
"order_type": "limit",
"price": "0.29500"
}{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "buy",
"order_contracts": "100",
"order_type": "stop",
"price": "0.31000"
}price is required for limit and stop orders.
platform_nametickerorder_actionorder_contracts
trade_typeleverageorder_size_typeorder_typepricestop_losstake_profitsl_pricetp_pricesltp_typetrailing_pipstriggerclose_side
| Value | Purpose | order_contracts means |
|---|---|---|
balance_percent |
Position sizing | Percentage of current account equity |
risk_percent |
Risk-based position sizing | Percentage of equity risked at Stop Loss |
position_percent |
Partial closing | Percentage of current open position to close |
- Without
order_size_type,order_contractsuses normal quantity sizing. balance_percentis intended for position entry sizing.risk_percentis intended for position entry sizing and requires a Stop Loss.position_percentis intended forflat.position_percent: 50means close 50% of the current position.position_percent: 100means close 100% of the current position.closeallcloses the actual matching open position size.close_sidecan be used in Hedge mode to selectlongorshort.- Percentage sizing remains subject to MEXC minimum contract and executable volume rules.
- Symbol normalization and MEXC instrument matching are handled by the private AlgoWay connector.
- This repository contains public documentation and examples only. The private connector source code is not included.
See the docs/ directory for additional field descriptions, trade mode notes, and MEXC-specific behavior.
Many traders search for ways to automate TradingView alerts to MEXC Futures, but public examples are often limited to basic bots or incomplete webhook snippets.
This repository provides a clearer reference for structuring TradingView webhook payloads for MEXC Futures through AlgoWay while keeping the private execution connector separate from the public documentation.
Full setup guide: TradingView to MEXC Webhook Automation with AlgoWay
AlgoWay: https://algoway.trade