TradingView

Chart VWAP

TradingView 已更新   
█  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.


發布通知:
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.

Get $15 worth of TradingView Coins for you and a friend: www.tradingview.com/share-your-love/

Read more about the new tools and features we're building for you: www.tradingview.com/blog/en/
開源腳本

本著真正的TradingView精神,該腳本的作者將其開源發布,以便交易者可以理解和驗證它。為作者喝彩吧!您可以免費使用它,但在出版物中重複使用此代碼受網站規則的約束。 您可以收藏它以在圖表上使用。

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。

想在圖表上使用此腳本?