Volume Profile Free Ultra SLI (100 Levels Value Area VWAP) - RRB

RagingRocketBull Diupdate   
Volume Profile Free Ultra SLI by RagingRocketBull 2019
Version 1.0

This indicator calculates Volume Profile for a given range and shows it as a histogram consisting of 100 horizontal bars.
This is basically the MAX SLI version with +50 more Pinescript v4 line objects added as levels.
It can also show Point of Control (POC), Developing POC, Value Area/ VWAP StdDev High/Low as dynamically moving levels.
Free accounts can't access Standard TradingView Volume Profile , hence this indicator.

There are several versions: Free Pro, Free MAX SLI , Free Ultra SLI , Free History. This is the Free Ultra SLI version. The Differences are listed below:
- Free Pro: 25 levels, +Developing POC, Value Area/ VWAP High/Low Levels, Above/Below Area Dimming
- Free MAX SLI: 50 levels, 2x SLI modes for Buy/Sell or even higher res 150 levels
- Free Ultra SLI: 100 levels, packed to the limit, 2x SLI modes for Buy/Sell or even higher res 300 levels
- Free History: auto highest/lowest, historic poc/va levels for each session

- High-Res Volume Profile with up to 100 levels (line implementation)
- 2x SLI modes for even higher res: 300 levels with 3x vertical SLI , 100 buy/sell levels with 2x horiz SLI
- Calculate Volume Profile on full history
- POC, Developing POC Levels
- Buy/Sell/Total volume modes
- Side Cover
- Value Area, VAH/VAL dynamic levels
- VWAP High/Low dynamic levels with Source, Length, StdDev as params
- Show/Hide all levels
- Dim Non Value Area Zones
- Custom Range with Highlighting
- 3 Anchor points for Volume Profile
- Flip Levels Horizontally
- Adjustable width, offset and spacing of levels
- Custom Color for POC/VA/ VWAP levels, Transparency for buy/sell levels

- Compilation Time: 1 min 20 sec

- specify max_level/min_level/spacing (required)
- select range (start_bar, range length), confirm with range highlighting
- select volume type: Buy/Sell/Total
- select mode Value Area/ VWAP to show corresponding levels
- flip/select anchor point to position the buy/sell levels
- use Horiz Buy/Sell SLI mode with 100 or Vertical SLI with 300 levels if needed
- use POC/Developing POC/VA/ VWAP High/Low as S/R levels. Usually daily values from 1-3 days back are used as levels for the current day.

use SLI modes to extend the functionality of the indicator:
- Horiz Buy/Sell 2x SLI lets you view 100 Buy/Sell Levels at the same time
- Vertical Max_Vol 3x SLI lets you increase the resolution to 300 levels
- you need at least 2 instances of the indicator attached to the same chart for SLI to work

1) Enable Horiz SLI:
- attach 2 indicator instances to the chart
- make sure all instances have the same min_level/max_level/range/spacing settings
- select volume type for each instance: you can have a buy/sell or buy/total or sell/total SLI . Make sure your buy volume instance is the last attached to be displayed on top of sell/total instances without overlapping.
- set buy_sell_sli_mode to true for indicator instances with volume_type = buy/sell, for type total this is optional.
- this basically tells the script to calculate % lengths based on total volume instead of individual buy/sell volumes and use ext offset for sell levels
- Sell Offset is calculated relative to Buy Offset to stack/extend sell after buy. Buy Offset = Zero - Buy Length. Sell Offset = Buy Offset - Sell Length = Zero - Buy Length - Sell Length
- there are no master/slave instances in this mode, all indicators are equal, poc/va levels are not affected and can work independently, i.e. one instance can show va levels, another - vwap .

2) Enable Vertical SLI:
- attach the first instance and evaluate the full range to roughly determine where is the highest max_vol/poc level i.e. 0..20000, poc is in the bottom half (third, middle etc) or
- add more instances and split the full vertical range between them, i.e. set min_level/max_level of each corresponding instance to 0..10000, 10000..20000 etc
- make sure all instances have the same range/spacing settings
- an instance with a subrange containing the poc level of the full range is now your master instance (bottom half). All other instances are slaves, their levels will be calculated based on the max_vol/poc of the master instance instead of local values
- set show_max_vol_sli to true for the master instance. for slave instances this is optional and can be used to check if master/slave max_vol values match and slave can read the master's value. This simply plots the max_vol value
- you can also attach all instances and set show_max_vol_sli to true in all of them - the instance with the largest max_vol should become the master

