OPEN-SOURCE SCRIPT

VWAP Strategy

2 238
VWAP and volatility filters for structured intraday trades.

How the Strategy Works

1. VWAP Anchored to Session
VWAP is calculated from the start of each trading day.
Standard deviations are used to create bands above/below the VWAP.

2. Entry Triggers: Al Brooks H1/H2 and L1/L2
  • H1/H2 (Long Entry): Opens below 2nd lower deviation, closes above it.
  • L1/L2 (Short Entry): Opens above 2nd upper deviation, closes below it.


3. Volatility Filter (ATR)
  • Skips trades when deviation bands are too tight (< 3 ATRs).


4. Stop Loss
  • Based on the signal bar’s high/low ± stop buffer.
  • Longs: signalBarLow - stopBuffer
  • Shorts: signalBarHigh + stopBuffer


5. Take Profit / Exit Target
Exit logic is customizable per side:
VWAP, Deviation Band, or None

6. Safety Exit
  • Exits early if X consecutive bars go against the trade.
  • Longs: X red bars
  • Shorts: X green bars


Explanation of Strategy Inputs
- Stop Buffer: Distance from signal bar for stop-loss.
- Long/Short Exit Rule: VWAP, Deviation Band, or None
- Long/Short Target Deviation: Standard deviation for target exit.
- Enable Safety Exit: Toggle emergency exit.
- Opposing Bars: Number of opposing candles before safety exit.
- Allow Long/Short Trades: Enable or disable entry side.
- Show VWAP/Entry Bands: Toggle visual aids.
- Highlight Low Vol Zones: Orange shading for low volatility skips.

Tuning Tips
- Stop buffer: Use 1–5 points.
- Target deviation: Start with VWAP. In strong trends use 2nd deviation and turn off the counter-trend entry.
- Safety exit: 3 bars recommended.
- Disable short/long side to focus on one type of reversal.

Backtest Setup Suggestions
- initial_capital = 2000
- default_qty_value = 1 (fixed contracts or percent-of-equity)

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.