OPEN-SOURCE SCRIPT
Cập nhật

0 Anchored VWAP Strategy - Full Suite v21

972
0 Anchored VWAP Strategy - Full Suite
Overview
The "0 Anchored VWAP Strategy - Full Suite" is a comprehensive and highly customizable trading system designed to capture momentum breakouts. At its core, the strategy anchors Volume-Weighted Average Price (VWAP) lines to significant market turning points identified by a Stochastic RSI. It provides a robust framework for both long and short trading, equipped with advanced risk management and filtering tools.

Core Logic

Momentum Identification: The strategy calculates a smoothed Stochastic RSI to detect overbought and oversold market conditions.

Dynamic Anchoring: * A High VWAP (Red Line) is anchored to the peak price when the Stochastic RSI crosses down from the overbought territory.

A Low VWAP (Green Line) is anchored to the lowest price when the Stochastic RSI crosses up from the oversold territory.

Entry & Exit: A Long position is triggered when the price breaks above the resistance of the High VWAP. Conversely, a default exit occurs if the price breaks below the support of the Low VWAP.

Advanced Features & Modules
This "Full Suite" version includes a modular set of advanced filters and exits that can be individually toggled in the settings to adapt to any asset or timeframe:

MTF Trend Filter: A Multi-Timeframe Moving Average (SMA or EMA). When enabled, trades are only taken in the direction of the macro trend (e.g., requiring the price to be above the 250-day EMA for longs), protecting against prolonged bear markets.

Volume Confirmation: Filters out fakeouts by requiring the breakout candle to have trading volume significantly higher than the recent average.

Short Selling: Fully supports short trades with mirrored logic for downtrends.

ATR Stop-Loss: A dynamic, volatility-based hard stop-loss to limit drawdowns in case the market crashes before the VWAP exit triggers.

Partial Take Profits (Scaling Out): Automatically secures profits by selling a defined percentage of the position once a specific target (in %) is reached.

Built-In Performance Dashboard
The strategy features an integrated, on-chart performance table that updates in real-time. It compares the strategy's metrics directly against a standard "Buy & Hold" approach over your defined backtest period. Metrics include:

Total Return (%)

CAGR (Compound Annual Growth Rate)

Maximum Drawdown (%) & Date of Max DD

Relative Performance (Strategy vs. Buy & Hold)

Total Number of Trades closed

Visualization
An optional "Relative Equity Curve" can be displayed directly on the main chart, scaled to the starting price of the backtest. This allows for an immediate visual comparison of how the strategy performs relative to the underlying asset's price action.
Phát hành các Ghi chú
Stoch to 47
Phát hành các Ghi chú
added Market Capital
Phát hành các Ghi chú
small BugFixes
Phát hành các Ghi chú
Bugfixes
Phát hành các Ghi chú
//Update v31: Added Exposure (Time in Market) tracking. Calmar Ratios are now strictly exposure-adjusted.
Phát hành các Ghi chú
//Update v33: Added Minimum Hold Time to prevent immediate VWAP exits after an entry.
Phát hành các Ghi chú
added Sharpe Ratio
Phát hành các Ghi chú
Update v38: Integrated Full 21-Row Performance Dashboard & frozen end-date metrics.

Thông báo miễn trừ trách nhiệm

Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.