Auto/Manual Ext Max_Vol Modes:
- for auto vertical max_vol SLI mode set max_vol_sli_src in all slave instances to the max_vol of the master indicator: "VolumeProfileFree_MAX_RRB: Max Volume for Vertical SLI Mode". It can be tricky with 2+ instances
- in case auto SLI mode doesn't work - assign max_vol_sli_ext in all slave instances the max_vol value of the master indicator manually and repeat on each change
- manual override max_vol_sli_ext has higher priority than auto max_vol_sli_src when both values are assigned, when they are 0 and close respectively - SLI is disabled
- master/slave max_vol values must match on each bar at all times to maintain proper level scale, otherwise slave's levels will look larger than they should relative to the master's levels.
- Max_vol (red) is the last param in the long list of indicator outputs
- the only true max_vol/poc in this SLI mode is the master's max_vol/poc. All poc/va levels in slaves will be irrelevant and are disabled automatically. Slaves can only show VWAP levels.
- VA Levels of the master instance in this SLI mode are calculated based on the subrange, not the whole range and may be inaccurate. Cross check with the full range.

- auto mode max_vol_sli_src is experimental and may not work as expected
- you can only assign auto mode max_vol_sli_src = max_vol once due to some bug with unhandled exception/buffer overflow in Tradingview. Seems that you can clear the value only by removing the indicator instance
- sometimes you may see a "study in error state" error when attempting to set it back to close. Remove indicator/Reload chart and start from scratch
- volume profile may not finish to redraw and freeze in an ugly shape after an UI parameter change when max_vol_sli_src is assigned a max_vol value. Assign it to close - VP should redraw properly, but it may not clear the assigned max_vol value
- you can't seem to be able to assign a proper auto max_vol value to the 3rd slave instance
- 2x Vertical SLI works and tested in both auto/manual, 3x SLI - only manual seems to work (you can have a mixed mode: 2nd instance - auto, 3rd - manual)

- This code uses Pinescript v3 compatibility framework
- This code is 20x-30x faster (main for cycle is removed) especially on lower tfs with long history - only 4-5 sec load/redraw time vs 30-60 sec of the old Pro versions
- Instead of repeatedly calculating the total sum of volumes for the whole range on each bar, vol sums are now increased on each bar and passed to the next in the range making it a per range vs per bar calculation that reduces time dramatically

- 100 levels consist of 50 main plot levels and 50 line objects used as alternate levels, differences are:
- line objects are always shown on top of other objects, such as plot levels, zero line and side cover, it's not possible to cover/move them below.
- all line objects have variable lengths, use actual x,y coords and don't need side cover, while all plot levels have a fixed length of 100 bars, use offset and require cover.
- all key properties of line objects, such as x,y coords, color can be modified, objects can be moved/deleted, while this is not possible for static plot levels.
- large width values cause line objects to expand only up/down from center while their length remains the same and stays within the level's start/end points similar to an area style.
- large width values make plot levels expand in all directions (both h/v), beyond level start/end points, sometimes overlapping zero line, making them an inaccurate % length representation, as opposed to line objects/plot levels with area style.
- large width values translate into different widths on screen for line objects and plot levels.
- you can't compensate for this unwanted horiz width expansion of plot levels because width uses its own units, that don't translate into bars/pixels.
- line objects are visible only when num_levels > 50, plot levels are used otherwise

