OPEN-SOURCE SCRIPT

Volume Buoyancy [LucF]

Cập nhật
█ OVERVIEW


This indicator uses simple analysis of past ​volume to determine how well it supports recent market activity. What I call Volume buoyancy measures the strength and direction of that support.



█ CONCEPTS


Buoyancy

In physics, buoyancy is the force described in Archemedes' principle:

     Any object, wholly or partially immersed in a fluid, is buoyed up by a force equal to the weight of the fluid displaced by the object.

I use the term loosely in this indicator's context, as "​Volume buoyancy" here can be directed either up or down, indicating that past ​volume displays a ​bullish or ​bearish bias.

The calculation of buoyancy begins from a target quantity of ​volume summed over n bars. We then search chart bars backward, adding the ​​volume of up and down bars in two different slots until each slot reaches the target. We then calculate two average distances: one each for the up and down bars whose ​volume was summed to reach the target. These average distances are then subtracted and the difference is divided by the farthest distance we had to go to find the target ​in either up or down bars. The last part of the calculations looks like this:



When the average distance of down bars is greater than that of up bars, buoyancy will be positive, indicating that past activity favors the upside and vice versa. The force's strength, which in the case of actual buoyancy is the weight of the displaced fluid, in our case is measured by the size of the gap between the average distance of up vs down bars in relation to the farthest distance we had to go in the past. Buoyancy is always between +1 and -1, with values higher/lower than 0.3/-0.3 typically being unsustainable.



█ HOW TO USE THE INDICATOR


Load the indicator on an active chart (see here if you don't know how).

The default configuration displays:
 • Buoyancy as a monochrome gray line.
 • A channel between buoyancy and its MA, colored in one of four colors. The MA is not plotted by default, but you can see where it is with the channel.
  The default settings use an Arnaud Legoux moving average over 20 bars.
 • A fill between the MA and the centerline, which can be one of two colors.
 • A high level at 0.30, a low level at -0.30 and the centerline at zero.

The default target is the sum of ​volume in the last 20 bars.



█ FEATURES


The indicator's settings allow you to define:
 • A higher timeframe you want the calculations to be made on. Note that you should then ensure your chart's timeframe is always lower than the higher timeframe you specified,
  as calculating on a timeframe lower than the chart's does not make much sense because the indicator is then displaying only the value of the last intrabar in the chart bar.
 • The number of bars for which to add volume to obtain the target value that will be searched for in past up and down bars.
 • The display of the buoyancy and MA lines, the channel between them and the fill between the MA line and the centerline.
 • The type and length of the MA.

Using the "Style" tab of the indicator's settings, you can change the type and width of the lines, and the level values.



█ INTERPRETATION


Buoyancy shares the properties and shortcomings of many oscillators:
 • It tends to be noisy, which is why the MA line can be helpful.
 • The safest way to use it may be as a rough sentiment indicator, i.e., by paying more attention to its bull/bear state above/below the centerline.
 • The more intrepid traders will want to use the channel between the main line and the MA, as it will provide earlier information than main line crosses of the centerline.

Decreasing the number of bars for which the source is added to calculate the target value will increase the noise level, somewhat like decreasing an MA's length would, but keep in mind that the number of bars is not the length of an MA.



█ LIMITATIONS


Under some circumstances, the indicator will display zero values because it cannot find the target in past bars. This will happen at the beginning of the dataset when not enough past bars have elapsed, or in the rarer cases anywhere in the dataset, when the target cannot be found in the `MAX_BARS_BACK` number of bars defined in the first line of the indicator's code (the default is 1000).

The calculations use a very primitive interpretation of ​volume similar to that of OBV, where all the ​volume of a bar is attributed to either the up or down slot. The indicator nonetheless produces results I think can be useful because we are not so much calculating precise buying/selling pressure as trying to build a big picture of where past activity over many bars appears to be taking price.

​Volume data is notoriously high-variance; large values that come into or exit the calculations' ​scope can produce sudden variations in results, somewhat like the drop-off effect in moving averages.



█ NOTES


 • The script can be used with any chart timeframe, including seconds.
 • Historical values will always produce the same results. In real time, values will change until the bar closes.


Phát hành các Ghi chú
v2
• Added the possibility to color chart bars using one of four methods.
• The script now uses my "ta" library's functions for the calculation of buoyancy and the MA.
Phát hành các Ghi chú
v3
• Fixed an issue where bar coloring using one of the first two modes didn't work if the corresponding line wasn't displayed.
Volume

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 đồ?


"The stock market is a device for transferring money from the impatient to the patient."
— Buffet

tradingview.com/u/PineCoders/
tradingview.com/u/TradingView/
Ngoài ra, trên:

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