AlgoWay JSON Schema for TradingView Webhook Automation: Market, Limit, Stop and Trade Type
AlgoWay uses JSON messages to understand trading alerts from TradingView, TrendSpider, custom bots and external webhook systems. The JSON tells AlgoWay which platform should receive the order, which symbol to trade, which action to perform, what size to use, whether the entry is a market, limit or stop order, which entry price should be used for pending orders, and whether optional management fields such as Stop Loss, Take Profit, trailing stop, trade mode override, modify, breakeven, closeall or hedge-side closing should be applied.
This reference explains the complete AlgoWay webhook structure, including required fields, order actions, market and pending orders, per-signal trade mode, leverage, percentage-based position sizing and percentage-based partial closing with order_size_type, Alpaca ATM options with optionType, Stop Loss and Take Profit formats, trailing stops, position modification, breakeven and hedge-side closing.
The basic route is:
TradingView / TrendSpider / custom alert → AlgoWay webhook URL → AlgoWay JSON parser → selected broker, exchange or trading platform
If the JSON is valid and the route is configured correctly, AlgoWay can normalize the signal and send it to the selected destination. If the JSON is invalid or required fields are missing, the request is rejected before execution.
Last updated: 2026-09-27 • Author: AlgoWay
Quick Answer: Minimal AlgoWay JSON
The minimal JSON for opening a trade usually contains four required fields:
{
"platform_name": "metatrader5",
"ticker": "EURUSD",
"order_action": "buy",
"order_contracts": "0.10"
}
For TradingView strategy alerts, the same structure can use TradingView placeholders:
{
"platform_name": "metatrader5",
"ticker": "{{ticker}}",
"order_action": "{{strategy.market_position}}",
"order_contracts": "{{strategy.order.contracts}}",
"price": "{{close}}"
}
For pending entries, add order_type and price. If order_type is missing, AlgoWay treats the order as market by default.
{
"platform_name": "metatrader5",
"ticker": "EURUSD",
"order_action": "buy",
"order_contracts": "0.10",
"order_type": "limit",
"price": "1.0800",
"sl_price": "1.0750",
"tp_price": "1.0950"
}
To close all open positions for one symbol, use order_action as closeall. This action does not require order_contracts.
{
"platform_name": "metatrader5",
"ticker": "XAUUSD",
"order_action": "closeall"
}
If one specific alert must use another position behavior than the webhook default, add trade_type. If trade_type is missing, AlgoWay uses the required Trade Type configured in the webhook dashboard.
{
"platform_name": "metatrader5",
"ticker": "XAUUSD",
"order_action": "sell",
"order_contracts": "0.05",
"trade_type": "hedge"
}
For TrendSpider alerts, the structure can use TrendSpider placeholders:
{
"platform_name": "metatrader5",
"ticker": "%alert_symbol%",
"order_action": "buy",
"order_contracts": 1,
"price": "%last_price%",
"comment": "TS:%alert_name%"
}
Why JSON Matters in Webhook Trading Automation
A webhook URL only delivers a message. The JSON body tells AlgoWay what the message means. Without a clear schema, the receiving system cannot reliably know whether the alert is a buy, sell, close, closeall, modify, breakeven or another action.
Good JSON makes automation safer because it defines:
- destination platform route;
- trading symbol;
- direction or management action;
- order size;
- optional execution price for logs;
- optional SL/TP;
- optional trailing stop;
- optional comment or position identifier;
- optional hedge-side close behavior;
- optional close-all behavior for supported routes.
If the alert message is valid JSON, webhook receivers can parse it consistently. If it is broken text, missing quotes or incomplete JSON, AlgoWay cannot safely treat it as an execution command.
Required Fields
AlgoWay's core schema expects these fields for normal order routing.
| Field | Required | Example | Purpose |
|---|---|---|---|
platform_name |
Yes | metatrader5 |
Defines which platform handler should process the alert. |
ticker |
Yes | EURUSD, BTCUSDT, XAUUSD |
Defines the market instrument. |
order_action |
Yes | buy, sell, flat, closeall |
Defines order direction or management action. |
order_contracts |
Yes for normal entry orders. No for closeall. |
0.10, 1, 0.001 |
Defines trade size, lot, contracts or quantity depending on platform. |
order_type |
No | market, limit, stop, stop_limit |
Defines order type. If missing, AlgoWay treats the order as market. stop_limit uses a market entry followed by a protective Stop-Limit order. |
price |
Required for new limit, stop or stop_limit entries; not for MT5 pending cancellation |
1.0800, {{close}} |
Defines the entry price for limit and stop orders. With order_type: stop_limit, it defines the protective Stop-Limit limit price. For standard market orders it can still be used for logs. |
order_contracts in every normal entry alert. Do not include order_contracts when using order_action as closeall.
order_action Values and Normalization
order_action tells AlgoWay what the alert is trying to do.
| Value | Meaning | Typical use |
|---|---|---|
buy |
Buy-side entry. | Long entry, spot buy, futures long. |
sell |
Sell-side entry or short-side entry depending on platform. | Short entry, sell order, futures short. |
flat |
Close matching exposure, or cancel pending orders on MT5 when combined with order_type: "limit" or "stop". |
Close a position, or cancel pending LIMIT/STOP orders without closing positions. |
close |
Close instruction. AlgoWay normalizes it to flat. |
Exit signal, close command from external tools, pending-order cleanup where supported. |
closeall |
Close all open positions for the specified ticker without sending order_contracts. |
Close all active exposure on one symbol with one command. |
modify |
Update an existing position or pending order. | Change SL/TP on a position, or modify the entry price of an existing LIMIT/STOP pending order where supported. |
breakeven |
Move Stop Loss to entry price where supported. | Position protection after price moves in favor. |
Normalization Rules
AlgoWay can normalize common directional words into the internal action model:
| Incoming value | Normalized value |
|---|---|
long | buy |
short | sell |
close | flat |
closelong, closeshort, closeall | flat with route-specific close behavior |
This allows TradingView messages like {{strategy.market_position}} to be used in many workflows, but you should still test exactly how your destination route handles the normalized action.
order_action = closeall: Close All Positions
closeall is a close-only action that closes all open positions for the specified ticker with one command. It does not open a new trade and does not require order_contracts.
This action is useful when a user wants to exit all active exposure on one symbol without calculating the current lot size, contract amount or remaining position volume.
order_action is closeall, do not send order_contracts. AlgoWay will send a close-all instruction for the specified symbol where the destination route supports this action.
Minimal closeall Example
{
"platform_name": "metatrader5",
"ticker": "XAUUSD",
"order_action": "closeall"
}
How to Use closeall
Use closeall when the alert must close every open position on the selected symbol. The JSON must include platform_name, ticker and order_action. The order_contracts, order_type and price fields are not required for this action.
For MetaTrader 5 users, closeall requires AlgoWay EA version 2.10b or newer.
{
"platform_name": "metatrader5",
"ticker": "{{ticker}}",
"order_action": "closeall"
}
order_type: market, limit, stop and stop_limit Orders
order_type defines how AlgoWay should treat an order. Supported values are market, limit, stop and stop_limit.
| order_type | price required for entry? | Meaning | Typical use |
|---|---|---|---|
market |
No | Execute immediately at available market price. | Standard TradingView strategy entry, fast webhook execution, default mode. |
limit |
Yes | Create a limit entry at the specified price. |
Buy below market, sell above market, pullback entries. |
stop |
Yes | Create a stop entry at the specified price. |
Breakout entries, momentum confirmation, stop-market style triggers where supported. |
stop_limit |
Yes | Enter at market, then place the protective Stop Loss as a Stop-Limit order. sl_price is the stop trigger and price is the limit price. |
Protective Stop-Limit execution when a stop-market order is not desired. |
order_type is not included, AlgoWay treats the entry as market. This keeps old TradingView webhook JSON messages backward compatible.
For a new entry with order_type set to limit or stop, include price as the requested pending entry price. MT5 cancellation with flat plus limit or stop does not need a new price. When order_type is stop_limit, include both sl_price and price: sl_price is the protective stop trigger and price is the Stop-Limit limit price.
Market Order Example
{
"platform_name": "metatrader5",
"ticker": "EURUSD",
"order_action": "buy",
"order_contracts": "0.10",
"order_type": "market"
}
Limit Order Example with Absolute SL/TP
{
"platform_name": "metatrader5",
"ticker": "EURUSD",
"order_action": "buy",
"order_contracts": "0.10",
"order_type": "limit",
"price": "1.0800",
"sl_price": "1.0750",
"tp_price": "1.0950"
}
Stop Order Example with Absolute SL/TP
{
"platform_name": "metatrader5",
"ticker": "XAUUSD",
"order_action": "buy",
"order_contracts": "0.05",
"order_type": "stop",
"price": "2365.00",
"sl_price": "2352.00",
"tp_price": "2395.00"
}
Stop-Limit Protective Stop Example
{
"platform_name": "tradovate",
"ticker": "MGCZ6",
"order_action": "sell",
"order_contracts": "1",
"order_type": "stop_limit",
"sl_price": "4389.8",
"price": "4390.0"
}
* order_type: "stop_limit" is currently supported only for Tradovate.
With stop_limit, AlgoWay submits the entry as a market order. After the fill is confirmed, the protective Stop Loss is sent to Tradovate as a Stop-Limit order. sl_price sets the stop trigger and price sets the limit price.
sl_price and tp_price can be used together with market, limit or stop entries where the selected destination supports absolute Stop Loss and Take Profit prices. For distance-style SL/TP, use stop_loss and take_profit.
Closing an Open Position
To close an open position, use order_action: "flat". The alias close is normalized to flat. For this position-closing command, omit order_type and price.
{"platform_name":"metatrader5","ticker":"EURUSD","order_action":"flat","order_contracts":"0.10"}
Cancel Pending LIMIT and STOP Orders on MetaTrader 5
Pending-order cancellation is already supported. On MetaTrader 5, send order_action: "flat" together with order_type: "limit" or order_type: "stop". This combination cancels matching pending entry orders and leaves open positions untouched. Use the JSON below to cancel orders; a separate order_action: "cancel" is not needed.
Cancel LIMIT Orders
{"platform_name":"metatrader5","ticker":"EURUSD","order_action":"flat","order_type":"limit","order_contracts":"0.10"}
This cancels AlgoWay Buy Limit and Sell Limit orders on EURUSD managed by the EA with its configured Magic Number. It does not close an open EURUSD position.
Cancel STOP Orders
{"platform_name":"metatrader5","ticker":"EURUSD","order_action":"flat","order_type":"stop","order_contracts":"0.10"}
This cancels AlgoWay Buy Stop and Sell Stop pending entry orders on EURUSD. It does not remove the Stop Loss of an open position or close that position.
Cancel a Specific Pending Order by Comment
Include the same comment sent when creating the pending order. For example, to cancel a LIMIT order created with comment: "TV#12345":
{"platform_name":"metatrader5","ticker":"EURUSD","order_action":"flat","order_type":"limit","order_contracts":"0.10","comment":"TV#12345"}
Use a unique comment for each order that must be cancelled individually. Without a comment filter, all matching AlgoWay pending orders of the requested type on the symbol are targeted. Orders with a different Magic Number are excluded. When an entry was automatically converted between LIMIT and STOP, the EA can still locate it by the exact comment when no matching order of the requested type exists.
order_contracts is retained in these flat payloads for compatibility; cancellation deletes the matching pending order in full, rather than cancelling only the stated volume. No new entry price, SL or TP is needed for cancellation.
| MT5 instruction | Result |
|---|---|
flat with order_type: "limit" | Cancel matching pending LIMIT orders; leave open positions untouched. |
flat with order_type: "stop" | Cancel matching pending STOP entry orders; leave open positions untouched. |
flat without order_type | Close matching open position exposure. |
closeall | Close matching open positions; do not use it as a pending-order cancellation command. |
This pending-only behavior is confirmed for AlgoWay MT5 EA 2.18. Other destination platforms have their own supported cancellation behavior.
trade_type: Per-Order Trade Mode Override
trade_type lets one JSON message override the Trade Type configured in the webhook dashboard. Supported values are hedge, netting, opposite and inverse.
| trade_type | Meaning | Typical use |
|---|---|---|
hedge |
Allow separate long and short exposure where the destination supports it. | Strategy legs, multi-signal workflows, independent long/short handling. |
netting |
Use net-position behavior for this order. | One net exposure per symbol, no separate long/short stacking. |
opposite |
Send the opposite side of the incoming signal. | Inverse execution strategy, copy opposite behavior. |
inverse |
Invert the incoming direction where the route supports inverse mode. | Contrarian mirroring, inverse copy-trading logic. |
If trade_type is missing, AlgoWay uses the Trade Type selected in the webhook settings. In the webhook creation form this setting is required, so the route always has a default behavior. Use trade_type in JSON only when this exact alert must behave differently from the webhook default.
Example: One Order Forced to Hedge Mode
{
"platform_name": "metatrader5",
"ticker": "XAUUSD",
"order_action": "buy",
"order_contracts": "0.05",
"trade_type": "hedge"
}
Example: Limit Order with trade_type Override
{
"platform_name": "metatrader5",
"ticker": "NAS100",
"order_action": "sell",
"order_contracts": "1",
"order_type": "limit",
"price": "18350.0",
"sl_price": "18430.0",
"tp_price": "18100.0",
"trade_type": "netting"
}
For a full explanation of hedge, netting, opposite and inverse behavior, read How AlgoWay handles opposite trading signals.
leverage: Per-Signal Leverage Control
leverage allows a webhook signal to set leverage for the current order without changing the leverage stored in the AlgoWay platform connection settings.
The parameter is supported for the following cryptocurrency exchange connections:
- MEXC;
- KuCoin Futures;
- BitMart Futures;
- Coinbase Futures;
- BingX.
If leverage is omitted, AlgoWay uses the leverage saved in the connected platform settings.
MEXC Example with 5x Leverage
{
"platform_name": "mexc",
"ticker": "BTCUSDT",
"order_contracts": "0.01",
"order_action": "buy",
"leverage": "5"
}
This signal opens a BTCUSDT position using 5x leverage.
order_size_type: Percentage-Based Position Sizing and Partial Closing
order_size_type changes how AlgoWay interprets order_contracts. The parameter is optional. If it is omitted, order_contracts keeps its normal platform-specific meaning such as lots, contracts or quantity.
The percentage-based sizing modes are:
| order_size_type | Used with | Meaning of order_contracts | Additional requirement |
|---|---|---|---|
balance_percent |
buy, sell |
order_contracts is the percentage of current account equity used as the target position notional. |
No Stop Loss is required. |
risk_percent |
buy, sell |
order_contracts is the percentage of current account equity that may be lost if Stop Loss is reached. |
sl_price or stop_loss is required. |
position_percent |
flat |
order_contracts is the percentage of the currently open position that should be closed. |
Value must be greater than 0 and not greater than 100. |
balance_percent and risk_percent use live account equity for entry sizing. position_percent uses the actual open position size for partial closing and does not require an equity or Stop Loss calculation.
balance_percent Example
{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "buy",
"order_contracts": "0.05",
"order_size_type": "balance_percent",
"leverage": "50"
}
In this example, 0.05 means 0.05% of current account equity. AlgoWay reads the live account equity and calculates 0.05% of that equity as the target position notional. The destination handler then converts that target size into the quantity or contract format required by the platform.
leverage is handled separately. It does not multiply the percentage used by balance_percent. The percentage defines the target position notional, while leverage controls the leverage setting used by the destination handler where leverage control is supported.
risk_percent Example with Absolute Stop Loss
{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "buy",
"order_contracts": "0.05",
"order_size_type": "risk_percent",
"sl_price": "0.29000",
"leverage": "50"
}
Here 0.05 means that the loss at the specified Stop Loss should equal approximately 0.05% of current account equity. AlgoWay calculates the distance between the entry reference price and sl_price, converts the permitted account risk into position size, and the destination handler converts that size into the quantity or contract format required by the platform.
risk_percent Example with Percentage Stop Loss
{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "sell",
"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 0.05% account risk and stop_loss: 1 means a Stop Loss distance of 1% from the entry reference price.
position_percent Example: Close 50% of a Position
{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "flat",
"order_contracts": "50",
"order_size_type": "position_percent"
}
Here 50 means close 50% of the currently open TRXUSDT position. AlgoWay reads the actual open position size and calculates the close volume from that position. It does not recalculate the original balance_percent or risk_percent used to open the trade.
For example, if the current position contains 322 contracts, position_percent: 50 closes 161 contracts. The destination handler applies the platform-specific quantity step, lot step or contract-size rules when converting the percentage to an executable close size.
Hedge Example: Close 25% of the Long Side
{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "flat",
"order_contracts": "25",
"order_size_type": "position_percent",
"close_side": "long"
}
In hedge mode, close_side can be long or short. The percentage is calculated from the selected hedge leg. If close_side is omitted and both long and short positions exist, AlgoWay calculates the requested percentage separately for each open leg.
Close 100% of the Current Position with position_percent
{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "flat",
"order_contracts": "100",
"order_size_type": "position_percent"
}
position_percent: 100 closes 100% of the matching current position. For a simpler full-close instruction that does not require order_contracts, you can also use closeall.
{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "closeall"
}
balance_percent and risk_percent are entry-sizing modes. For percentage-based partial closes, use position_percent. To close every matching open position without calculating a percentage, use closeall.
Optional Fields
Optional fields add execution context, risk controls, management actions or logging labels.
| Field | Example | Purpose |
|---|---|---|
order_type |
market, limit, stop, stop_limit |
Optional order type. If missing, default is market. For new limit or stop entries, price is required. With MT5 flat, these types select pending cancellation without a new price. For stop_limit, both sl_price and price are required. |
trade_type |
hedge, netting, opposite, inverse |
Overrides the webhook Trade Type for this specific order. If missing, webhook settings are used. |
leverage |
5 |
Sets leverage for the current signal. Supported for MEXC, KuCoin Futures, BitMart Futures, Coinbase Futures and BingX. If omitted, AlgoWay uses the leverage saved in the connected platform settings. |
order_size_type |
balance_percent, risk_percent, position_percent |
Changes how order_contracts is interpreted. balance_percent sizes a new position by account equity, risk_percent sizes a new position by equity risk at Stop Loss, and position_percent closes a percentage of the current position with flat. |
optionType |
call, put |
Alpaca options only. When present, ticker is treated as the underlying stock or ETF symbol. With order_action: buy, AlgoWay selects the nearest available expiration and the ATM strike closest to the current underlying price, then buys that option contract. With order_action: flat, AlgoWay closes the matching open long option position of the same underlying and option type. |
sltp_type |
pips, percent |
Defines how stop_loss and take_profit are interpreted. If omitted, AlgoWay uses pips by default. Percentage mode is available only for supported cryptocurrency exchange connections. |
stop_loss |
100 |
Distance-style Stop Loss value. Usually interpreted as points, pips or route-specific distance. |
take_profit |
200 |
Distance-style Take Profit value. Usually interpreted in the same model as stop_loss. |
sl_price |
1.0845 |
Absolute Stop Loss price level. |
tp_price |
1.0950 |
Absolute Take Profit price level. |
price |
{{close}}, %last_price% |
Tracking price from the alert source. Useful for logs and comparison. With order_type: stop_limit, this field is used as the protective Stop-Limit limit price. |
trailing_pips |
80 |
Trailing stop value where supported by the platform route. |
comment |
TV#12345 |
User label, alert label, EA comment, magic-like reference or debug tag. |
close_side |
long, short |
Used with flat in hedge mode to close only one side. |
tv_order_id |
order-12345 |
Stable TradingView-side identifier used to find the same position or pending order later. For pending-order modification, use the same value that was sent with the original order. |
order_id |
Long Entry 1 |
Optional route-specific position leg or strategy signal identifier where supported. |
pyramiding is an optional JSON boolean field (true or false) that controls additional entries in the same direction on the same symbol. Set "pyramiding": false to reject a new BUY while a BUY position is already open, or a new SELL while a SELL position is already open. Opposite-direction entries and position-management actions are not blocked. Example: {"ticker":"EURUSD","order_action":"buy","order_contracts":0.1,"pyramiding":false}. Omitting the parameter or using true preserves the default behavior. Supported routes: Binance Futures, MatchTrader, DXtrade, TradeLocker, cTrader FIX-P and cTrader Open API.
Empty strings are treated as missing values and ignored. Numeric fields must be parseable as numbers. A non-numeric value in a numeric field can trigger validation failure.
optionType: Alpaca ATM Calls and Puts
optionType is an optional field used for automated options trading through the Alpaca route. Supported values are call and put. When this field is present, ticker is interpreted as the underlying stock or ETF symbol rather than as the final OCC option contract symbol.
For an option entry, use order_action: "buy". AlgoWay reads the current underlying market price, requests active and tradable option contracts from Alpaca, selects the nearest available expiration, finds the strike closest to the current underlying price, and submits the selected contract as a long option entry. The user does not need to calculate or send an OCC option symbol, expiration date or strike price.
buy + optionType: call buys an ATM call. buy + optionType: put buys an ATM put. Option quantities are whole contracts.
Buy an ATM Call
{
"platform_name": "alpaca",
"ticker": "SPY",
"order_action": "buy",
"order_contracts": 1,
"optionType": "call"
}
AlgoWay treats SPY as the underlying, resolves the nearest-expiration ATM call contract and submits a buy-to-open order for one contract.
Buy an ATM Put
{
"platform_name": "alpaca",
"ticker": "SPY",
"order_action": "buy",
"order_contracts": 1,
"optionType": "put"
}
AlgoWay resolves the nearest-expiration ATM put contract for SPY and submits a buy-to-open order.
Close a Previously Bought Call
{
"platform_name": "alpaca",
"ticker": "SPY",
"order_action": "flat",
"order_contracts": 1,
"optionType": "call"
}
For flat, AlgoWay does not calculate a new ATM contract. It searches the current Alpaca positions for the existing long SPY call and submits a sell-to-close order for the actual open OCC contract. If the requested quantity is larger than the open quantity, the close quantity is limited to the position size.
Close a Previously Bought Put
{
"platform_name": "alpaca",
"ticker": "SPY",
"order_action": "flat",
"order_contracts": 1,
"optionType": "put"
}
This closes the matching open long SPY put with a sell-to-close order.
order_action: "sell" with optionType to close a long option. Use flat. The current Alpaca options route supports long call and long put entries and closes those positions with sell-to-close. If more than one different open long option contract of the same underlying and option type exists, AlgoWay rejects the close as ambiguous instead of guessing which contract to sell.
stop_loss, take_profit, sl_price or tp_price with an option entry.
Stop Loss and Take Profit Fields
AlgoWay supports three SL/TP calculation methods:
- percentage-based values using
sltp_type: percent; - price-step values using
sltp_type: pips; - exact prices using
sl_priceandtp_price.
Percentage-Based Stop Loss and Take Profit
To interpret stop_loss and take_profit as percentages of the current market price, add:
{
"sltp_type": "percent"
}
The signal must also contain at least one of these fields:
stop_loss;take_profit.
{
"platform_name": "bybit",
"ticker": "BTCUSDT",
"order_contracts": "0.01",
"order_action": "buy",
"sltp_type": "percent",
"stop_loss": "1",
"take_profit": "2.5"
}
In this example, Stop Loss is placed 1% away from the current market price and Take Profit is placed 2.5% away.
- For BUY orders, Stop Loss is below the price and Take Profit is above the price.
- For SELL orders, Stop Loss is above the price and Take Profit is below the price.
Using Only Stop Loss
{
"platform_name": "binance",
"ticker": "ETHUSDT",
"order_contracts": "0.1",
"order_action": "buy",
"sltp_type": "percent",
"stop_loss": "1.5"
}
Using Only Take Profit
{
"platform_name": "okx",
"ticker": "BTC-USDT-SWAP",
"order_contracts": "1",
"order_action": "sell",
"sltp_type": "percent",
"take_profit": "3"
}
Exact Stop Loss and Take Profit Prices
Use sl_price and tp_price when the alert contains exact price levels.
{
"platform_name": "bybit",
"ticker": "BTCUSDT",
"order_contracts": "0.01",
"order_action": "buy",
"sl_price": "98000",
"tp_price": "105000"
}
Absolute sl_price and tp_price values always have priority over relative stop_loss and take_profit values.
{
"sltp_type": "percent",
"stop_loss": "1",
"sl_price": "98000"
}
In this example, AlgoWay uses sl_price: 98000 and ignores stop_loss: 1.
Pips Mode
To explicitly use the existing price-step calculation, set sltp_type to pips.
{
"platform_name": "binance",
"ticker": "BTCUSDT",
"order_contracts": "0.01",
"order_action": "sell",
"sltp_type": "pips",
"stop_loss": "500",
"take_profit": "1000"
}
If sltp_type is omitted, AlgoWay uses pips by default. Existing webhook alerts remain compatible.
trailing_pips Support
trailing_pips is a route-dependent field. Some destinations support native trailing-stop behavior. Others ignore the field or delegate trailing logic to an EA, broker-side feature or separate management workflow.
Platforms with Direct trailing_pips Processing in Current AlgoWay Schema
- ✅ MetaTrader 5 — trailing stop is supported. It can be enabled in the EA settings or sent from the webhook with
trailing_pips. The EA manages trailing by modifying SL, so the EA must be running and connected. Broker stop-level and freeze-level rules may affect SL movement. - ✅ Binance Futures — trailing value sent to the futures handler where supported.
- ✅ Bybit Futures — trailing-stop parameter supported by route where configured.
- ✅ Bitget Futures — trailing stop can be passed by the futures handler where supported.
- ✅ Capital.com — field interpreted and added to order options where supported.
- ✅ DxTrade — dynamic trailing field can be parsed and transmitted.
- ✅ Match-Trader — trailing distance can be passed when non-zero and supported.
Platforms That May Ignore or Delegate trailing_pips
- ❌ cTrader FIX — no generic webhook-level trailing in the current schema; broker/platform handling may differ.
- ❌ OKX, MEXC, BitMart — trailing is not implemented in current handlers.
trailing_pips creates a trailing stop on every platform. Check the route documentation and test with small size.
modify Positions and Pending Orders
Modify an Existing Position
order_action: "modify" can update an existing open position without opening a new trade. It is commonly used to change Stop Loss, Take Profit or absolute SL/TP fields.
{
"platform_name": "metatrader5",
"order_action": "modify",
"ticker": "EURUSD",
"comment": "TV#12345",
"sl_price": "1.0845",
"tp_price": "1.0950"
}
Use a stable comment or tv_order_id when the route needs to identify one specific position.
Modify the Entry Price of an Existing LIMIT or STOP Order
MetaTrader 5 and cTrader can modify the entry price of an existing resting LIMIT or STOP order with one webhook request. Send order_action: "modify", the existing pending order type in order_type, the new entry level in price, and the same stable tv_order_id or comment that was used when the pending order was created.
order_contracts is not required for this price-modification request.
MetaTrader 5 LIMIT Example
{
"platform_name": "metatrader5",
"ticker": "EURUSD",
"order_action": "modify",
"order_type": "limit",
"price": "1.16500",
"tv_order_id": "order-12345"
}
cTrader STOP Example
{
"platform_name": "ctrader",
"ticker": "EURUSD",
"order_action": "modify",
"order_type": "stop",
"price": "1.16500",
"tv_order_id": "order-12345"
}
price is the new pending entry price. If both comment and tv_order_id are sent, comment is used as the primary identifier. The identifier must match the original pending order so AlgoWay can locate exactly one resting order to modify.
order_action = breakeven
breakeven is a position management action. It moves Stop Loss to the entry price where the route and platform support that behavior.
{
"platform_name": "metatrader5",
"order_action": "breakeven",
"ticker": "GBPUSD",
"order_contracts": "0.10"
}
breakeven does not open a new trade. It manages an existing position.
close_side for Hedge Mode
In hedge mode, a symbol can have long-side and short-side exposure. A generic flat command can close all matching exposure depending on the platform handler. Use close_side when you want to close only one side.
Close Only Long Positions
{
"platform_name": "metatrader5",
"order_action": "flat",
"ticker": "EURUSD",
"order_contracts": "0.10",
"close_side": "long"
}
Close Only Short Positions
{
"platform_name": "metatrader5",
"order_action": "flat",
"ticker": "EURUSD",
"order_contracts": "0.10",
"close_side": "short"
}
If close_side is omitted, the platform handler may close all matching positions on the symbol. Test the behavior on your destination route before live use.
Supported platform_name Values
platform_name must match the destination route configured in AlgoWay. The current schema supports 25 destination values, with cTrader FIX-P and cTrader Open API treated as separate routes.
| Platform | platform_name |
|---|---|
| MetaTrader 5 | metatrader5 |
| TradeLocker | tradelocker |
| Match-Trader | matchtrader |
| DxTrade | dxtrade |
| cTrader FIX-P | ctrader |
| cTrader Open API | ctrader_oapi |
| Capital.com | capitalcom |
| Alpaca | alpaca |
| Tradovate | tradovate |
| ProjectX | projectx |
| Interactive Brokers | ibkr |
| Binance | binance |
| OKX | okx |
| Bybit | bybit |
| MEXC | mexc |
| Bitget | bitget |
| BingX | bingx |
| HyperLiquid | hyperliquid |
| Kraken | kraken |
| KuCoin | kucoin |
| Gate.io | gateio |
| Coinbase | coinbase |
| WEEX | weex |
| Toobit | toobit |
Copy-Paste JSON Examples
0. Market Order by Default
If order_type is missing, AlgoWay treats this as a market order.
{
"platform_name": "metatrader5",
"order_action": "buy",
"ticker": "EURUSD",
"order_contracts": "0.10"
}
0.1 Limit Entry with price, sl_price and tp_price
{
"platform_name": "metatrader5",
"order_action": "buy",
"ticker": "EURUSD",
"order_contracts": "0.10",
"order_type": "limit",
"price": "1.0800",
"sl_price": "1.0750",
"tp_price": "1.0950"
}
0.2 Stop Entry with trade_type Override
{
"platform_name": "metatrader5",
"order_action": "sell",
"ticker": "XAUUSD",
"order_contracts": "0.05",
"order_type": "stop",
"price": "2338.00",
"sl_price": "2350.00",
"tp_price": "2310.00",
"trade_type": "inverse"
}
0.3 Tradovate Market Entry with Protective Stop-Limit
{
"platform_name": "tradovate",
"ticker": "MGCZ6",
"order_action": "sell",
"order_contracts": "1",
"order_type": "stop_limit",
"sl_price": "4389.8",
"price": "4390.0"
}
* order_type: "stop_limit" is currently supported only for Tradovate.
0.4 Close an Open Position
{
"platform_name": "metatrader5",
"order_action": "close",
"ticker": "EURUSD",
"order_contracts": "0.10"
}
To cancel an unfilled LIMIT or STOP order instead, use flat with the matching order_type: see pending cancellation examples.
0.5 Close All Positions on Symbol
{
"platform_name": "metatrader5",
"ticker": "XAUUSD",
"order_action": "closeall"
}
1. Open BUY with SL/TP by Distance
{
"platform_name": "binance",
"order_action": "buy",
"ticker": "BTCUSDT.P",
"order_contracts": "0.10",
"stop_loss": "150",
"take_profit": "300"
}
2. Open SELL with Absolute SL/TP Prices
{
"platform_name": "tradelocker",
"order_action": "sell",
"ticker": "XAUUSD",
"order_contracts": "0.05",
"sl_price": "2055.50",
"tp_price": "2038.00"
}
3. Open BUY with trailing_pips
{
"platform_name": "bybit",
"order_action": "buy",
"ticker": "BTCUSDT",
"order_contracts": "0.10",
"stop_loss": "120",
"trailing_pips": "80"
}
4. Hedge: Close Only Long Positions
{
"platform_name": "matchtrader",
"order_action": "flat",
"ticker": "EURUSD",
"order_contracts": "0.10",
"close_side": "long"
}
5. Use LONG / SHORT Normalization
{
"platform_name": "ctrader",
"order_action": "long",
"ticker": "USDJPY",
"order_contracts": "0.10",
"stop_loss": "100"
}
6. Modify Existing Position SL/TP
{
"platform_name": "okx",
"order_action": "modify",
"ticker": "ETHUSDT",
"comment": "TV#12345",
"stop_loss": "140",
"take_profit": "280"
}
6.1 Modify Pending LIMIT Entry Price
{
"platform_name": "metatrader5",
"ticker": "EURUSD",
"order_action": "modify",
"order_type": "limit",
"price": "1.16500",
"tv_order_id": "order-12345"
}
6.2 Modify Pending STOP Entry Price on cTrader
{
"platform_name": "ctrader",
"ticker": "EURUSD",
"order_action": "modify",
"order_type": "stop",
"price": "1.16500",
"comment": "TV#12345"
}
7. Move Position to Breakeven
{
"platform_name": "metatrader5",
"order_action": "breakeven",
"ticker": "GBPUSD",
"order_contracts": "0.10"
}
8. TradingView Strategy Alert JSON
{
"platform_name": "metatrader5",
"ticker": "{{ticker}}",
"order_action": "{{strategy.market_position}}",
"order_contracts": "{{strategy.order.contracts}}",
"price": "{{close}}"
}
9. TradingView Close All Alert JSON
{
"platform_name": "metatrader5",
"ticker": "{{ticker}}",
"order_action": "closeall"
}
10. TrendSpider Standard Alert JSON
{
"platform_name": "metatrader5",
"ticker": "%alert_symbol%",
"order_action": "buy",
"order_contracts": 1,
"price": "%last_price%",
"comment": "TS:%alert_name%"
}
11. Close / Flat Signal
{
"platform_name": "metatrader5",
"ticker": "EURUSD",
"order_action": "flat",
"order_contracts": "0.10"
}
12. Position Size as Percentage of Equity
{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "buy",
"order_contracts": "0.05",
"order_size_type": "balance_percent",
"leverage": "50"
}
13. Risk as Percentage of Equity
{
"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"
}
14. Close 50% of Current Position
{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "flat",
"order_contracts": "50",
"order_size_type": "position_percent"
}
15. Hedge: Close 25% of Long Position
{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "flat",
"order_contracts": "25",
"order_size_type": "position_percent",
"close_side": "long"
}
16. Close Entire Position
{
"platform_name": "mexc",
"ticker": "TRXUSDT",
"order_action": "closeall"
}
17. Alpaca: Buy ATM Call
{
"platform_name": "alpaca",
"ticker": "{{ticker}}",
"order_action": "buy",
"order_contracts": 1,
"optionType": "call"
}
18. Alpaca: Close Bought Call
{
"platform_name": "alpaca",
"ticker": "{{ticker}}",
"order_action": "flat",
"order_contracts": 1,
"optionType": "call"
}
19. Alpaca: Buy ATM Put
{
"platform_name": "alpaca",
"ticker": "{{ticker}}",
"order_action": "buy",
"order_contracts": 1,
"optionType": "put"
}
20. Alpaca: Close Bought Put
{
"platform_name": "alpaca",
"ticker": "{{ticker}}",
"order_action": "flat",
"order_contracts": 1,
"optionType": "put"
}
Validation Checklist Before Sending Live Alerts
Before using live size, check:
- JSON is one complete object;
- all keys use double quotes;
- all string values use double quotes;
- there are no trailing commas;
platform_namematches your AlgoWay route;tickermatches or maps to the destination symbol;order_actionis valid;order_contractsis valid for entry alerts;order_contractsis omitted whenorder_actioniscloseall;order_type, when present, is one ofmarket,limit,stoporstop_limit;priceis present and numeric for newlimit,stoporstop_limitentries;- MT5 pending cancellation uses
flatwithorder_type: "limit"or"stop"; no new entry price is needed, and a comment filter must match the original order; sl_priceis present and numeric whenorder_typeisstop_limit;- pending-order price modification includes
order_action: "modify",order_type, the newprice, and a stabletv_order_idorcommentmatching the original pending order; trade_type, when present, is one ofhedge,netting,oppositeorinverse;order_size_type, when present, isbalance_percent,risk_percentorposition_percent;risk_percentincludessl_priceorstop_loss;position_percentis used withflatandorder_contractsis greater than 0 and not greater than 100;- SL/TP fields match the intended distance or absolute-price model;
trailing_pipsis supported by the destination route;close_sideis used only when hedge-side close behavior is required;- MetaTrader 5 users have AlgoWay EA version 2.10b or newer for
closeall; - AlgoWay logs show the received payload;
- destination platform accepts a small test order.
Before moving to live execution, explore syntax, schema and semantic validation in the isolated Webhook Safety Lab. The demo does not place orders.
Common JSON Problems
Invalid JSON
Use double quotes and remove trailing commas. A missing quote or extra comma can stop the webhook before AlgoWay routes the command. See: How to fix AlgoWay webhook Error 415.
Wrong platform_name
If the AlgoWay route is ProjectX but the JSON says metatrader5, the message can be rejected or routed incorrectly.
order_contracts Missing on Entry
Entry actions should include order_contracts. The value must be convertible to a floating-point number.
order_contracts Used with closeall
Do not send order_contracts with order_action set to closeall. This action closes all open positions for the specified symbol and does not need lot, contract or quantity size.
Old MetaTrader 5 EA Version with closeall
MetaTrader 5 users must update AlgoWay EA to version 2.10b or newer before using closeall.
Symbol Mismatch
{{ticker}}, %alert_symbol% or a fixed ticker may not match the broker or exchange symbol. Use the exact symbol or configure mapping.
Wrong SL/TP Model
Do not use stop_loss when you mean an absolute price. Use sl_price for exact price levels.
order_type limit or stop Without price
For new limit or stop entries, include price to specify the requested entry level. This entry-price requirement does not apply to MT5 pending cancellation using flat with limit or stop.
stop_limit Without sl_price or price
When order_type is stop_limit, both sl_price and price are required. sl_price is the protective stop trigger and price is the Stop-Limit limit price.
* order_type: "stop_limit" is currently supported only for Tradovate.
Pending Modify Cannot Find the Order
When changing the entry price of an existing LIMIT or STOP order, send the same tv_order_id or comment that was used for the original pending order. AlgoWay must be able to identify exactly one matching resting order before it can modify the price.
Wrong trade_type Value
trade_type must be hedge, netting, opposite or inverse. If you omit it, AlgoWay uses the Trade Type configured in the webhook dashboard.
risk_percent Without Stop Loss
risk_percent requires a Stop Loss reference because AlgoWay must know the loss distance before it can calculate position size. Use either sl_price or stop_loss. If stop_loss is percentage-based, also send sltp_type: "percent".
position_percent Used for Entry
position_percent is a close-sizing mode. Use it with order_action: "flat" to close a percentage of the current position. Do not use it with buy or sell.
balance_percent or risk_percent Used with flat
balance_percent and risk_percent are entry-sizing modes. For percentage-based partial closing, use position_percent. For a complete close without a percentage, use closeall.
Calculated Size Below the Platform Minimum
Percentage sizing does not bypass destination sizing rules. If the calculated amount is below the platform minimum or cannot be represented by its quantity, lot or contract step, the handler may reject the order.
Using order_type on Close Commands
On MT5, order_type changes what flat does: limit or stop selects pending-only cancellation and leaves open positions untouched. Omitting it selects position closing. Do not omit order_type from a pending cancellation alert. See cancel pending orders for complete examples.
trailing_pips Ignored
The destination route may not support webhook-level trailing. Test the route and check platform logs.
flat Closes More Than Expected
In hedge mode, use close_side when you want only one side closed. Without it, the handler may close all matching symbol exposure.
Related AlgoWay Guides
- How to create a TradingView webhook alert
- Manual TradingView webhook alerts
- TrendSpider webhook automation with AlgoWay
- Automate webhook alerts to any broker with AlgoWay
- How to fix AlgoWay webhook Error 415
- How AlgoWay handles opposite trading signals
- Advanced risk management and trade automation
- TradingView to MetaTrader 5 with AlgoWay
- TradingView to ProjectX with AlgoWay
- TradingView to Tradovate with AlgoWay
Final Summary
AlgoWay JSON schema is the language that turns webhook alerts into executable trading commands. The core fields are platform_name, ticker, order_action and order_contracts for normal entry orders. order_type adds support for market, limit, stop and stop_limit. price is required for new pending limit and stop entries, but not for MT5 pending cancellation; with stop_limit, sl_price is the protective stop trigger and price is the Stop-Limit limit price. trade_type can override the webhook Trade Type for one specific alert. order_size_type can reinterpret order_contracts as a percentage of live account equity used for position notional size, a percentage of equity risked at Stop Loss, or a percentage of the current open position to close with flat.
Use order_action as closeall when the alert must close all open positions for one symbol without sending order_contracts. MetaTrader 5 users must update AlgoWay EA to version 2.10b or newer before using this action.
Optional fields such as stop_loss, take_profit, sl_price, tp_price, trailing_pips, comment, tv_order_id, order_id and close_side add risk control, logs and position management. For MetaTrader 5 and cTrader pending LIMIT/STOP orders, order_action: "modify" with order_type, a new price and the original stable identifier can modify the resting entry directly without a separate cancel-and-replace webhook. Start with the minimal JSON, test it with small size, check AlgoWay Webhook Logs, then add pending orders, SL/TP, trailing, modify, breakeven, closeall or hedge-side behavior only after the basic route works.