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. اقرأ المزيد في شروط الاستخدام.

هل تريد استخدام هذا النص البرمجي على الرسم البياني؟