TradingView webhooks9 min readPublished Sep 9, 2026Updated Aug 30, 2026

Take-Profit and Stop-Loss Ticks in Webhook JSON

Translate futures protection into explicit `tp` and `sl` tick counts, validate contract math, build Pine JSON, and test broker behavior without confusing ticks, points, prices, and dollars.

By HexTrade1,849 wordsSources reviewed Aug 30, 2026
Futures price ladder measuring take-profit and stop-loss distances in discrete ticks around an entry

What do `tp` and `sl` mean in HexTrade webhook JSON?

HexTrade documents `tp` and `sl` as distances in ticks, not dollars, points, or absolute prices. Calculate them from the exact destination contract's minimum price increment, then evaluate money exposure using its tick value and the routed quantity. Add the fields only after the core payload validates, and confirm live protective-order behavior on the connected broker with the smallest approved test.

A tick is the smallest quoted price increment defined for a contract. A point can contain several ticks, and the currency value of one tick varies by contract. Therefore, `sl: 20` expresses twenty increments away from an entry reference; it does not encode twenty dollars and does not imply the same risk on ES, MES, NQ, MNQ, or another future. Read the current exchange specification and the broker's actual destination contract before translating a strategy stop.

The JSON field conveys an instruction to the receiver, not a guarantee of a particular fill. Entry slippage can change the resulting protective prices if distances are anchored to the eventual entry, and broker capabilities can differ. HexTrade's public docs establish the tick unit and show example fields; use the connected route's current documentation and a controlled test to establish order linkage, modification, cancellation, and rejection behavior rather than filling those details with assumptions.

  • Ticks measure discrete price increments.
  • Points measure a larger price move that may contain multiple ticks.
  • Dollars measure economic exposure after tick value and quantity are applied.
  • Absolute price names a level and is not interchangeable with a distance.
Protective distance becomes exposure in four stepsContract tickVerify the mi…DistanceExpress the p…QuantityMultiply per-…Execution behaviorConfirm how t…
Protective distance becomes exposure in four steps. A tick count is meaningful only when paired with the exact contract, quantity, and destination behavior.

How do you convert a planned price stop into ticks?

Divide the absolute price distance between the intended reference and protective level by the contract's minimum tick size, then verify the result is a whole number allowed by the instrument. To estimate currency exposure, multiply ticks by current tick value and quantity. Recheck all specifications at contract selection and never infer micro-contract economics from a full-size symbol.

For an illustrative instrument with a 0.25 minimum price increment, a 4.00-point distance contains sixteen ticks because 4.00 divided by 0.25 equals 16. That arithmetic demonstrates the method; it does not establish a current specification for every future. Source tick size and tick value from the exchange's contract page and confirm the exact symbol at the broker. If the desired level is not aligned to a valid tick, define a rounding policy before encoding it.

Risk review must use the actual quantity that reaches the route. A dynamic `{{strategy.order.contracts}}` placeholder can differ across events, and a scale-in can change total open exposure even if each order has the same `sl`. `maxQty` is a documented hard cap per webhook request, which can catch an unexpectedly large value, but it does not calculate portfolio risk or account for other positions. Keep those calculations in an accountable risk process.

Unit conversion worksheet; contract-specific inputs must come from current official specifications
InputFormula or sourceFailure to avoid
Minimum tick sizeCurrent exchange contract specificationAssuming all index futures move in the same increment
Price distanceAbsolute difference between intended reference and protective levelConfusing an absolute stop price with a distance
Tick countPrice distance divided by minimum tick sizeSending fractional or incorrectly rounded ticks
Per-order exposureTicks multiplied by tick value and quantityCalling the tick count a dollar amount

What does a guarded TP/SL payload look like?

Keep the required route and intent fields visible, express `tp` and `sl` as reviewed tick-count strings or numbers accepted by current documentation, and add `maxQty`, `allowedSymbols`, and `dryRun` during commissioning. Use the exact account ID and lowercase platform slug from HexTrade. Never include broker credentials or a private token inside the body.

The example uses fixed protective distances because fixed inputs are easier to audit. Replace them only after calculating values for the exact destination contract. The chart can use a continuous or differently named symbol, but the payload must name what the connected account trades. If mapping is required, HexTrade documents `symbolOverride`; make that transformation explicit rather than allowing an accidental chart ticker to determine live routing.

