Fair value bands (Dynamic risk levels, fair value metrics)

quantifytools Premium 已更新   
— Overview

Fair value bands, like other band tools, depict dynamic points in price where price behaviour is normal or abnormal, i.e. trading at/around mean (price at fair value) or deviating from mean (price outside fair value). Unlike constantly readjusting standard deviation based bands, fair value bands are designed to be smooth and constant, based on typical historical deviations. The script calculates pivots that take place above/below fair value basis and forms median deviation bands based on this information. These points are then multiplied up to 3, representing more extreme deviations.

By default, the script uses OHLC4 and SMA 20 as basis for the bands. Users can form their preferred fair value basis using following options:

Price source
- Standard OHLC values
- HL2 (High + low / 2)
- OHLC4 (Open + high + low + close / 4)
- HLC3 (High + low + close / 3)
- HLCC4 (High + low + close + close / 4)

- Median

Once fair value basis is established, some additional customization options can be employed:

Trend mode
Direction based
Cross based

Trend modes affect fair value basis color that indicates trend direction. Direction based trend considers only the direction of the defined fair value basis, i.e. pointing up is considered an uptrend, vice versa for downtrend. Cross based trends activate when selected source (same options as price source) crosses fair value basis. These sources can be set individually for uptrend/downtrend cross conditions. By default, the script uses cross based trend mode with low and high as sources.

Cross based (downtrend not triggered) vs. direction based (downtrend triggered):

Threshold band
Threshold band is calculated using typical deviations when price is trading at fair value basis. In other words, a little bit of "wiggle room" is added around the mean based on expected deviation. This feature is useful for cross based trends, as it allows filtering insignificant crosses that are more likely just noise. By default, threshold band is calculated based on 1x median deviation from mean. Users can increase/decrease threshold band width via input menu for more/less noise filtering, e.g. 2x threshold band width would require price to cross wiggle room that is 2x wider than typical, 0x erases threshold band altogether.

Deviation bands
Width of deviation bands by default is based on 1x median deviations and can be increased/decreased in a similar manner to threshold bands.

Each combination of customization options produces varying behaviour in the bands. To measure the behaviour and finding fairest representation of fair and unfair value, some data is gathered.

— Fair value metrics

Space between each band is considered a lot, named +3, +2, +1, -1, -2, -3. For each lot, time spent and volume relative to volume moving average ( SMA 20) is recorded each time price is trading in a given lot:

Depending on the asset, timeframe and chosen fair value basis, shape of the distributions vary. However, practically always time is distributed in a normal bell curve shape, being highest at lots +1 to -1, gradually decreasing the further price is from the mean. This is hardly surprising, but it allows accurately determining dynamic areas of normal and abnormal price behaviour (i.e. low risk area between +1 and -1, high risk area between +-2 to +-3). Volume on the other hand is typically distributed the other way around, being lowest at lots +1 to -1 and highest at +-2 to +-3. When time and volume are distributed like so, we can conclude that 1) price being outside fair value is a rare event and 2) the more price is outside fair value, the more anomaly behaviour in volume we tend to find.

Viewing metric calculations
Metric calculation highlights can be enabled from the input menu, resulting in a lot based coloring and visibility of each lot counter (time, cumulative relative volume and average relative volume ) in data window:

— Alerts

Available alerts are the following:

- High crossing deviation band (bands +1 to +3 )
- Low crossing deviation band (bands -1 to -3 )
- Low at threshold band in an uptrend
- High at threshold band in a downtrend
- New uptrend
- New downtrend

- New uptrend or downtrend
- Deviation band cross (+1 or -1)
- Deviation band cross (+2 or -2)
- Deviation band cross (+3 or -3)

— Practical guide

Example #1: Risk on/risk off trend following

Ideal trend stays inside fair value and provides sufficient cool offs between the moves. When this is the case, fair value bands can be used for sensible entry/exit levels within the trend.

Example #2: Mean reversions

When price shows exuberance into an extreme deviation, followed by a stall and signs of exhaustion (wicks), an opportunity for mean reversion emerges. The higher the deviation, the more volatility in the move, the more signalling of exhaustion, the better.

Example #3: Tweaking bands for desired behaviour

The faster the length of fair value basis, the more momentum price needs to hit extreme deviation levels, as bands too are moving faster alongside price. Decreasing fair value basis length typically leads to more quick and aggressive deviations and less steady trends outside fair value.


Fixed a bug causing settings table to occasionally show incorrect price sources.

1. Fixed a bug causing chart to scale out on enabling metric highlights. If you experienced chart "disappearing", this should fix it.
2. Added inputs for adjusting table position and size.

🔸 Like what you see?

🍥 Check out @quantifytools for more pragmatic, sleek and free tools.

🍥 New releases will drop regularly, follow us to stay in the loop 🔔

本著真正的TradingView精神,該腳本的作者將其開源發布,以便交易者可以理解和驗證它。為作者喝彩吧!您可以免費使用它,但在出版物中重複使用此代碼受網站規則的約束。 您可以收藏它以在圖表上使用。