OPEN-SOURCE SCRIPT

Volume Profile Free MAX SLI (50 Levels Value Area VWAP) by RRB

ที่อัปเดต:
Volume Profile Free MAX SLI by RagingRocketBull 2019
Version 1.0

All available Volume Profile Free MAX SLI versions are listed below (They are very similar and I don't want to publish them as separate indicators):
ver 1.0: style columns implementation
ver 2.0: style histogram implementation
ver 3.0: style line implementation

This indicator calculates Volume Profile for a given range and shows it as a histogram consisting of 50 horizontal bars.
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 History. This is the Free MAX 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, packed to the limit, 2x SLI modes for Buy/Sell or even higher res 150 levels
- Free History: auto highest/lowest, historic poc/va levels for each session

Features:
- High-Res Volume Profile with up to 50 levels (3 implementations)
- 20-30x faster than the old Pro versions especially on lower tfs with long history
- 2x SLI modes for even higher res: 150 levels with 3x vertical SLI, 50 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 and Transparency for buy/sell levels

Usage:
- 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 SLI mode for 50 Buy/Sell or Vertical SLI for 150 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.

SLI:
- use SLI modes to extend the functionality of the indicator:
- Horiz Buy/Sell 2x SLI lets you view 50 Buy/Sell Levels at the same time
- Vertical Max_Vol 3x SLI lets you increase the resolution to 150 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. Cross check with the full range.

WARNING!
- 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


Notes:
- This code is 20x-30x faster (main for cycle is removed) especially on lower tfs with long history - only 2-3 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
- hist_base for levels still results is ugly redraw
- 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 plot 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
- 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
- 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. Gravitonium Levels Are Increasing. Unobtainium is nowhere to be found!

Links on Volume Profile and Value Area calculation and usage:
tradingview.com/wiki/Volume_Profile
stockcharts.com/school/doku.php?id=chart_school:technical_indicators:volume_by_price
onlinelibrary.wiley.com/doi/pdf/10.1002/9781118659724.app1
เอกสารเผยแพร่

All available Volume Profile Free MAX SLI versions are listed below:
ver 1.0: plot style columns implementation
ver 2.0: plot style histogram implementation
ver 3.0: plot style area implementation
ver 4.0: plot style line implementation
ver 5.0: all-in-one plot styles 1-4 implementation
ver 6.0: pinescript v4 line objects implementation

Differences between implementations:

1. style: ver 1-4: columns, histogram, area, and line respectively;
ver 5: any style;
ver 6: ps v4 line objects instead of plots;

2. internal buy/sell mode: ver 1-5: no
ver 6: yes

3. sli modes: ver 1-6: yes

4. min/max level: ver 1-3,5: manual control, auto not possible
ver 4,6: manual control, auto highest/lowest in range technically possible, but discarded

5. 100% base width/length: ver 1-5: fixed (plots);
ver 6: dynamic level length control (line objects)

6. hist_base: ver 1-3: hist_base (ugly redraw),
ver 5: depends on style used
ver 4,6: no hist_base (clean redraw)

7. level width/height: ver 1: fixed bar width, no density control (discrete equalizer), spacing instead of height control
ver 2: level density control (discrete, appears more solid due to overlapping), spacing instead of height control
ver 3: density control not needed (continuous seamless area), spacing instead of height control
ver 5: depends on style used
ver 4,6: density control not needed (continuous seamless line), line width/level height control (thickness) + log scale adjustment

8. level gaps/spacing: ver 1-3: no gaps, spacing control to eliminate gaps;
ver 5: depends on style used
ver 4,6: gaps, vertical shift, line width/level height control (thickness) + log scale adjustment to eliminate gaps, no spacing control

9. transparency: ver 1,3,4,6: good;
ver 2: mediocre transparency (density is in the way)
ver 5: depends on style used

10. cover: ver 1-5: plot side cover, nva zone cover;
ver 6: covers not needed, transparency is applied directly to line objects

Changes in ver 2.0:
- histogram implementation
- floor replaced with round for more accurate len calculation
- cover style set to area (continuous cover), cover width, cover_ext_height removed as not needed
- added level width/density
- added cover ext_length to compensate for large length/density
- added cover offset relative to zero
- fixed flipped levels offset relative to zero
- fixed end of range offset for all history
- fixed nva zone cover transparency
เอกสารเผยแพร่

ver 3.0: plot style area implementation

the cleanest of plot histbase variety
เอกสารเผยแพร่

ver 4.0: plot style line implementation

- more straightforward and clean, doesn't have histbase redraw issues for levels,
- side cover still uses plot histbase style area
- large width values produce unwanted horiz expansion beyond start/end points of a level, unlike style area => solve with zero/cover offsets. Can't be fixed in adjust width for log scale mode.
- adjust width for log scale mode may break at log(0) and log(1) extremes when level, h are < 1 => produces infinite widths, only level1 = 0 can be fixed
เอกสารเผยแพร่

ver 5.0: all-in-one plot styles 1-4 implementation

apparently, you can assign style from input using an int var instead of a string (doesn't work).
เอกสารเผยแพร่

Pros: the cleanest version of them all.
Cons: longer compile time.

Changes in ver 6.0:
- Pinescript v4 support
- line objects implementation instead of plots, clean redraw
- internal buy/sell mode using 2x25 levels. You don't have to use SLI now
- custom color/transparency for line objects
- side cover, nva zones removed - transparency is applied directly to line objects
- 100% base level length can be set from input - you can control max width of Volume Profile
- level, offset, len and width replaced with functions
- alt range highlighting option using barcolor
- shift now also affects va levels, but not VWAP levels
- show level stats option: index, price, length, buy/sell/total volumes

WARNING:
- Compilation Time: 1 min vs 35-40 sec for prev versions
- Slower redraw times 5-10 sec with level stats on especially on lower tfs with long history

Notes:
- uses Pinescript v3 compatibility framework

- Line Objects
- line objects don't use plot/histbase -> clean redraw with no limitations
- 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.
- line objects can have variable length, 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/modified, 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.
- you can change level color/transparency of line objects. Due to Pinescript limitations, only discrete values are supported.

- Internal Buy/Sell mode lets you view 2x25 Buy/Sell Levels at the same time:
- when num_levels > 25 => 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 levels (overlapping)
- volume type buy: line = buy, plot = total => line objects appear as green buy levels on top of blue total levels (overlapping)
- volume type sell: line = sell, plot = buy => line objects appear as red sell levels extending blue buy levels from the edge (no overlapping)

- Volume Profile calculation is not affected by shift, it is for visual correction only. Set shift to 0 to see the actual levels used in level stats
POCpointofcontrolVAHvalueareaVolume IndicatorvolumeanalysisVolume ProfileVolume Weighted Average Price (VWAP)

สคริปต์โอเพนซอร์ซ

ด้วยเจตนารมณ์หลักของ TradingView ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถเข้าใจและตรวจสอบได้ ต้องขอบคุณผู้เขียน! ที่ให้คุณใช้ได้ฟรี แต่การนำโค้ดนี้ไปใช้ในการเผยแพร่ซ้ำจะต้องอยู่ภายใต้ กฎระเบียบการใช้งาน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้

ต้องการที่จะใช้สคริปต์นี้บนชาร์ตใช่ไหม?

คำจำกัดสิทธิ์ความรับผิดชอบ