TradingView
LuxAlgo
25 apr 2024 15:28

Volume Profile with Node Detection [LuxAlgo] 

Bitcoin all time history indexINDEX

Descrizione

â‹…
The Volume Profile with Node Detection is a charting tool that allows visualizing the distribution of traded volume across specific price levels and highlights significant volume nodes or clusters of volume nodes that traders may find relevant in utilizing in their trading strategies.

🔶 USAGE



The volume profile component of the script serves as the foundation for node detection while encompassing all the essential features expected from a volume profile. See the sub-sections below for more detailed information about the indicator components and their usage.

🔹 Peak Volume Node Detection

A volume peak node is identified when the volume profile nodes for the N preceding and N succeeding nodes are lower than that of the evaluated one.



Displaying peak volume nodes along with their surrounding N nodes (Zones or Clusters) helps visualize the range, typically representing consolidation zones in the market. This feature enables traders to identify areas where trading activity has intensified, potentially signaling periods of price consolidation or indecision among market participants.



🔹 Trough Volume Node Detection

A volume trough node is identified when the volume profile nodes for the N preceding and N succeeding nodes are higher than that of the evaluated one.



🔹 Highest and Lowest Volume Nodes

Both the highest and lowest volume areas play significant roles in trading. The highest volume areas typically represent zones of strong price acceptance, where a significant amount of trading activity has occurred. On the other hand, the lowest volume areas signify price levels with minimal trading activity, often indicating zones of price rejection or areas where market participants have shown less interest.



🔹 Volume profile

Volume profile is calculated based on the volume of trades that occur at various price levels within a specified timeframe. It divides the price range into discrete price intervals, typically known as "price buckets" or "price bars," and then calculates the total volume of trades that occur at each price level within those intervals. This information is then presented graphically as a histogram or profile, where the height of each bar represents the volume of trades that occurred at that particular price level.



🔶 SETTINGS

🔹 Volume Nodes

  • Volume Peaks: Toggles the visibility of either the "Peaks" or "Clusters" on the chart, depending on the specified percentage for detection.
  • Node Detection Percent %: Specifies the percentage for the Volume Peaks calculation.
  • Volume Troughs: Toggles the visibility of either the "Troughs" or "Clusters" on the chart, depending on the specified percentage for detection.
  • Node Detection Percent %: Specifies the percentage for the Volume Troughs calculation.
  • Volume Node Threshold %: A threshold value specified as a percentage is utilized to detect peak/trough volume nodes. If a value is set, the detection will disregard volume node values lower than the specified threshold.
  • Highest Volume Nodes: Toggles the visibility of the highest nodes for the specified count.
  • Lowest Volume Nodes: Toggles the visibility of the lowest nodes for the specified count.


🔹 Volume Profile - Components

  • Volume Profile: Toggles the visibility of the volume profile with either classical display or gradient display.
  • Value Area Up / Down: Color customization option for the volume nodes within the value area of the profile.
  • Profile Up / Down Volume: Color customization option for the volume nodes outside of the value area of the profile.
  • Point of Control: Toggles the visibility of the point of control, allowing selection between "developing" or "regular" modes. Sets the color and width of the point of control line accordingly.
  • Value Area High (VAH): Toggles the visibility of the value area high level and allows customization of the line color.
  • Value Area Low (VAL): Toggles the visibility of the value area low level and allows customization of the line color.
  • Profile Price Labels: Toggles the visibility of the Profile Price Levels and allows customization of the text size of the levels.


🔹 Volume Profile - Display Settings

  • Profile Lookback Length: Specifies the length of the profile lookback period.
  • Value Area (%): Specifies the percentage for calculating the value area.
  • Profile Placement: Specify where to display the profile.
  • Profile Number of Rows: Specify the number of rows the profile will have.
  • Profile Width %: Adjusts the width of the rows in the profile relative to the profile range.
  • Profile Horizontal Offset: Adjusts the horizontal offset of the profile when it is selected to be displayed on the right side of the chart.
  • Value Area Background: Toggles the visibility of the value area background and allows customization of the fill color.
  • Profile Background: Toggles the visibility of the profile background and allows customization of the fill color.


🔶 RELATED SCRIPTS

Supply-Demand-Profiles
Liquidity-Sentiment-Profile

Thanks to our community for recommending this script. For more conceptual scripts and related content, we welcome you to explore by visiting >>> LuxAlgo-Scripts.

Note di rilascio

â‹…
- Improved script speed and memory efficiency
Commenti
Ether2020
â‹…
Amazing! You are a true genius! Thank you so much!
tkarolak
â‹…
I hope this message finds you well. I have been using your excellent "Volume Profile With Node Detection [LuxAlgo]" script and wanted to thank you for sharing it with the community. Recently, I encountered an issue where the script reported an error due to excessive calculation time in the volume profile loop. After investigating, I identified the portion of the code that could be optimized to prevent this issue.