`dryRun: true` asks HexTrade to return the planned trade without sending an order. It also does not update the documented in-memory cooldown and daily-trade counters. Use the result to verify account, symbol, side, quantity, and protective fields. Then remove dry mode only under a smallest-size live procedure. A parser success cannot confirm that the broker created protection or that a future fill will occur at the planned price.

Auditable protective-distance payload for validation
{
  "ticker": "MES",
  "action": "{{strategy.order.action}}",
  "quantity": "{{strategy.order.contracts}}",
  "platformType": "tradovate",
  "accountId": "replace_with_exact_account_id",
  "tp": "40",
  "sl": "16",
  "maxQty": 1,
  "allowedSymbols": ["MES"],
  "strategyName": "trend-protection-v2",
  "dryRun": true
}

Tick distance is not a risk budget

The same `sl` count can produce different currency exposure across contracts and quantities. Verify contract specifications, aggregate exposure, and account rules before enabling the payload.

How should Pine create dynamic protective tick values?

Calculate a price distance from confirmed strategy data, divide by `syminfo.mintick`, apply a deliberate rounding rule, and convert the integer-like result to a JSON value. Guard against `na`, zero, negative, or excessive distances before calling `alert()` or assigning `alert_message`. Validate every branch because Pine constructs JSON strings manually rather than through a built-in serializer.

Dynamic stops are useful for volatility or structure-based strategies, but each calculation must map to the destination contract. `syminfo.mintick` describes the chart context. If the chart symbol differs from the routed future, its minimum increment may not represent the destination. In that case, either chart the exact contract, supply a reviewed destination tick input, or calculate outside Pine under a documented mapping. Never silently combine a CFD chart's increment with a futures ticker.

Choose rounding based on protective intent. Rounding to nearest, floor, and ceiling can move the actual distance in different directions; the correct policy is a strategy and risk decision. Set minimum and maximum bounds and reject an invalid result instead of emitting malformed or dangerous JSON. Once the string is built, send dry-run examples at low, normal, and high volatility and parse the rendered body to ensure a number has not become `NaN`, `na`, or an empty value.

  • Chart tick size must match the destination or be replaced by an explicit reviewed input.
  • Rounding is a risk decision; document it and test boundary values.
  • Invalid protection should suppress or reject the event visibly, never degrade to a missing field silently.
  • After changing Pine or inputs, recreate the alert because the running instance is a snapshot.
Illustrative confirmed-bar conversion from ATR price distance to whole ticks
//@version=6
indicator("Dynamic protective ticks", overlay = true)
atr = ta.atr(14)
rawStopTicks = atr / syminfo.mintick
stopTicks = int(math.ceil(rawStopTicks))
targetTicks = stopTicks * 2
signal = ta.crossover(ta.ema(close, 9), ta.ema(close, 21)) and barstate.isconfirmed
validProtection = stopTicks > 0 and stopTicks <= 200

if signal and validProtection
    payload = '{"ticker":"MES","action":"buy","quantity":"1",' +
      '"platformType":"projectx","accountId":"replace_with_exact_account_id",' +
      '"tp":"' + str.tostring(targetTicks) + '","sl":"' +
      str.tostring(stopTicks) + '","dryRun":true}'
    alert(payload, alert.freq_once_per_bar_close)

When should TP/SL JSON be emitted from order fills?

If the external route should begin when TradingView's broker emulator fills a strategy order, put the reviewed JSON in that order command's `alert_message` and configure an order-fill alert with `{{strategy.order.alert_message}}`. This aligns the webhook with the simulated fill event, but it still does not reveal the actual external entry price or confirm live protective orders.

The distinction matters for stop and limit entries. A strategy can create an order several bars before its emulator fills, or the condition may never fill. An `alert()` emitted at creation can reach the external broker earlier than an order-fill event. Choose the desired model deliberately. Variables in `alert_message` are evaluated when the emulator executes the order, allowing the protective tick calculation to reflect Pine state at that simulated event.

