Biên tập viên chọn
OPEN-SOURCE SCRIPT

Chart VWAP

Cập nhật
█  OVERVIEW


This indicator displays a ​Volume-Weighted Average Price anchored to the leftmost visible bar of the chart. It dynamically recalculates when the chart's visible bars change because you scroll or zoom your chart.

If you are not already familiar with ​VWAP, our Help Center will get you started. The typical ​VWAP is designed to be used on intraday charts, as it resets at the beginning of the day. Our Rolling ​VWAP, instead, resets on a rolling time window. You may also find the VWAP Auto Anchored built-in indicator worth a try.



█  HOW TO USE IT


Load the indicator on an active chart (see the Help Center if you don't know how). By default, it displays the chart's ​VWAP in orange and a simple average of the chart's visible close values in gray. This average can be used as a companion to the ​VWAP, since both are calculated from the same set of bars. The script's settings allow you to hide it.

You may also use the script's settings to enable the display of the chart's OHLC (open, high, low, close) levels and the values of the high and low. These are also calculated from the range of visible bars. You can complement the high and low lines with their price and their distance in percent from the chart's latest visible close. You can use the levels to quickly identify the distances from extreme points in the visible price range, as well as observe the visible chart's beginning and end prices.



█  NOTES FOR Pine Script™ CODERS


This script showcases three novelties:
 • Dynamic recalculation on visible bars
 • The VisibleChart library by PineCoders
 • The new `anchor` parameter of ta.vwap()


Dynamic recalculation on visible bars

This script behaves in a novel way made possible by the recent introduction of two new built-in variables: chart.left_visible_bar_time and chart.right_visible_bar_time, which return the opening time of the leftmost and rightmost visible bars on the chart. These are only two of many new built-ins in the `chart.*` namespace. See this blog post for more information, or look up them up by typing "chart." in the Pine Script™ Reference Manual.

Any script using chart.left_visible_bar_time or chart.right_visible_bar_time acquires a unique property, which triggers its recalculation when traders scroll or zoom their chart, causing the range of visible bars to change. This new capability is what makes it possible for this script to calculate its ​VWAP on the chart's visible bars only, and dynamically recalculate if the user scrolls or zooms their chart.

This script is just a start to the party; endless uses for indicators that redraw on changes to the chart will no doubt emerge through the hands of our community's Pine Script™ programmers.


The VisibleChart library by PineCoders

The newly published VisibleChart library is designed to help programmers benefit from the new capabilities made possible by the fact that Pine Script™ code can now tell when it is executing on visible bars. The library's description, functions and example code will help programmers make the most of the new feature.

This script uses three of the library's functions:
 • `PCvc.vVwap()` calculates a ​VWAP for visible bars.
​​​​ • `PCvc.​avg()` calculates the average of a source value for visible bars only. We use it to calculate the average close (the default source).
 • `PCvc.chartXTimePct(25)` calculates a time value corresponding to 25% of the horizontal distance between visible bars, starting from the left.


The new `anchor` parameter of ta.vwap()

Our script also uses this new `anchor` parameter to reset the ​VWAP at the leftmost visible bar. See how simple the code is for the VisibleChart library's `vVwap()` function.



Look first. Then leap.


Phát hành các Ghi chú
v2

This script now includes standard deviation bands, which can be adjusted using the "Standard Deviation Multiplier" input in the script settings. The script will only display the band values on the chart if the multiplier is nonzero.
Volume Weighted Average Price (VWAP)Volume Weighted Moving Average (VWMA)

Mã nguồn mở

Theo tinh thần TradingView thực sự, tác giả của tập lệnh này đã xuất bản dưới dạng nguồn mở để các nhà giao dịch có thể hiểu và xác minh. Chúc mừng tác giả! Bạn có thể sử dụng miễn phí. Tuy nhiên, bạn cần sử dụng lại mã này theo Quy tắc nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?


Share TradingView with a friend:
tradingview.com/share-your-love/

Read more about the new tools and features we're building for you: tradingview.com/blog/en/
Ngoài ra, trên:

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