AlgoWay JSON Schema for TradingView Webhook Automation: Market, Limit, Stop and Trade Type

AlgoWay JSON schema for TradingView webhook automation

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, 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-08-31 • 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 Defines entry order type. If missing, AlgoWay treats the order as market.
price Required when order_type is limit or stop 1.0800, {{close}} Defines the entry price for limit and stop orders. For market orders it can still be used for logs.

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 or flatten matching exposure. Exit signal, close position, strategy goes flat.
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
longbuy
shortsell
closeflat
closelong, closeshort, closeallflat 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.

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 and stop Orders

order_type defines how AlgoWay should treat an entry alert. Supported values are market, limit and stop.

order_type price required? 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.

When order_type is limit or stop, include price. In this context, price is not only a log value; it is the requested entry price for the pending order.

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

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 a Position or Cleaning a Pending Entry

To close a position or send a close command, use order_action as flat or close. close is normalized to flat. For close-only messages, order_type and price are normally not required.

{
  "platform_name": "metatrader5",
  "ticker": "EURUSD",
  "order_action": "flat",
  "order_contracts": "0.10"
}

If the route supports pending-order cleanup, a flat or close command can also be used to remove pending entries connected with the same symbol, route, comment or order identifier. Exact behavior depends on the destination handler and route settings.

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 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 Optional entry type. If missing, default is market. If limit or stop, price is 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.
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.
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.

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.

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_price and tp_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.

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.

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.

Common platform_name Values

platform_name must match the destination route configured in AlgoWay.

Platform platform_name
MetaTrader 5metatrader5
TradeLockertradelocker
Match-Tradermatchtrader
DxTradedxtrade
cTraderctrader
cTrader Open APIctrader_oapi
Capital.comcapitalcom
Alpacaalpaca
Tradovatetradovate
ProjectXprojectx
Binancebinance
Bybitbybit
OKXokx
BitMEXbitmex
Bitgetbitget
BitMartbitmart
BingXbingx
Coinbasecoinbase
HyperLiquidhyperliquid
Krakenkraken
KuCoinkucoin

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 Close Command

{
  "platform_name": "metatrader5",
  "order_action": "close",
  "ticker": "EURUSD",
  "order_contracts": "0.10"
}

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

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_name matches your AlgoWay route;
  • ticker matches or maps to the destination symbol;
  • order_action is valid;
  • order_contracts is valid for entry alerts;
  • order_contracts is omitted when order_action is closeall;
  • order_type, when present, is one of market, limit or stop;
  • price is present and numeric when order_type is limit or stop;
  • pending-order price modification includes order_action: "modify", order_type, the new price, and a stable tv_order_id or comment matching the original pending order;
  • trade_type, when present, is one of hedge, netting, opposite or inverse;
  • order_size_type, when present, is balance_percent, risk_percent or position_percent;
  • risk_percent includes sl_price or stop_loss;
  • position_percent is used with flat and order_contracts is greater than 0 and not greater than 100;
  • SL/TP fields match the intended distance or absolute-price model;
  • trailing_pips is supported by the destination route;
  • close_side is 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.

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

If order_type is limit or stop, the alert must include price. Without price, AlgoWay does not know the requested entry level for the pending order.

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

For flat, close or closeall messages, the important field is order_action. order_type is normally not needed for closing exposure or cleaning supported pending entries.

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

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 and stop entries, while price becomes required for pending limit and stop orders. 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.