Search documentation

Search every page of the Trade Wzrd docs

Automation

Strategy Setup

Build complete automated trading strategies with entry and exit signals, risk management, and a step-by-step testing workflow.

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:

text
CLOSEALL;BUY,EURUSD,VOL=0.01,SL=100,TP=200

Close all existing positions, then immediately open a new one:

text
CLOSE,{{ticker}};SELL,{{ticker}},VOL=0.01,SL=100,TP=200

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):

text
BUY,EURUSD,VOL=0.01,SL=50,TP=100,TPSLTYPE=PIPSBUY,XAUUSD,VOL=0.1,SL=2000.00,TP=2100.00

Risk-Based Position Sizing

Use the RISK parameter to size your position based on account balance instead of fixed lots:

text
BUY,EURUSD,RISK=1,SL=50,TP=100,TPSLTYPE=PIPS

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:

text
BUY,{{ticker}},VOL=0.01,SL=100,TP=200CLOSE,{{ticker}}BREAKEVEN,{{ticker}},OFFSET=0.0010

CLOSEALL Filters for Risk Management

Use CLOSEALL with filters to manage portfolio-level exits:

text
CLOSEALL,EURUSD,POSITIVE=true

Close only winning positions to lock in profits:

text
CLOSEALL,XAUUSD,NEGATIVE=true

Close only losing positions to stop the bleeding:

text
CLOSEALL,EURUSD,PENDING=true

Cancel all pending orders before a news event:

text
CLOSEALL,EURUSD,POSITIONS=true

LAYER_CLOSE for Volume-Based Exits

When you need to close a specific lot amount across multiple open positions:

text
LAYER_CLOSE,EURUSD,VOL=0.05

This closes enough trades to total 0.05 lots, starting from the oldest. Add SIDE=BUY or SIDE=SELL to filter by direction:

text
LAYER_CLOSE,EURUSD,VOL=0.03,SIDE=BUY

BREAKEVEN to Protect Profits

Move your stop loss to entry price (or entry plus an offset) to protect profits on winning trades:

text
BREAKEVEN,EURUSDBREAKEVEN,EURUSD,OFFSET=0.0010BREAKEVEN,EURUSD,OFFSET=0.0005,SIDE=BUY

Magic Numbers

Use MAGIC to tag trades from a specific strategy. This lets you selectively close or modify only trades from that strategy:

text
BUY,EURUSD,VOL=0.01,SL=100,TP=200,MAGIC=101

Later, close only these trades:

text
CLOSE,EURUSD,MAGIC=101

Direction Filtering

When closing, you can filter by direction to only close one side:

text
CLOSE,EURUSD,SIDE=BUY

This only closes BUY positions on EURUSD, leaving any SELL positions open.


Testing Workflow

  1. Build in Playground - Use Automation > Playground to construct and verify your signal format
  2. Test on demo - Connect a demo account to the webhook and send test signals
  3. Verify in Alerts - Check Automation > Alerts to confirm signals were received and executed
  4. Check Trade History - Verify trades appear in Automation > History
  5. 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:

text
BUY,{{ticker}},RISK=1,SL=50,TP=150,TPSLTYPE=PIPS,MAGIC=201

Alert 2 - Move to breakeven (triggered when price moves in profit):

text
BREAKEVEN,{{ticker}},OFFSET=0.0005,MAGIC=201

Alert 3 - Partial close (take some profit):

text
CLOSE,{{ticker}},PERCENT=50,MAGIC=201

Alert 4 - Full close (exit remaining):

text
CLOSE,{{ticker}},MAGIC=201

The MAGIC=201 tag ensures only trades from this strategy are affected by the exit alerts. All four alerts use the same webhook URL.