MEXC Setup Guide
Connect TradingView to MEXC Spot using TradeAdapter’s direct API integration with Pine Script strategies.
Video walkthrough #
MEXC + TradingView setup
1 — Create MEXC API keys #
Spot only
MEXC currently supports automatic Spot trading only. Margin and Futures auto-trading are temporarily disabled by the exchange, even if you see these options in the UI.
-
Create or log in to your account
Go to mexc.com and sign in or create a new account. MEXC provides real accounts only — there is no Demo account.
-
Open API Management
Navigate to API Management. Click Create API or Create New Key to start.
-
Allow only Trade operations
In the API settings, enable only Trade permissions. Keep Withdrawals disabled — TradeAdapter never needs withdrawal access.
-
Restrict access to TradeAdapter IP
Limit API access to the TradeAdapter IP:
35.75.198.16. This ensures only TradeAdapter can send orders with this key. -
Select allowed symbols
In the API configuration, add the Spot symbols you plan to trade and confirm them (Spot/Margin toggle in MEXC UI). Only these symbols will be tradable via this API key.
-
Save your credentials
After email / 2FA confirmation, MEXC will show your API Key and Secret once. Copy them and store securely — you will paste them in the alert message.
2 — Select the MEXC symbol in TradingView #
Open TradingView and search for the symbol using the MEXC prefix. MEXC auto-trading via TradeAdapter is Spot-only, so always choose the Spot market:
Search MEXC:BTCUSDT, MEXC:ETHUSDT, etc. Confirm the market type is Spot in TradingView.
Important
The {{ticker}} placeholder in your alert message sends this exact symbol name to MEXC. If the symbol does not exist on MEXC Spot, the order will be rejected.
3 — Add your strategy to the chart #
MEXC integration with TradeAdapter works with Pine Script strategies (not indicator-only alerts).
Open Pine Editor, paste your strategy code, and click “Add to chart”. Then open the Strategy Tester tab to confirm backtest results appear and trades are firing as expected.
If you are unsure whether your script is an indicator or a strategy, see Indicator vs Strategy.
4 — Configure order size #
MEXC enforces symbol-specific precision and minimums (base / quote precision, amount precision). Before creating the alert, make sure your order size fits these rules.
How to set order size (Strategy)
Open your strategy settings in TradingView and configure Order Size in contracts/quantity to respect the symbol’s minimum and precision. For example, if the symbol requires 2 decimal places, set the size so that {{strategy.order.contracts}} always respects that precision.
Check the exact precision and limits for your symbol: MEXC Supported Symbols — Spot
5 — Create the TradingView alert #
Press Alt + A (or click the alarm clock icon) to create a new alert on your strategy.
Under Condition, select your strategy and set trigger to “Order fills only”. TradingView will fill {{strategy.order.action}}, {{strategy.order.contracts}}, and {{strategy.order.price}} automatically.
Required: Webhook URL + Message
In the Notifications tab, enable Webhook URL and paste your personal webhook from your TradeAdapter profile. Then paste the JSON message (below) in the Message field.
Alert message format #
Paste this JSON into the alert’s Message field. Replace only the highlighted values — the {{...}} placeholders are filled automatically by TradingView when the alert fires.
{
"broker_api_key": "YOUR_MEXC_API_KEY",
"broker_api_secret": "YOUR_MEXC_SECRET",
"real_order": "No",
"order_market": "Spot",
"order_type": "Market",
"isolated_margin": "No",
"exchange": "mexc",
"ticker": "{{ticker}}",
"time": "{{timenow}}",
"order_contracts": "{{strategy.order.contracts}}",
"order_action": "{{strategy.order.action}}",
"order_price": "{{strategy.order.price}}",
"market_position": "{{strategy.market_position}}",
"prev_market_position": "{{strategy.prev_market_position}}"
}
Message fields explained #
| Field | Description |
|---|---|
broker_api_key |
Your MEXC API Key (from Step 1) |
broker_api_secret |
Your MEXC API Secret (from Step 1) |
real_order |
"Yes" executes real orders on MEXC. "No" sends a test order through TradeAdapter without placing a live trade. |
order_market |
Must be "Spot" for MEXC auto-trading. Margin and Futures are currently not supported. |
order_type |
"Market" or "Limit". Market is recommended for most strategies. |
isolated_margin |
Used only for Margin trading. Since MEXC auto-trading is Spot-only, keep this as "No". |
exchange |
Exchange identifier, must be "mexc" for MEXC. |
ticker |
The TradingView symbol name (e.g. MEXC:BTCUSDT) sent via {{ticker}}. |
time |
Alert time from TradingView ({{timenow}}). |
order_contracts |
Order quantity from your strategy ({{strategy.order.contracts}}). |
order_action |
Buy or Sell, filled automatically by {{strategy.order.action}}. |
order_price |
Price from the strategy ({{strategy.order.price}}), used when you send Limit orders. |
market_position |
Strategy position after the order ({{strategy.market_position}}). |
prev_market_position |
Strategy position before the order ({{strategy.prev_market_position}}). |
6 — Execute & monitor #
-
Start in test mode
Set
"real_order": "No"in your message and let the first alerts fire. Check your MyTrades page to confirm that TradeAdapter receives and processes the signals correctly. -
Verify on MEXC
When you switch to
"real_order": "Yes", watch the Order History on MEXC Spot to make sure orders are placed with the expected size and symbol. -
Go live carefully
Once everything matches your expectations, keep
"real_order": "Yes", delete the old alert, and create a fresh alert with the final message. Start with small sizes while you build confidence.
Symbol specifications #
MEXC Spot symbols have strict precision rules for base and quote assets. Always confirm the precision before finalizing your order size.
Base / quote precision and amount precision.
Important notes #
API security — Never share your Secret. Keep withdrawals disabled and restrict your key to the TradeAdapter IP (
35.75.198.16).
Strategy only — MEXC integration is optimized for Pine Script strategies with Order fills only. Indicator-only alerts are not supported in this guide.
Recreate alerts after changes — If you change strategy parameters or message fields, delete and recreate the alert. Editing an existing alert does not refresh placeholders.
Symbol must match — The TradingView symbol (
MEXC:...) must correspond to an enabled Spot symbol on your MEXC API configuration.
Test with small size — MEXC has no demo account, so always begin with very small orders until you confirm sizes and behavior.
All setup guides