
Most automated traders send entry signals and hope for the best. They rely on percentage-based exits configured at the strategy level, which works until it doesn't. Different market conditions require different risk-reward ratios, and static percentage rules can't adapt.
The solution is sending dynamic take profit and stop loss parameters directly with your entry signals. This approach allows your strategy to calculate optimal exit levels based on current market structure, volatility, and technical levels, then communicate those levels to your execution platform in real-time.
TradersPost supports this capability through webhook signals that can include complete trade instructions: entry price, stop loss level, and take profit target all in one message. This guide explains how to structure these signals and why this approach improves trading outcomes.
Traditional automated trading separates entry logic from exit logic. You might configure a strategy to take profit at 5% gains and stop out at 2% losses. This works fine for strategies with consistent behavior across all market conditions.
The problem emerges when your strategy encounters different market regimes. A swing trade might need a 10% stop loss to avoid getting shaken out of good positions, while a scalp trade might need a 0.5% stop. A trend-following system might want a 3:1 risk-reward ratio, while a mean-reversion system prefers 1:1.
By calculating and sending exit parameters with each signal, your strategy can adapt exits to current conditions:
This flexibility transforms a one-size-fits-all approach into adaptive risk management that responds to market reality.
Different strategies need different exit approaches. A breakout strategy might use tight stops with 2:1 targets. A range-bound mean reversion strategy might use symmetrical exits. A momentum strategy might trail stops aggressively while letting winners run.
When you send exits with your signals, each strategy can implement its own risk management philosophy without being constrained by subscription-level settings.
TradersPost webhook signals accept JSON-formatted messages containing trade parameters. The basic structure includes action (buy/sell), ticker symbol, and quantity. But you can enhance this with stop loss and take profit objects.
A complete signal with exits looks like this in JSON format:
```json
{
"ticker": "AAPL",
"action": "buy",
"signalPrice": 150.00,
"quantity": 100,
"stopLoss": {
"type": "stop",
"stopPrice": 148.00
},
"takeProfit": {
"limitPrice": 153.00
}
}
```
This signal tells TradersPost to buy 100 shares of AAPL at $150, place a stop loss at $148, and take profit at $153. All parameters are specified explicitly, leaving nothing to assumption.
TradersPost supports three methods for defining stop loss and take profit levels, each suited to different calculation approaches.
Calculate exits as a percentage move from entry price. If you buy at $100 and want a 5% stop loss, you'd specify:
```json
"stopLoss": {
"type": "stop",
"percent": 5
}
```
TradersPost automatically calculates the stop price as $95 for long positions or $105 for short positions. The percentage always represents the loss amount, regardless of direction.
Specify exits as a fixed dollar amount from entry. For a $5 stop loss on a $100 entry:
```json
"stopLoss": {
"type": "stop",
"amount": 5.00
}
```
The stop would be placed at $95 for longs or $105 for shorts. This approach works well when you want consistent dollar risk per trade regardless of entry price.
Provide the exact stop loss or take profit price. This gives complete control and is ideal when your strategy identifies specific support/resistance levels:
```json
"stopLoss": {
"type": "stop",
"stopPrice": 95.50
}
```
The stop will be placed precisely at $95.50. This is the most common approach for technical traders who calculate exits based on chart levels.
Take profit orders close your position when price reaches your target. TradersPost handles these as limit orders that execute when your profit objective is achieved.
The simplest take profit uses just a limit price:
```json
"takeProfit": {
"limitPrice": 155.00
}
```
When price reaches $155, your position closes at that level (or better). This works for most take profit strategies.
Calculate take profit as a percentage gain from entry:
```json
"takeProfit": {
"percent": 3
}
```
For a $100 entry on a long position, this creates a limit order at $103. For shorts, it would be $97. The percentage represents your gain, automatically adjusted for direction.
Target a specific dollar profit per share:
```json
"takeProfit": {
"amount": 5.00
}
```
This places a limit order $5 away from your entry price, regardless of percentage. Useful when you want consistent dollar profits per share.
Stop losses protect capital by exiting positions when price moves against you. TradersPost supports standard stops and stop-limit orders.
A standard stop order becomes a market order when price reaches your stop level:
```json
"stopLoss": {
"type": "stop",
"stopPrice": 95.00
}
```
This executes as a market order once price touches $95, ensuring you exit the position even if that means accepting some slippage.
Stop-limit orders provide price protection but risk non-execution:
```json
"stopLoss": {
"type": "stop_limit",
"stopPrice": 95.00,
"limitPrice": 94.50
}
```
When price hits $95, a limit order is placed at $94.50. This prevents excessive slippage but means you might not exit if price gaps through your limit.
Standard stops guarantee execution but not price. Stop-limits guarantee price but not execution. For most automated strategies, standard stops are preferable because they ensure you exit bad trades.
Stop-limits make sense in highly liquid instruments where gaps are rare, or when you'd rather hold a position than exit at a terrible price during a flash crash.
The power of sending exits with signals comes from dynamic calculation based on market conditions. Here are common approaches.
Average True Range (ATR) measures current volatility. Set stops at 2x or 3x ATR below entry:
In TradingView PineScript:
```
atr_value = ta.atr(14)
stop_distance = atr_value * 2
stop_price = strategy.position_avg_price - stop_distance
```
Then send `stop_price` in your webhook signal. Your stops automatically widen during volatile periods and tighten during calm markets.
Identify key support levels and set stops just below:
```
support_level = findSupportLevel() // Your support detection logic
stop_price = support_level - (syminfo.mintick * 10) // 10 ticks below
```
Take profit at resistance:
```
resistance_level = findResistanceLevel()
take_profit_price = resistance_level - (syminfo.mintick * 5) // Just below resistance
```
This ensures your strategy respects market structure rather than arbitrary percentages.
Calculate take profit based on your stop distance to maintain consistent risk-reward:
```
stop_distance = strategy.position_avg_price - stop_price
take_profit_price = strategy.position_avg_price + (stop_distance * 2) // 2:1 RR
```
This guarantees every trade has the same risk-reward profile regardless of entry price or market conditions.
Size stops based on portfolio risk tolerance:
```
risk_per_trade = strategy.equity * 0.02 // 2% account risk
shares = risk_per_trade / stop_distance
```
While this doesn't directly affect stop placement, it illustrates how dynamic exit calculation enables sophisticated risk management.
TradingView strategies can send complete trade instructions through alert webhooks. The key is formatting your alert message correctly.
Create an alert with this message structure:
```
{
"ticker": "{{ticker}}",
"action": "{{strategy.order.action}}",
"signalPrice": {{close}},
"quantity": {{strategy.order.contracts}},
"stopLoss": {
"type": "stop",
"stopPrice": YOUR_CALCULATED_STOP
},
"takeProfit": {
"limitPrice": YOUR_CALCULATED_TARGET
}
}
```
Replace `YOUR_CALCULATED_STOP` and `YOUR_CALCULATED_TARGET` with variables from your strategy that contain the calculated prices.
In your PineScript strategy, declare variables for exits:
```
var float stop_loss_price = na
var float take_profit_price = na
if (buy_condition)
stop_loss_price := close - (ta.atr(14) * 2)
take_profit_price := close + (ta.atr(14) * 4)
strategy.entry("Long", strategy.long)
```
These variables can then be referenced in your alert message when the strategy fires a signal.
Set your alert to send to the TradersPost webhook URL for your strategy. In the alert settings:
Now whenever your strategy triggers, TradingView sends the complete trade package to TradersPost including all exit parameters.
For traders building custom signal generation systems, sending take profit and stop loss parameters through HTTP POST requests is straightforward.
```python
import requests
import json
def send_signal_with_exits(ticker, action, entry_price, stop_price, target_price, quantity):
webhook_url = "YOUR_TRADERSPOST_WEBHOOK_URL"
payload = {
"ticker": ticker,
"action": action,
"signalPrice": entry_price,
"quantity": quantity,
"stopLoss": {
"type": "stop",
"stopPrice": stop_price
},
"takeProfit": {
"limitPrice": target_price
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(webhook_url, data=json.dumps(payload), headers=headers)
return response.status_code
send_signal_with_exits(
ticker="SPY",
action="buy",
entry_price=450.00,
stop_price=447.50,
target_price=455.00,
quantity=10
)
```
This function constructs the JSON payload and sends it to TradersPost. The platform handles order creation, stop placement, and take profit execution.
In Python, you can implement sophisticated exit calculation:
```python
def calculate_exits(entry_price, atr, direction="long"):
stop_distance = atr * 2
target_distance = atr * 4 # 2:1 risk-reward
if direction == "long":
stop_price = entry_price - stop_distance
target_price = entry_price + target_distance
else:
stop_price = entry_price + stop_distance
target_price = entry_price - target_distance
return round(stop_price, 2), round(target_price, 2)
```
This calculates ATR-based exits that adapt to current volatility, then rounds to appropriate precision for the instrument.
Before deploying signals with exits to live trading, verify they work correctly in paper trading environments.
Connect your strategy to a TradersPost paper broker subscription. Send signals with various exit configurations and verify:
The paper broker simulates order execution, allowing you to test signal structure without risk.
More realistic testing uses actual broker paper trading accounts like TradeStation simulator or Tradovate demo. These accounts simulate real market conditions including slippage, fees, and order routing delays.
Connect your TradersPost strategy to a broker paper account and run your signal generation for several days. Review each trade to ensure stops and targets were placed correctly.
Watch for these frequent problems:
Test thoroughly until your signals execute perfectly every time.
Once you master basic stop loss and take profit signals, several advanced techniques become available.
Send multiple signals with different quantities and exit levels to scale out of positions:
```
Signal 1: Buy 100 shares, TP at $155
Signal 2: Buy 100 shares, TP at $160
```
TradersPost handles these as separate positions with individual take profit levels, effectively scaling out as price rises.
While TradersPost doesn't currently support trailing stops in webhook signals, you can simulate them by:
This requires more sophisticated position tracking in your signal generation system but provides trailing stop functionality.
Add time-based logic to your exit strategy:
```python
def should_exit_on_time(entry_time, current_time, max_hold_minutes=60):
time_in_trade = (current_time - entry_time).total_seconds() / 60
return time_in_trade >= max_hold_minutes
```
Send an exit signal when time expires, regardless of price levels. This prevents capital from being tied up too long in non-performing trades.
Once price moves favorably by a certain amount, update your stop to breakeven:
This locks in zero loss on trades that start working immediately.
Even experienced traders make errors when implementing take profit and stop loss signals. Awareness prevents costly mistakes.
Don't send both relative (percentage/amount) and absolute (price) parameters in the same signal. Choose one approach:
Wrong:
```json
"stopLoss": {
"type": "stop",
"percent": 2,
"stopPrice": 95.00
}
```
Right:**
```json
"stopLoss": {
"type": "stop",
"stopPrice": 95.00
}
```
TradersPost will reject signals with conflicting parameters.
When using relative exits (percentage or amount), TradersPost needs to know your entry price:
```json
{
"ticker": "AAPL",
"action": "buy",
"signalPrice": 150.00, // Required for relative calculations
"stopLoss": {
"type": "stop",
"percent": 2
}
}
```
Without `signalPrice`, relative calculations can't determine where to place stops.
Ensure stop prices make sense for your direction:
Setting a stop above your entry on a long trade creates immediate execution rather than protection.
Match decimal precision to your instrument. Stocks trade in pennies, futures in ticks, forex in pips. Round calculations appropriately:
```python
stop_price = round(calculated_stop, 2)
stop_price = round(calculated_stop * 4) / 4
```
Your profit targets should account for commissions and fees. If you need $100 profit and pay $5 in fees, target $105:
```python
target_profit = 100
estimated_fees = 5
take_profit_price = entry_price + ((target_profit + estimated_fees) / shares)
```
Otherwise, achieved targets produce less profit than expected.
Understanding how TradersPost processes stop loss and take profit signals helps you design better systems.
When TradersPost receives a signal with exits:
Both exit orders remain active until one executes or you manually cancel.
Subscription-level settings can override signal parameters. If your subscription disables stop loss, signals containing stop loss instructions won't create stop orders.
Review subscription settings to ensure they allow signal-level exit parameters:
Not all brokers support all order types. Check your broker's capabilities:
TradersPost documentation lists each broker's supported order types.
If you connect multiple subscriptions to one strategy, each receives the same signal with the same exits. All connected accounts will have identical stop loss and take profit levels.
For strategies managing different account sizes, consider sending quantity as a variable that scales with account equity rather than fixed share counts.
Sending take profit and stop loss parameters with your entry signals transforms automated trading from simple signal execution into comprehensive risk-managed trading systems. Your strategies gain the flexibility to adapt exits to market conditions, implement sophisticated risk-reward ratios, and respect technical levels.
The three methods for specifying exits (relative percentage, relative dollar amount, and absolute price) cover every common use case. Percentage-based exits work for simple strategies. Dollar amounts suit position sizing approaches. Absolute prices enable technical analysis-based trading.
Integration with TradingView through alert webhooks makes implementation straightforward for indicator-based traders. Custom Python implementations provide unlimited flexibility for quantitative traders building proprietary signal generation.
Test thoroughly in paper trading before going live. Verify that stops and targets appear at correct prices, execute as expected, and produce desired outcomes. Once confirmed, your automated trading becomes truly hands-off: entries, exits, and risk management all handled systematically.
TradersPost's support for dynamic exit parameters in webhook signals enables professional-grade automated trading accessible to retail traders. Whether you're running simple moving average crossovers or complex multi-factor models, proper exit management improves results and reduces stress.
Start by implementing basic stop losses with your signals. Once comfortable, add take profit targets. Then explore dynamic calculation methods that adjust to volatility and market structure. Over time, you'll develop exit strategies as sophisticated as your entry logic, completing the automated trading system that can run profitably without constant intervention.