The live route remains independent. A market can move between the TradingView event and the external broker response, and the destination may reject the order or protective instruction. Record both requested tick distances and the broker's resulting orders. Avoid enabling both an entry `alert()` and an order-fill event for the same external intent unless one is a non-trading diagnostic message that the receiver cannot interpret as an order.

  1. 1

    Choose creation or fill

    State whether external routing follows Pine's order request or the emulator's simulated execution.

  2. 2

    Bind the message

    Attach JSON to each relevant order command and include the order alert-message placeholder.

  3. 3

    Review every exit

    Ensure exit and close fills cannot accidentally reuse an entry payload.

  4. 4

    Reconcile live protection

    Inspect the external broker account rather than inferring protection from the emulator event.

How do you test protective ticks without false confidence?

Test in four gates: arithmetic against current contract specifications, rendered JSON parsing, HexTrade dry-run planning, and smallest-size live broker reconciliation. Cover long and short entries, quantity changes, invalid symbols, minimum and maximum distances, delayed fills, rejection, cancellation, and any position-closing path. Stop if the destination's protective behavior cannot be observed unambiguously.

Start with a hand-calculated case whose entry reference, tick size, target distance, stop distance, tick value, and quantity are written down. Compare Pine output with that worksheet. Then send a sanitized dry-run message and confirm the planned trade preserves the same units. Because dry run places no order, it cannot reveal broker-side bracket creation or slippage. The live gate is still necessary, but it should use the minimum approved exposure.

During the live gate, save requested values, receiver outcome, broker order identifiers where available, protective prices, quantities, statuses, and final fills or cancellations. Test what happens when the entry is rejected or only partly filled rather than assuming protection exists. If the route's order-management semantics are not documented, ask for current product guidance; do not publish a guessed claim based on one interface snapshot.

Protection test gates and what they prove
GateProvesDoes not prove
Contract worksheetThe tick and exposure arithmetic is internally consistentThe payload or broker accepts it
Rendered JSONThe final message is syntactically valid with intended valuesThe route or account exists
HexTrade dry runThe documented route can plan the request without orderingLive broker authorization or protective-order behavior
Small live testObserved behavior for one controlled route and market stateA universal fill or behavior guarantee

Sources and methodology

HexTrade Research uses official product, exchange, regulator, and vendor documentation. Policies and platform behavior can change; follow the linked source and verify current terms before trading.

  1. 1.TradingView webhook automation HexTrade Docs, accessed Aug 30, 2026
  2. 2.Pine Script webhook payloads HexTrade Docs, accessed Aug 30, 2026
  3. 3.Symbol mapping HexTrade Docs, accessed Aug 30, 2026
  4. 4.Pine Script alerts TradingView, accessed Aug 30, 2026
  5. 5.Pine Script alerts FAQ TradingView, accessed Aug 30, 2026
  6. 6.Micro E-mini S&P 500 contract specifications CME Group, accessed Aug 30, 2026
  7. 7.Position and risk management CME Group, accessed Aug 30, 2026

Frequently asked questions

Is `sl: 20` a $20 stop loss?

No. HexTrade documents `sl` as twenty ticks. Convert that count using the exact contract's current tick size and tick value, then multiply by quantity to estimate exposure. The dollar result differs by instrument and position size.

Can I send an absolute stop price in the `sl` field?

Do not assume so. The published HexTrade webhook docs define `sl` as a tick distance, not an absolute price. If another order form is required, verify a currently documented field or supported workflow instead of overloading the tick field.

Does `dryRun` create the take-profit and stop-loss orders?

No. It validates and returns the planned trade without sending an order. Use it to check fields and units, then follow a smallest-size live test to observe broker submission, protective orders, rejection, and final state.

Can the chart's `syminfo.mintick` always calculate destination ticks?

Only when the chart context has the same minimum increment as the routed destination. A CFD, continuous contract, spread, or different future may not match. Validate the exact broker symbol and use a reviewed destination-specific input when necessary.

Do protective fields guarantee a fill at the requested price?

No. A webhook field expresses intent. Broker support, order type, market movement, liquidity, gaps, rejection, and partial execution affect outcomes. Inspect the resulting broker orders and fills; neither JSON acceptance nor a TradingView event guarantees price.

Next step

Put the research into a controlled workflow

Start small, verify the broker and account rules, and keep risk controls between every signal and live order.

Explore webhook automation

Continue reading

Educational content only. Futures are leveraged products and can produce losses greater than the amount you expected to risk. This article is not financial, legal, or prop-firm compliance advice.