Home

/

Guides

/

SL/TP via Webhook

Features & SyntaxUpdated 2026-02-07

How to Send Stop Loss & Take Profit via TradingView Webhook

12 min read

2026-02-07

The Problem: SL/TP in Webhooks Is Hard

Every serious trader knows that a position without a stop loss is a ticking time bomb. Yet the vast majority of trading automation tools make it surprisingly difficult to include stop loss and take profit orders in a webhook command. Most bots require you to send separate webhook alerts for the entry, the stop loss, and the take profit. Some do not support SL/TP via webhooks at all, forcing you to place them manually on the exchange after your entry fills.

This gap between entry and protection is where real money gets lost. In crypto futures markets, price can move 2-5% in the time it takes you to open the exchange interface and place a stop loss manually. During high-volatility events like CPI releases, FOMC announcements, or liquidation cascades, that window of exposure can wipe out an entire week of gains.

The problem gets worse when you try to automate SL/TP with separate webhook alerts. TradingView fires alerts asynchronously. If your entry alert triggers but the SL alert arrives 500ms later, your position sits unprotected during that window. If the SL alert fails entirely (network glitch, rate limit, webhook timeout), your position has no downside protection at all. You might not even notice until the damage is done.

The ideal solution is straightforward: entry, stop loss, and take profit in a single, atomic command. One webhook, one execution pipeline, no gaps. That is exactly what Flipr.Cloud provides with inline SL/TP in Smart Syntax.

The cost of unprotected positions

A study of crypto futures liquidations shows that 73% of blown accounts had positions that lacked stop losses during volatile market events. Even a 30-second window without a stop loss during a flash crash can result in catastrophic losses on leveraged positions.

Three Approaches to Webhook SL/TP

Not all SL/TP implementations are created equal. Understanding the differences helps you choose the right tool and avoid nasty surprises when volatility spikes. Here are the three main approaches used by trading automation platforms, ranked from most reliable to least.

Approach 1: Native Exchange TP/SL (Best)

Native TP/SL means the stop loss and take profit orders are placed directly on the exchange's matching engine as conditional orders. Once placed, they exist independently of the bot that created them. The exchange monitors price and triggers execution internally, with sub-millisecond reaction times.

  • Orders live on the exchange's infrastructure, protected 24/7
  • Execute even if your bot, server, or internet connection goes down
  • Automatically bound to position size (exchange handles partial fills)
  • When one triggers, the exchange can clean up the other (exchange-native OCO)
  • Sub-millisecond execution latency once the trigger price is hit

This is the approach Flipr.Cloud uses by default on all exchanges that support it. When you send market long 0.01 sl off 2% tp off 5%, Flipr places native conditional orders on the exchange after your market order fills. Your protection is exchange-grade, not bot-grade.

Approach 2: OCO Polling (Good)

OCO (One-Cancels-Other) polling is a fallback mechanism where the bot places both SL and TP as separate limit/stop orders, then monitors them. When one fills, the bot cancels the other. This introduces a small delay (typically 1-5 seconds of polling interval) but works reliably on every exchange.

  • Works on exchanges that lack native TP/SL conditional orders
  • Both orders exist on the exchange (protected if bot goes offline)
  • Small cancellation delay when one side fills (1-5 seconds)
  • Flipr's OCO monitor runs as a background task with configurable polling intervals

When OCO polling is used

Flipr automatically falls back to OCO polling on exchanges like CoinEx, BitMEX, and MEXC that do not support native conditional TP/SL orders. You do not need to change your syntax. The same command works everywhere.

Approach 3: Separate Webhooks (Fragile)

This is what most competing automation tools require: one TradingView alert for the entry, a second alert for the stop loss, and a third for the take profit. Each fires as a separate HTTP request with no coordination between them.

  • Race conditions: SL webhook might arrive before entry fills
  • Partial failure: if one webhook fails, position is partially protected
  • Order of execution is not guaranteed by TradingView
  • Three alerts to manage per strategy instead of one
  • Debugging failures across three separate webhook logs is painful

If you have used tools like 3Commas, Cornix, or custom Pine Script webhook integrations, you have likely experienced these issues. The separate-webhook approach works in backtesting where execution is instant and sequential. In live markets with real latency, it breaks down at the worst possible moments.

Inline SL/TP with Smart Syntax

Flipr.Cloud's Smart Syntax lets you define entry, stop loss, and take profit in a single line of plain text. No JSON, no multiple alerts, no timing hacks. Here is the core pattern:

Single-line bracket order

BTCUSDT on Binance_F market long 0.01 sl off 2% tp off 5%

That is it. Two lines. The first line identifies the trading pair and exchange. The second line places a market order to go long 0.01 BTC, with a stop loss at 2% below the fill price and a take profit at 5% above. Flipr handles the entire execution pipeline:

  1. Market order placed - Flipr sends the market buy to the exchange and waits for fill confirmation
  2. Fill price captured - The actual entry price is recorded (not the current price, the real fill price)
  3. Stop loss placed - A native conditional stop order at the calculated SL price
  4. Take profit placed - A native conditional limit order at the calculated TP price

