OPEN-SOURCE SCRIPT

Granular Candle-by-Candle VWAP

Granular Candle-by-Candle VWAP is a customizable Volume Weighted Average Price (VWAP) indicator designed for TradingView. Unlike traditional VWAP indicators that operate on the chart's primary timeframe, this script enhances precision by incorporating lower timeframe (e.g., 1-minute) data into VWAP calculations. This granular approach provides traders with a more detailed and accurate representation of the average price, accounting for intra-bar price and volume movements. The indicator dynamically adjusts to the chart's current timeframe and offers a range of customization options, including price type selection, visual styling, and alert configurations.

Customizable Features
Users have extensive control over various aspects of the Granular Candle-by-Candle VWAP indicator. Below are the key features that can be customized to align with individual trading preferences:

🎛️ Customizable Features
Users have extensive control over various aspects of the Granular Candle-by-Candle VWAP indicator. Below are the key features that can be customized to align with individual trading preferences:

🔢 Lookback Period
  1. Description: Defines the number of lower timeframe bars used in the VWAP calculation.
  2. Customization:
  3. Input: VWAP Lookback Period (Number of Lower Timeframe Bars)
  4. Default Value: 20 bars
  5. Range: Minimum of 1 bar
  6. Purpose: Allows traders to adjust the sensitivity of the VWAP. A smaller lookback period makes the VWAP more responsive to recent price changes, while a larger period smoothens out fluctuations.

📈 Price Type Selection
  1. Description: Determines which price metric is used in the VWAP calculation.
  2. Customization:
  3. Input: Price Type for VWAP Calculation
  4. Options:
  5. Open: Uses the opening price of each lower timeframe bar.
  6. High: Uses the highest price of each lower timeframe bar.
  7. Low: Uses the lowest price of each lower timeframe bar.
  8. Close: Uses the closing price of each lower timeframe bar.
  9. OHLC/4: Averages the Open, High, Low, and Close prices.
  10. HL/2: Averages the High and Low prices.
  11. Typical Price: (High + Low + Close) / 3
  12. Weighted Close: (High + Low + 2 × Close) / 4
  13. Default Value: Close
  14. Purpose: Offers flexibility in how the average price is calculated, allowing traders to choose the price metric that best fits their analysis style.

🕒 Lower Timeframe Selection
  1. Description: Specifies the lower timeframe from which data is fetched for granular VWAP calculations.
  2. Customization:
  3. Input: Lower Timeframe for Granular Data
  4. Default Value: 1 minute ("1")
  5. Options: Any valid TradingView timeframe (e.g., "1", "3", "5", "15", etc.)
  6. Purpose: Enables traders to select the granularity of data used in the VWAP calculation, enhancing the indicator's precision on higher timeframe charts.

🎨 VWAP Line Customization
  1. Description: Adjusts the visual appearance of the VWAP line based on price position relative to the VWAP.
  2. Customizations:
  3. Color When Price is Above VWAP:
  4. Input: VWAP Color (Price Above)
  5. Default Value: Green
  6. Color When Price is Below VWAP:
  7. Input: VWAP Color (Price Below)
  8. Default Value: Red
  9. Line Thickness:
  10. Input: VWAP Line Thickness
  11. Default Value: 2
  12. Range: Minimum of 1
  13. Line Style:
  14. Input: VWAP Line Style
  15. Options: Solid, Dashed, Dotted
  16. Default Value: Solid
  17. Purpose: Enhances visual clarity, allowing traders to quickly assess price positions relative to the VWAP through color coding and line styling.

🔔 Alerts and Notifications
  1. Description: Provides real-time notifications when the price crosses the VWAP.
  2. Customizations:
  3. Enable/Disable Alerts:
  4. Input: Enable Alerts for Price Crossing VWAP
  5. Default Value: Enabled (true)
  6. Alert Conditions:
  7. Price Crossing Above VWAP:
  8. Trigger: When the closing price crosses from below to above the VWAP.
  9. Alert Message: "Price has crossed above the Granular VWAP."
  10. Price Crossing Below VWAP:
  11. Trigger: When the closing price crosses from above to below the VWAP.
  12. Alert Message: "Price has crossed below the Granular VWAP."
  13. Purpose: Keeps traders informed of significant price movements relative to the VWAP, facilitating timely trading decisions.

📊 Plotting and Visualization
  1. Description: Displays the calculated Granular VWAP on the chart with user-defined styling.
  2. Customization Options:
  3. Color, Thickness, and Style: As defined in the VWAP Line Customization section.
  4. Track Price Feature:
  5. Parameter: trackprice=true
  6. Function: Ensures that the VWAP line remains visible even when the price moves far from the VWAP.
  7. Purpose: Provides a clear and persistent visual reference of the VWAP on the chart, aiding in trend analysis and support/resistance identification.

⚙️ Performance Optimizations
  1. Description: Ensures the indicator runs efficiently, especially on higher timeframes with large datasets.
  2. Strategies Implemented:
  3. Minimized Security Calls: Utilizes two separate request.security calls to fetch necessary data, balancing functionality and performance.
  4. Efficient Calculations: Employs built-in functions like ta.sum for rolling calculations to reduce computational load.
  5. Conditional Processing: Alerts are processed only when enabled, preventing unnecessary computations.
  6. Purpose: Maintains smooth chart performance and responsiveness, even when using lower timeframe data for granular calculations.

Volume Weighted Moving Average (VWMA)

สคริปต์โอเพนซอร์ซ

ด้วยเจตนารมณ์หลักของ TradingView ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถเข้าใจและตรวจสอบได้ ต้องขอบคุณผู้เขียน! ที่ให้คุณใช้ได้ฟรี แต่การนำโค้ดนี้ไปใช้ในการเผยแพร่ซ้ำจะต้องอยู่ภายใต้ กฎระเบียบการใช้งาน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้

ต้องการที่จะใช้สคริปต์นี้บนชาร์ตใช่ไหม?

คำจำกัดสิทธิ์ความรับผิดชอบ