Library "Casa_VolumeProfileSession" Analyzes price and volume during regular trading hours to provide a session volume profile, including Point of Control (POC), Value Area High (VAH), and Value Area Low (VAL). Calculates and displays these levels historically and for the developing session. Offers customizable visualization options for the Value Area, POC, histogram, and labels. Uses lower timeframe data for increased accuracy and supports futures sessions. The number of rows used for the volume profile can be fixed or dynamically calculated based on the session's price range and the instrument's minimum tick increment, providing optimal resolution.
calculateEffectiveRows(configuredRows, dayHigh, dayLow) Determines the optimal number of rows for the volume profile, either using the configured value or calculating dynamically based on price range and tick size Parameters: configuredRows (int): User-specified number of rows (0 means auto-calculate) dayHigh (float): Highest price of the session dayLow (float): Lowest price of the session Returns: The number of rows to use for the volume profile
debug(vp, position) Helper function to write some information about the supplied SVP object to the screen in a table. Parameters: vp (Object): The SVP object to debug position (string): The position.* to place the table. Defaults to position.bottom_center
getLowerTimeframe() Depending on the timeframe of the chart, determines a lower timeframe to grab volume data from for the analysis Returns: The timeframe string to fetch volume for
get(volumeProfile, lowerTimeframeHigh, lowerTimeframeLow, lowerTimeframeVolume, lowerTimeframeTime, lowerTimeframeSessionIsMarket) Populated the provided SessionVolumeProfile object with vp data on the session. Parameters: volumeProfile (Object): The SessionVolumeProfile object to populate lowerTimeframeHigh (array<float>): The lower timeframe high values lowerTimeframeLow (array<float>): The lower timeframe low values lowerTimeframeVolume (array<float>): The lower timeframe volume values lowerTimeframeTime (array<int>): The lower timeframe time values lowerTimeframeSessionIsMarket (array<bool>): The lower timeframe session.ismarket values (that are futures-friendly)
drawPriorValueAreas(todaySessionVolumeProfile, extendYesterdayOverToday, showLabels, labelSize, pocColor, pocStyle, pocWidth, vahlColor, vahlStyle, vahlWidth, vaColor) Given a SessionVolumeProfile Object, will render the historical value areas for that object. Parameters: todaySessionVolumeProfile (Object): The SessionVolumeProfile Object to draw extendYesterdayOverToday (bool): Defaults to true showLabels (bool): Defaults to true labelSize (string): Defaults to size.small pocColor (color): Defaults to #e500a4 pocStyle (string): Defaults to line.style_solid pocWidth (int): Defaults to 1 vahlColor (color): The color of the value area high/low lines. Defaults to #1592e6 vahlStyle (string): The style of the value area high/low lines. Defaults to line.style_solid vahlWidth (int): The width of the value area high/low lines. Defaults to 1 vaColor (color): The color of the value area background. Defaults to #00bbf911)
drawHistogram(volumeProfile, bgColor, showVolumeOnHistogram) Given a SessionVolumeProfile object, will render the histogram for that object. Parameters: volumeProfile (Object): The SessionVolumeProfile object to draw bgColor (color): The baseline color to use for the histogram. Defaults to #00bbf9 showVolumeOnHistogram (bool): Show the volume amount on the histogram bars. Defaults to false.
Object Object Contains all settings and calculated values for a Volume Profile Session analysis Fields: numberOfRows (series int): Number of price levels to divide the range into. If set to 0, auto-calculates based on price range and tick size valueAreaCoverage (series int): Percentage of total volume to include in the Value Area (default 70%) trackDevelopingVa (series bool): Whether to calculate and display the Value Area as it develops during the session valueAreaHigh (series float): Upper boundary of the Value Area - price level containing specified % of volume pointOfControl (series float): Price level with the highest volume concentration valueAreaLow (series float): Lower boundary of the Value Area startTime (series int): Session start time in Unix timestamp format endTime (series int): Session end time in Unix timestamp format dayHigh (series float): Highest price of the session dayLow (series float): Lowest price of the session step (series float): Size of each price row (calculated as price range divided by number of rows) pointOfControlLevel (series int): Index of the row containing the Point of Control valueAreaHighLevel (series int): Index of the row containing the Value Area High valueAreaLowLevel (series int): Index of the row containing the Value Area Low lastTime (series int): Tracks the most recent timestamp processed volumeRows (map<int, float>): Stores volume data for each price level row (key=row number, value=volume) ltfSessionHighs (array<float>): Stores high prices from lower timeframe data ltfSessionLows (array<float>): Stores low prices from lower timeframe data ltfSessionVols (array<float>): Stores volume data from lower timeframe data
Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.