Total execution time for all three orders: approximately 150-300ms, depending on the exchange's API latency. Your position goes from zero to fully protected in under a third of a second.

Why fill price matters

Flipr calculates SL/TP based on your actual fill price, not the price at the time the webhook was sent. In fast markets, there can be significant slippage between the alert trigger and the fill. Using the real fill price ensures your risk:reward ratio is preserved exactly as intended.

The Prefix System Explained

One of Smart Syntax's most powerful features is the prefix system for SL/TP price calculation. Instead of hardcoding an absolute price, you specify how the price should be calculated. This eliminates errors and makes your webhooks reusable across different market conditions. Every SL/TP value requires a prefix. There are three options.

off - Offset from Current Price

The off prefix calculates the SL/TP price as an offset from the current market price at the moment of execution. This is the most commonly used prefix for strategies that define risk as a percentage of current price.

Offset examples

# Stop loss at 2% below current price (for long) market long 0.01 sl off 2% # Take profit at 5% above current price (for long) market long 0.01 tp off 5% # Both together market long 0.01 sl off 2% tp off 5% # Absolute offset (500 USDT below/above) market long 0.01 sl off 500 tp off 1200 # Short position: sides are automatically inverted # sl off 2% = 2% ABOVE current price (where you'd get stopped on a short) market short 0.01 sl off 2% tp off 5%

The off prefix is direction-aware. For long positions, sl off 2% places the stop below the current price. For short positions, it places the stop above the current price. You never need to think about the direction manually.

at / @ - Absolute Price

The at prefix (or its shorthand @) sets the SL/TP at an exact, absolute price level. Use this when you have specific support and resistance levels from your technical analysis.

Absolute price examples

# Stop loss at exactly $62,500 market long 0.01 sl at 62500 # Take profit at exactly $72,000 market long 0.01 tp at 72000 # Shorthand with @ symbol market long 0.01 sl @62500 tp @72000 # Short with absolute levels market short 0.01 sl @72000 tp @62500

Best for known levels

Use absolute pricing when your strategy is based on chart levels: support/resistance zones, Fibonacci levels, order blocks, or liquidation clusters. The price does not change regardless of when the webhook fires or what the current price is at execution time.

e - Entry-Relative

The e prefix calculates SL/TP relative to your actual entry (fill) price. This is ideal for strategies that define exits as a fixed ratio from entry, such as risk:reward systems. The entry price is captured after the market order fills, ensuring accurate calculation even with slippage.

Entry-relative examples

# Stop loss at 1.5% below entry price market long 0.01 sl e-1.5% # Take profit at 3% above entry price market long 0.01 tp e+3% # Both: classic 1:2 risk:reward market long 0.01 sl e-1% tp e+2% # 1:3 risk:reward market long 0.01 sl e-1% tp e+3% # For SHORT positions: # e+2% means 2% ABOVE entry (where you'd get stopped) # e-5% means 5% BELOW entry (where you'd take profit) market short 0.01 sl e+2% tp e-5%

The entry-relative prefix is particularly powerful for algorithmic strategies where the risk:reward ratio must remain constant regardless of the entry price. Whether BTC is at $60,000 or $100,000, your sl e-1% tp e+3% always produces a 1:3 risk:reward ratio.

Direction awareness for shorts

Pay attention to the sign when using entry-relative on short positions. For a short, your stop loss is above entry so you use sl e+2%. Your take profit is below entry so you use tp e-5%. This is the mathematical direction, not the trade direction.

Prefix Comparison at a Glance

PrefixCalculates FromBest ForExample
offCurrent market priceQuick trades, scalpingsl off 2%
at / @Absolute price levelChart levels, S/R zonessl at 62500
eYour actual fill priceR:R strategies, algossl e-1.5%

Real Examples by Scenario

Below are complete webhook message bodies for common trading scenarios. Each example shows the full text you would paste into TradingView's alert webhook message field. Copy, adapt, and use.

Scalping with Tight SL

For scalping strategies that target small moves with tight risk management. The stop loss is placed close to entry to limit downside, while the take profit captures a quick 1.5% move.

TradingView webhook message

BTCUSDT on ByBit_F market long 0.01 sl off 0.5% tp off 1.5%

Risk:reward ratio of 1:3. If BTC is at $67,000, the stop loss lands at approximately $66,665 and the take profit at approximately $68,005. Total risk: $335 per 0.01 BTC.

Swing Trade with Absolute Levels

When your strategy identifies specific support and resistance levels from the chart, use absolute pricing for precision. This is common with structure-based or order-flow analysis.

TradingView webhook message

BTCUSDT on Binance_F market long 0.01 sl at 62500 tp at 68000

The stop loss sits at $62,500 (a key support zone) and the take profit targets $68,000 (resistance). These levels do not change regardless of the exact fill price.

Risk:Reward 1:3 Strategy

For systematic strategies that maintain a constant risk:reward ratio from entry. The entry-relative prefix guarantees the ratio holds even if there is slippage on the market order fill.

TradingView webhook message

ETHUSDT on OKX_F market long 0.5 sl e-1% tp e+3%

If ETH fills at $3,450, the stop loss is placed at $3,415.50 (1% below entry) and the take profit at $3,553.50 (3% above entry). The 1:3 ratio is locked in at the moment of fill.

Multiple Take Profits (Scaling Out)

Advanced strategies often scale out of a position at multiple price levels. Flipr supports multi-line commands where you can define separate take profit levels, each closing a percentage of the position. This uses the %p suffix to specify position percentage.

TradingView webhook message

ETHUSDT on ByBit_F market long 0.1 takeprofit long 50%p tp off 3% takeprofit long 50%p tp off 6% stoploss long 100%p sl off 2%

This opens a 0.1 ETH long, then places two take profit orders: one to close 50% of the position at 3% profit, and another to close the remaining 50% at 6% profit. A single stop loss covers 100% of the position at 2% loss. As take profits fill, the stop loss quantity is automatically managed.

Why scale out?

Scaling out lets you lock in partial profits while keeping exposure for larger moves. Many professional traders take 30-50% off at the first target and let the remainder run with a breakeven stop. Smart Syntax makes this a single webhook.

Short Position with SL/TP

Short positions work identically. The off prefix automatically inverts the direction: stop loss goes above the current price and take profit goes below.

TradingView webhook message

BTCUSDT on Bitget_F market short 0.01 sl off 2% tp off 5%

If BTC is at $67,000: the stop loss is placed at approximately $68,340 (2% above), and the take profit at approximately $63,650 (5% below). You do not need to manually invert anything. The prefix system handles directionality for you.

Exchange Support Matrix

Flipr.Cloud supports stop loss and take profit on every integrated exchange, but the underlying mechanism varies. Exchanges with native TP/SL support get conditional orders placed directly on the matching engine. Exchanges without native support automatically fall back to OCO polling. Your syntax stays exactly the same either way.

ExchangeNative TP/SLOCO FallbackNotes
BinanceFull support, batch order API
ByBitFull support, hedge mode compatible
OKXFull support
BloFinFull support
BitgetFull support
BitunixNative REST API
KuCoinFull support
KrakenFull support
PhemexFull support
HTXFull support
CoinExOCO polling only
BitMEXOCO polling only
MEXCLimited, OCO polling

Transparent fallback

You never need to know which mechanism an exchange uses. Send the same command everywhere. Flipr detects exchange capabilities at connection time and routes to the optimal execution path automatically.

Bracket Orders: The Complete Package

A bracket order is the combination of an entry order, a stop loss, and a take profit into a single atomic operation. In traditional exchange interfaces, bracket orders are a dedicated order type with complex forms and exchange-specific behavior. In Smart Syntax, any order with inline SL/TP is a bracket order.

This IS a bracket order

BTCUSDT on ByBit_F market long 0.01 sl off 2% tp off 5%

The execution sequence is deterministic and atomic from your perspective:

  1. Market order sent and filled - Flipr places the market order and waits for fill confirmation from the exchange. The actual fill price is captured.
  2. Stop loss placed - Using the captured fill price and your specified offset/level, a native conditional stop order is placed on the exchange.
  3. Take profit placed - Similarly, a native conditional limit order is placed at the take profit level.
  4. Smart OCO activated - If one side triggers (SL or TP), the other is automatically cancelled. On exchanges with native OCO, this is handled by the exchange itself. On others, Flipr's background OCO monitor handles cancellation within seconds.

The entire process completes in 150-300ms. From the outside, it looks and behaves exactly like a native bracket order, but it works across every exchange Flipr supports with identical syntax.

Bracket orders with limit entries

Bracket orders also work with limit entries. Use limit long 0.01 off 1% sl off 2% tp off 5% to place a limit buy at 1% below current price, with SL and TP that activate once the limit order fills. The SL/TP are placed only after the entry fills, not immediately.

Smart Syntax bracket orders eliminate an entire class of automation bugs: the entry-without-protection problem. Whether you are running a single TradingView alert or hundreds of alerts across multiple strategies, every position is born with full protection. No gaps, no race conditions, no manual intervention required.

Single Command

Entry + SL + TP in one webhook. No separate alerts, no timing issues.

Exchange-Native

SL/TP orders live on the exchange. Protected 24/7, even if Flipr is offline.

Under 300ms

All three orders placed and confirmed in under a third of a second.

Frequently Asked Questions

Ready to Automate Your Trading?

Set up TradingView webhook automation in under 2 minutes. No JSON required. Works with 15+ exchanges.

Full Pro features • No time limit • No credit card