Skip to content

About

Examples and payload templates for connecting TradingView to MEXC Futures via AlgoWay

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

17 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

How to Automate TradingView Alerts to MEXC Futures with AlgoWay

Public JSON examples and payload documentation for automating TradingView alerts on MEXC Futures through AlgoWay.

What this repository is

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.

What this repository helps you do

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

How the flow works

TradingView alert or TradingView strategy
→ JSON payload
→ AlgoWay webhook
→ private AlgoWay MEXC connector
→ MEXC Futures order execution

Basic JSON payload

{
  "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.

Supported order actions

  • buy
  • sell
  • flat
  • closeall

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.

Supported trade types

  • hedge
  • reverse
  • opposite

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.

Fixed position size

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.

Percentage-based position sizing

AlgoWay supports percentage-based position sizing through order_size_type.

Available values:

  • balance_percent
  • risk_percent
  • position_percent

balance_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.

risk_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"
}

Percentage-based partial closing

Use position_percent with flat when order_contracts should represent a percentage of the currently open position.

Close 50% of the current 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.

Close 25% of a LONG position in Hedge mode

{
  "platform_name": "mexc",
  "ticker": "TRXUSDT",
  "order_action": "flat",
  "order_contracts": "25",
  "order_size_type": "position_percent",
  "close_side": "long"
}

Close 25% of a SHORT position in Hedge mode

{
  "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.

Close 100% using position_percent

{
  "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.

Complete position closing with closeall

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"
}

Stop Loss and Take Profit

Absolute Stop Loss and Take Profit prices can be sent with:

  • sl_price
  • tp_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_loss
  • take_profit
  • sltp_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

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.

Pending orders

AlgoWay supports:

  • market
  • limit
  • stop

Market is the default order type.

Limit order

{
  "platform_name": "mexc",
  "ticker": "TRXUSDT",
  "order_action": "buy",
  "order_contracts": "100",
  "order_type": "limit",
  "price": "0.29500"
}

Stop order

{
  "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.

Available parameters

Core fields

  • platform_name
  • ticker
  • order_action
  • order_contracts

Optional fields

  • trade_type
  • leverage
  • order_size_type
  • order_type
  • price
  • stop_loss
  • take_profit
  • sl_price
  • tp_price
  • sltp_type
  • trailing_pips
  • trigger
  • close_side

order_size_type reference

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

Important notes

  • Without order_size_type, order_contracts uses normal quantity sizing.
  • balance_percent is intended for position entry sizing.
  • risk_percent is intended for position entry sizing and requires a Stop Loss.
  • position_percent is intended for flat.
  • position_percent: 50 means close 50% of the current position.
  • position_percent: 100 means close 100% of the current position.
  • closeall closes the actual matching open position size.
  • close_side can be used in Hedge mode to select long or short.
  • 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.

Documentation in this repository

See the docs/ directory for additional field descriptions, trade mode notes, and MEXC-specific behavior.

Why this repository exists

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.

Related documentation

Full setup guide: TradingView to MEXC Webhook Automation with AlgoWay

AlgoWay: https://algoway.trade

About

Examples and payload templates for connecting TradingView to MEXC Futures via AlgoWay

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors