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 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.
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.
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.
진정한 TradingView 정신에 따라, 이 스크립트의 저자는 트레이더들이 이해하고 검증할 수 있도록 오픈 소스로 공개했습니다. 저자에게 박수를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰에 의해 관리됩니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.