y71256

Volume Profile cheap copy

In the absence of TradingView's open-source Volume Profile (hereinafter referred to as VP) indicator code, I have replicated it. However, because this code is classified as an "indicator" rather than a "tool," it cannot allow users to define the range according to their preferences. In the code, I have set different periods, and users can input 0, 1, or 2 to let the indicator calculate the volume distribution from the earliest candle to the latest candle within the daily, weekly, or monthly range, respectively.

How can we prove that this code is consistent with TradingView's algorithm?
Firstly, the calculation or drawing process of VP starts from the earliest candle in the selected range. After calling TradingView's built-in "Fixed Range Volume Profile" (FRVP) tool, you can enter the settings interface of the tool and check both "developing POC" and "Value Area (VA)." The paths of POC, VAH, and VAL will appear in the chart. These paths are the changes in the values of POC, VAH, and VAL as the number of candles increases. If the paths shown by my indicator are the same as those shown by TradingView's VP indicator, then it proves the algorithms are consistent. Since VP itself is calculated based on volume, the high and low points of candles, and the opening and closing prices, if the data sources are consistent, the calculation results (the paths of POC, VAH, and VAL) will remain consistent over time. This can be used to infer that the algorithms are consistent. Additionally, the parameters of the two indicators (number of rows and value area ratio) must be the same to verify consistency. The number of rows in the indicator is usually set to 100 by default, and the value area ratio is 70. Therefore, the parameters in FRVP should also be set to 100 rows and a value area volume of 70.

Why is there a noticeable discrepancy?
When the start and end points of the VP remain unchanged, reducing the chart's time frame can improve accuracy. For example, when calculating the weekly VP, switching from a 1-hour time frame to a 5-minute time frame can make the indicator more closely match TradingView's native VP. Tests have shown that TradingView's native VP may not use the data displayed on the current chart for its calculations. For instance, the VP may use data from the 5-minute time frame even if the chart is displayed in the 1-hour time frame. However, my replicated VP calculates based on the chart's data, so differences in time frames will affect accuracy.

Current algorithm deficiencies
This replicated VP code is merely a demo and does not handle data updates. In other words, after the latest candle closes, the VP needs to be recalculated, but this recalculation step is not handled, which will cause errors. To resolve this issue, you only need to switch the time frame or delete the indicator and re-add it.
보호된 스크립트입니다
이 스크립트는 클로즈 소스로 게시되며 자유롭게 사용할 수 있습니다. 당신은 스크립트를 차트에 사용하기 위해 그것을 즐겨찾기 할 수 있습니다. 소스 코드는 보거나 수정할 수 없습니다.
면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?