- Since line objects are lines, plot levels also use style line because other style implementations will break the symmetry/spacing between levels.
- if you don't see a volume profile check range settings: min_level/max_level and spacing, set spacing to 0 (or adjust accordingly based on the symbol's precision, i.e. 0.00001)
- you can view either of Buy/Sell/Total volumes, but you can't display Buy/Sell levels at the same time using a single instance (this would 2x reduce the number of levels). Use 2 indicator instances in horiz buy/sell sli mode for that.
- Volume Profile /Value Area are calculated for a given range and updated on each bar. Each level has a fixed length. Offsets control visible level parts. Side Cover hides the invisible parts.
- Custom Color for POC/VA/ VWAP levels - UI Style color/transparency can only change shape's color and doesn't affect textcolor, hence this additional option
- Custom Width - UI Style supports only width <= 4, hence this additional option
- POC is visible in both modes. In VWAP mode Developing POC becomes VWAP , VA High and Low => VWAP High and Low correspondingly to minimize the number of plot outputs
- You can't change buy/sell level colors from input (only transparency) - this requires 2x plot outputs => 2x reduces the number of levels to fit the max 64 limit. That's why 2 additional plots are used to dim the non Value Area zones
- You can change level transparency of line objects. Due to Pinescript limitations, only discrete values are supported.
- Inverse transp correlation creates the necessary illusion of "covered" line objects, although they are shown on top of the cover all the time
- If custom lines_transp is set the illusion will break because transp range can't be skewed easily (i.e. transp 0..100 is always mapped to 100..0 and can't be mapped to 50..0)
- transparency can applied to lines dynamically but nva top zone can't be completely removed because plot/mixed type of levels are still used when num_levels < 50 and require cover
- transparency can't be applied to plot levels dynamically from script this can be done only once from UI , and you can't change plot color for the past length bars
- All buy/sell volume lengths are calculated as % of a fixed base width = 100 bars (100%). You can't set show_last from input to change it
- Range selection/Anchoring is not accurate on charts with time gaps since you can only anchor from a point in the future and measure distance in time periods, not actual bars, and there's no way of knowing the number of future gaps in advance.
- Adjust Width for Log Scale mode now also works on high precision charts with small prices (i.e. 0.00001)
- in Adjust Width for Log Scale mode Level1 width extremes can be capped using max deviation (when level1 = 0, shift = 0 width becomes infinite)
- There's no such thing as buy/sell volume , there's just volume , but for the purposes of the Volume Profile method, assume: bull candle = buy volume , bear candle = sell volume

P.S. I am your grandfather, Luke! Now, join the Dark Side in your father's steps or be destroyed! Once more the Sith will rule the Galaxy, and we shall have peace...

Catatan Rilis: Changes in ver 2.0:

- Internal Buy/Sell mode using max 2x50 levels. You don't have to use SLI now

Internal Buy/Sell mode lets you view 2x50 Buy/Sell Levels at the same time:
- when num_levels > 50 => num_levels/2 are used, otherwise num_levels are used as buy/sell levels
- volume type total: line = sell, plot = total => line objects appear as red sell levels on top of blue total plot levels (overlapping)
- volume type buy: line = buy, plot = total => line objects appear as green buy levels on top of blue total plot levels (overlapping)
- volume type sell: line = sell, plot = buy => line objects appear as red sell levels extending blue buy plot levels from the edge (no overlapping)

- Compilation Time: 1 min 30 sec
- This indicator is packed to the max and barely fits Pinescript's limits of max 1000 vars per script
Catatan Rilis: Changes in ver 3.0:

- Custom color for line object levels

- Compilation Time: 1 min 30 sec
- This indicator is packed to the max and barely fits Pinescript's limits of max 1000 vars per script and max 50K for the compiled code size
- This script has exactly 50K compiled code size, uses max 50 line objects, uses max 64 plot outputs and ~700 of max 1000 vars
- Adding more features is not possible. It takes a lot of work to even make it compile. Please see comments on tips how to shave off a few bytes here and there.
Skrip open-source

Dalam semangat TradingView, penulis dari skrip ini telah mempublikasikannya ke sumber-terbuka, maka trader dapat mengerti dan memverifikasinya. Semangat untuk penulis! Anda dapat menggunakannya secara gratis, namun penggunaan kembali kode ini dalam publikasi diatur oleh Tata Tertib. Anda dapat memfavoritkannya untuk digunakan pada chart

Pernyataan Penyangkalan

Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.

Inggin menggunakan skrip ini pada chart?