Original Code:
for arrayIndex = 0 to arraySize - 1 priceLevelIndex = 0 for priceLevel = lowestPrice to highestPrice - priceStep by priceStep levelHigh = barDataArray.barHigh.get(arrayIndex) levelLow = barDataArray.barLow.get(arrayIndex) levelVolume = barDataArray.barVolume.get(arrayIndex) if levelHigh >= priceLevel and levelLow < priceLevel + priceStep volumeProportion = if levelLow >= priceLevel and levelHigh > priceLevel + priceStep (priceLevel + priceStep - levelLow) / (levelHigh - levelLow) else if levelHigh <= priceLevel + priceStep and levelLow < priceLevel (levelHigh - priceLevel) / (levelHigh - levelLow) else if levelLow >= priceLevel and levelHigh <= priceLevel + priceStep 1 else priceStep / (levelHigh - levelLow) volumeDataArray.totalVolume.set(priceLevelIndex, volumeDataArray.totalVolume.get(priceLevelIndex) + levelVolume * volumeProportion) if barDataArray.barPolarity.get(arrayIndex) volumeDataArray.bullishVolume.set(priceLevelIndex, volumeDataArray.bullishVolume.get(priceLevelIndex) + levelVolume * volumeProportion) priceLevelIndex += 1


... in next comment, I will add my suggestions
tkarolak
â‹…
Suggested Changes:

Here's the optimized version of the relevant code:
for arrayIndex = 0 to arraySize - 1 levelHigh = barDataArray.barHigh.get(arrayIndex) levelLow = barDataArray.barLow.get(arrayIndex) levelVolume = barDataArray.barVolume.get(arrayIndex) int startSlotIndex = math.max(math.floor((levelLow - lowestPrice) / priceStep), 0) int endSlotIndex = math.min(math.floor((levelHigh - lowestPrice) / priceStep), arraySize - 1) for priceLevelIndex = startSlotIndex to endSlotIndex float priceLevel = lowestPrice + priceLevelIndex * priceStep volumeProportion = switch levelLow >= priceLevel and levelHigh > priceLevel + priceStep => (priceLevel + priceStep - levelLow) / (levelHigh - levelLow) levelHigh <= priceLevel + priceStep and levelLow < priceLevel => (levelHigh - priceLevel) / (levelHigh - levelLow) levelLow >= priceLevel and levelHigh <= priceLevel + priceStep => 1 => priceStep / (levelHigh - levelLow) volumeDataArray.totalVolume.set(priceLevelIndex, volumeDataArray.totalVolume.get(priceLevelIndex) + levelVolume * volumeProportion) if barDataArray.barPolarity.get(arrayIndex) volumeDataArray.bullishVolume.set(priceLevelIndex, volumeDataArray.bullishVolume.get(priceLevelIndex) + levelVolume * volumeProportion)


Reasons for the Change
Performance Improvement: Limiting the loop range to relevant indices (startSlotIndex to endSlotIndex) significantly reduces the number of iterations, preventing unnecessary calculations through full scope of volume profile slots.
Reduced Complexity: Removing an unnecessary if statement ( if levelHigh >= priceLevel and levelLow < priceLevel + priceStep) simplifies the logic while maintaining the same functionality.
And finally, this chunk, can be moved one level up, to: "for arrayIndex = 0 to arraySize - 1" loop
levelHigh = barDataArray.barHigh.get(arrayIndex)
levelLow = barDataArray.barLow.get(arrayIndex)
levelVolume = barDataArray.barVolume.get(arrayIndex)

These changes have improved the performance and reliability of the script, and I believe they would benefit other users as well.

Thank you once again for creating such a valuable tool, and I'd be happy to assist further if needed.

Warm regards,
Tomasz
tkarolak
â‹…
@tkarolak, one more fix, I should use "vp_profileNumberOfRows" when calculating endSlotIndex:
for arrayIndex = 0 to arraySize - 1 levelHigh = barDataArray.barHigh.get(arrayIndex) levelLow = barDataArray.barLow.get(arrayIndex) levelVolume = barDataArray.barVolume.get(arrayIndex) int startSlotIndex = math.max(math.floor((levelLow - lowestPrice) / priceStep), 0) int endSlotIndex = math.min(math.floor((levelHigh - lowestPrice) / priceStep), vp_profileNumberOfRows - 1) for priceLevelIndex = startSlotIndex to endSlotIndex float priceLevel = lowestPrice + priceLevelIndex * priceStep volumeProportion = switch levelLow >= priceLevel and levelHigh > priceLevel + priceStep => (priceLevel + priceStep - levelLow) / (levelHigh - levelLow) levelHigh <= priceLevel + priceStep and levelLow < priceLevel => (levelHigh - priceLevel) / (levelHigh - levelLow) levelLow >= priceLevel and levelHigh <= priceLevel + priceStep => 1 => priceStep / (levelHigh - levelLow) volumeDataArray.totalVolume.set(priceLevelIndex, volumeDataArray.totalVolume.get(priceLevelIndex) + levelVolume * volumeProportion) if barDataArray.barPolarity.get(arrayIndex) volumeDataArray.bullishVolume.set(priceLevelIndex, volumeDataArray.bullishVolume.get(priceLevelIndex) + levelVolume * volumeProportion)
sam_m400
â‹…
wonderful script.. can you please add visible range option as well in this ?
datafinder
â‹…
Sir relative volume script of each tpo period with the corresponding tpo of previous day along with the 10 days average volume of corresponding tpo possible?
More specifically say ratio of todays 9AM bar volume and Previous days 9AM bar volume along with past 10days 9AM bar volume average will be plotted. same way 9.30 bar and so on till the close will be plotted . It will be much helpful ....Plz do.
DerRicoR
â‹…
Much THX!!!
PABR
â‹…
Great work on this indicator! Detailed, easy to use, helpful for traders.
avineshwar
â‹…
It says loops takes too long to execute.
gurumobiles6
â‹…
thanks bro love you
Altro