OPEN-SOURCE SCRIPT

VWAP & Band Cross Strategy v6

204
VWAP & Band Cross Strategy v6: Script Summary

This Pine Script implements a highly flexible, multi-layered trading strategy centered around the Volume Weighted Average Price (VWAP) and its associated Standard Deviation Bands.

The strategy is designed to test various entry/exit models based on how the price interacts with the central VWAP line and the upper/lower volatility bands, with extensive risk management and confirmation filters.

1. Core Mechanics (VWAP & Bands)

VWAP Calculation: Calculates the VWAP based on a user-defined source (default is the close price).

Standard Deviation Bands: Creates upper and lower bands by calculating the standard deviation of the price (over 20 periods by default) and multiplying it by a user-defined Multiplier (default is 2.0). These bands dynamically expand and contract with volatility.

Plotting: The script clearly plots the VWAP (purple), the Upper Band (green), and the Lower Band (red), with a colored fill between the bands.

2. Entry Triggers

The core entry logic is based on a single, user-selected cross event between the price and the VWAP/Bands. The user can choose from six predefined entry types:

Entry Type Category

Entry Trigger (Long)

Entry Trigger (Short)

Mean Reversion

Price crosses over the Lower Band.

Price crosses under the Upper Band.

Trend Following

Price crosses over the Upper Band (Breakout).

Price crosses under the Lower Band (Breakout).

VWAP Cross

Price crosses over the VWAP.

Price crosses under the VWAP.

3. Filters and Confirmation

Trades are only executed if they pass a series of optional filters, making the strategy highly customizable:

Technical Confirmation (Optional): Users can enable and configure up to three additional indicators that must align with the trade direction:

RSI: Price must be Oversold (for Long) or Overbought (for Short).

SMMA: Price must be above the SMMA (for Long) or below (for Short).

MACD: MACD line must cross the Signal line and the Histogram must be positive/negative.

Time and Day Filters: Trades are restricted to a defined Entry Start/End Hour/Minute window, and only execute on user-selected Trading Days of the week.

Trade Direction: Can be toggled to execute Long Only, Short Only, or Both.

4. Advanced Risk Management (Daily Limits)

The strategy incorporates robust daily limits that reset at a configured Daily Reset Hour/Minute:

Daily Profit/Loss Limits: If the running total of Realized PnL (closed trades) + Unrealized PnL (open position) exceeds a user-defined Daily Take Profit (in Ticks) or falls below the Daily Stop Loss (in Ticks), the strategy locks out new trades and immediately closes any open position.

Max Daily Trades: Prevents the strategy from entering more than a specified number of trades per day.

5. Exit Logic

The strategy exit is also highly configurable via the Exit Type setting:

Fixed Ticks / ATR / Capped ATR: If one of these is selected, the script calculates a static Stop Loss and Take Profit level upon entry, using either fixed tick values or dynamic values based on the Average True Range (ATR), which are then executed using Pine Script's strategy.exit function.

Cross Exits (VWAP/Bands): If selected, the position is closed when the price crosses the VWAP or a specific band in the opposite direction.

End-of-Day Close: An unconditional exit that closes all open positions at a user-defined Close All Hour/Minute, regardless of profit/loss or limit status, preventing positions from being held overnight.

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.