wait - Pause Execution
Pause webhook execution for a specified duration before continuing to the next command.
What is wait?
wait pauses your webhook execution for a fixed amount of time. When the wait completes, execution continues with the next command in your script.
Common Use Cases:
Timed Order Management
Place an order, wait for fill window, then cancel if not filled
Staggered Entries
Enter position in stages with delays between each entry
Delayed Exits
Hold position for minimum time before allowing exits
Recommended: Keep Waits Under 60 Seconds
Long waits block workers and may cause webhook timeouts. While longer durations are technically possible, they are not recommended.
For longer delays:
- • Use time-based TradingView alerts (recommended)
- • Split your strategy into multiple webhooks triggered at different times
- • Chain multiple short waits if absolutely necessary
Syntax
wait <duration>Parameters
durationRequiredType: number or string | Default: 1s | Maximum: 60s
How long to wait. Can be specified with time units:
| Format | Example | Duration |
|---|---|---|
number | 10 | 10 seconds (default unit) |
ms | 500ms | 500 milliseconds |
s, sec, seconds | 30s | 30 seconds |
m, min, minutes | 1m | 60 seconds (1 minute) |
h, hr, hours | 1h | 1 hour (use with caution - blocks worker) |
Recommendation: Keep waits under 60 seconds. Long waits block webhook workers and may cause timeouts.
Real-World Examples
1. Timed Order - Cancel if Not Filled
Place a limit order, give it 30 seconds to fill, then cancel if still pending.
BTCUSDT on My_API_Key
// Place limit buy order
limit long 0.01 off 0.5% #entry
// Wait 30 seconds for fill
wait 30s
// Cancel if not filled
rem #entryIf order fills within 30s, there's nothing to cancel. If still pending, it's cancelled.
2. Staggered Entry (DCA Strategy)
Enter position in 3 stages with 20-second delays between each.
ETHUSDT on My_API_Key
// First entry - 33%
market long 33%
wait 20s
// Second entry - 33%
market long 33%
wait 20s
// Final entry - remaining balance
market long 99%Dollar-cost averaging over 40 seconds. Smooths out entry price during volatile moves.
3. Delayed Stop Loss Placement
Enter position, wait for initial volatility to settle, then place stop loss.
BTCUSDT on My_API_Key
// Enter immediately
market long 0.01
// Wait for initial volatility
wait 10s
// Now place protection
sl-or-tp short 100%p sl off 2% tp off 5%Avoids stop loss being immediately triggered by entry-related volatility.
4. Multiple Waits for Longer Delays
Need to wait 2 minutes? Chain two 60-second waits.
BTCUSDT on My_API_Key
market long 0.01
// Wait 2 minutes total
wait 60s
wait 60s
// Exit after 2 minutes
market short 100%pFor delays longer than 1 minute, chain multiple wait 60s commands.
When NOT to Use wait
For delays longer than 5 minutes, use time-based TradingView alerts instead:
- • Wait 15 min → Create alert that triggers 15 min later
- • Wait 1 hour → Use TradingView's time condition
- • Daily operations → Schedule separate daily alerts
Long waits tie up backend resources. Time-based alerts are more efficient.
Best Practices
Keep waits under 60 seconds - Maximum enforced limit
Use with rem for timed orders - Common pattern: place → wait → rem
Consider market volatility - In fast markets, even 10s can be significant
Use TradingView for long delays - Better than chaining many wait commands
Related Commands
rem- Often used after wait to cancel unfilled orders
limit- Place timed entry orders
market- Staggered entries with waits between