A complete trading strategy requires both entry and exit logic. This guide covers setting up end-to-end automation with proper risk management.
Entry + Exit Approaches
Separate Webhooks
Use one webhook for entries and another for exits. This keeps signal types organized and makes the Alerts page easier to filter.
Single Webhook
Use one webhook for all signals. The parser handles all command types through the same endpoint.
Multi-Command Signals
Use semicolons to chain entry and exit in a single signal. This ensures both commands execute together with no gap:
Close all existing positions, then immediately open a new one:
Risk Management
Always Use Stop Loss
Every entry signal should include a stop loss. Use TPSLTYPE=PIPS for pip-based distances, or use price values directly (the default):
Risk-Based Position Sizing
Use the RISK parameter to size your position based on account balance instead of fixed lots:
This risks 1% of your account balance with a 50-pip stop loss. Trade W zrd calculates the appropriate lot size automatically.
Multi-Symbol Strategies
Use the {{ticker}} placeholder for strategies that work across multiple symbols. One TradingView alert template works on any chart:
CLOSEALL Filters for Risk Management
Use CLOSEALL with filters to manage portfolio-level exits:
Close only winning positions to lock in profits:
Close only losing positions to stop the bleeding:
Cancel all pending orders before a news event:
LAYER_CLOSE for Volume-Based Exits
When you need to close a specific lot amount across multiple open positions:
This closes enough trades to total 0.05 lots, starting from the oldest. Add SIDE=BUY or SIDE=SELL to filter by direction:
BREAKEVEN to Protect Profits
Move your stop loss to entry price (or entry plus an offset) to protect profits on winning trades:
Magic Numbers
Use MAGIC to tag trades from a specific strategy. This lets you selectively close or modify only trades from that strategy:
Later, close only these trades:
Direction Filtering
When closing, you can filter by direction to only close one side:
This only closes BUY positions on EURUSD, leaving any SELL positions open.
Testing Workflow
- Build in Playground - Use Automation > Playground to construct and verify your signal format
- Test on demo - Connect a demo account to the webhook and send test signals
- Verify in Alerts - Check Automation > Alerts to confirm signals were received and executed
- Check Trade History - Verify trades appear in Automation > History
- Go live - Once satisfied, add your live account to the webhook
Complete Strategy Example
A breakout strategy with entry, breakeven, partial close, and exit - all pointing to the same webhook URL:
Alert 1 - Entry:
Alert 2 - Move to breakeven (triggered when price moves in profit):
Alert 3 - Partial close (take some profit):
Alert 4 - Full close (exit remaining):
The MAGIC=201 tag ensures only trades from this strategy are affected by the exit alerts. All four alerts use the same webhook URL.
