Auto-magnifier / quantifytools- Overview
Auto-magnifier shows a lower timeframe view of candles and volume bars inside any main timeframe candle by zooming into it. Candles and volume bars as they develop are shown chronologically from left to right. By default, magnifier is triggered when less than 3 candles are visible on the chart.
By default, 20 lower timeframe candles are displayed by splitting main timeframe into 20 parts. The amount of candles displayed is a target rate, meaning the script will use a lower timeframe that has the closest match to 20 candles and therefore will vary a bit. Users can override automatic timeframe calculation and opt in to display any specific lower timeframe or adjust amount of candles shown (e.g. 20 -> 30 candles) per each main timeframe candle.
Example
Main timeframe set to 30 minute, candles displayed set to 20 -> Magnifying using 2 minute candles (30 minute/20 candles = 1.5 min, rounded to 2 min)
Main timeframe set to 30 minute, override set to 5 minutes -> Displaying 5 minute candles
Size of volume bars is calculated using relative volume (volume relative to volume SMA20), lowest bar representing relative volume values of under or equal to 1x the moving average and from there onwards progressively growing.
- Limitations and considerations
Amount of candles shown might flow over from the background on smaller screen sizes, in which case you would want to decrease the amount shown. Opposite is true for bigger screens, this value can be increased as more candles fit.
This indicator involves a lot of tricks with text elements to make it work automatically by zooming in. Size of wicks, bodies and volume bars are calculated by adding more text elements on big candles and less text elements on smaller candles. This means the displayed candles won't be a 100% match, but a rather a fair representation of the view, e.g. candle is green = lower timeframe candle is green, candle has a big wick = lower timeframe candle has a big wick (but not a 100% match).
Example
Magnified lower timeframe chart vs. Actual lower timeframe chart
Most mismatch will be found on the price levels where lower timeframe candles are shown, which is sacrificed for the sake of getting a better readability on the overall shape of lower timeframe price action. Users can alternatively optimize calculations for more accuracy, giving a better representation of the price levels where candles truly originated. This typically comes with the cost of worse readability however.
Example
Optimized for readability vs. Optimized for accuracy
- Visuals
All visual elements are fully customizable.
Quantifytools
Broad market index / quantifytools- Overview
Broad market index is a market breadth based oscillator, depicting broad market trend by analysing ratio between symbols moving up and symbols moving down in a given market. When market breadth is positive, more symbols are going up and when negative, more symbols are going down. As markets tend to correlate, broad market trend dictates likely path for all individual symbols that make up the market.
This tool provides market breadth for US equities (based on NYSE advancers - decliners) and ability to build two custom breadth baskets with up to 39 symbols included in each. Market breadth can be customized with variety of smoothing options, weighting and threshold modes to find most optimal rules for trend following. Performance of the model is reflected on metrics showing percentage of up/down moves during bullish/bearish states.
Example
↑ 63% = 63% of price moves during positive breadth state are to the upside
↓ 59% = 59% of price moves during negative breadth state are to the downside
Breadth state is colorized on line and chart according to its state (negative/positive/equilibrium) and direction (trending up/down). Upper and lower bands depict historical turning points in breadth for identifying extremes in broad market trend. Triangles mark breadth thrusts, in other words abnormally large moves in breadth at either upper or lower extreme. Breadth thrusts can serve as early signs of broad market trend reverting.
- Concept and features
By default, market breadth is calculated based on NYSE advancers - decliners, usable for all major indices that depict broad markets in US equities (SP500, QQQ, IWM). Users can also build 2 custom breadth baskets consisting of up to 39 symbols for defining broad market on other asset classes, such as cryptocurrencies. Custom baskets are suitable for any chart that fairly represents a market as a whole.
Example
Basket consisting of cryptocurrencies = Use on CRYPTOCAP:TOTAL (all cryptocurrencies aggregated)
Basket consisting of healthcare stocks = Use on AMEX:XLV (healthcare sector ETF)
Breadth line can be further refined using various smoothing options (SMA, EMA, HMA, RMA, WMA), threshold method and weights. By default, threshold (dividing line between bullish and bearish states) is set to fixed at 0, depicting an equilibrium where equal amount of symbols are going up and down.
Threshold mode can also be set to Dynamic, switching threshold to a moving average of the breadth line. Fundamental functionality still remains, breadth line above threshold marks bullish state and below threshold marks bearish state. Difference here is that the threshold no longer depicts a point of equilibrium, but simply a smoothed version of the breadth line itself, which can catch turns in broad market trend earlier.
Breadth basket can be adjusted to volatility of the viewed chart, causing an overstating of breadth on high volatility and understating on low volatility. Weighting takes into account magnitude of up/down moves, which can provide better relevance for trend following purposes.
- Practical guide
Example #1 : Broad market trend
The utility of market breadth is based on the idea that markets correlate and individual symbols making up the market will eventually join the broad market trend. With this in mind, going against broad market is like swimming upstream, it's going to be the hard way. A well performing basket with clear skew for upside and downside on respective breadth states can be used to form directional bias for trades and risk on/off regimes for investing.
Example #2 : Broad market reversals
Thrusts signify two things: a historical extreme in breadth and an aggressive move to the opposite direction. Thrusts are valuable clues for exhaustion in broad market trend, potentially leading to a reversal.
Example #3 : Breadth/price divergences
Market breadth and price diverging signify events where most symbols that make up the market are going one way but a few high weight symbols (big tech for SP500) are going the other way. In other words, only a few symbols are moving the market while general interest and intention is to the other direction. Divergences in breadth and price are not ideal for sustainable trend and can be expected to eventually revert to the direction of broad market.
Open interest flow / quantifytools- Overview
Open interest flow detects inflows (positions opening) and outflows (positions closing) using open interest and estimates delta (net buyers/sellers) for the flows. Users are able to choose any open interest source available on Tradingview, by default set to BTCUSDT OI fetched from Binance. Using historical open interest flows, bands depicting typical magnitude of flows are formed for benchmarking intensity of flows. On the inflow side, +1 represents average inflows while +2 represents 2x above average inflows, a level considered an extreme. In a vice versa manner, -1 represents average outflows while -2 represents 2x above average outflows. Extreme inflows indicate aggressive position opening, in other words exuberance. Extreme outflows on the other hand indicate forced exiting of positions, in other words liquidations.
- Concept
Open interest flow is calculated using position of OI source relative to its moving average (by default set to SMA 10), referred to as relative open interest from hereon. When relative OI is positive (open interest is above its moving average), new positions are considered to enter the market. When relative OI is negative (open interest is below its moving average), existing positions are considered to exit the market. Open interest delta (side opening/closing positions, either net buyers/sellers) is calculated using relative price in a similar fashion to relative OI, but using close of viewed symbol as source. Price is considered to be up when relative price is positive, down when relative price is negative. Using relative OI and relative price in tandem, the following assumptions are applied:
Price up, open interest up = longs entering market
Price down, open interest up = shorts entering market
Price down, open interest down = longs exiting market
Price up, open interest down = shorts exiting market
Bands depicting magnitude of open interest flows are calculated using average turning points in relative OI. +1 and -1 represent levels where flows on average turn towards mean rather than continue to increase/decrease. These levels are then multiplied up to +2 and -2, representing two times larger deviations from the normal. When inflows are above 1, positions opening have reached a point where flows historically turn down. Therefore, anything above 1 would be abnormal amount of open interest entering, an extreme stretch being at 2 or above. Same logic applies to outflows, but in a vice versa manner (below -1 abnormal, extreme at -2)
Flow bursts further refine indications of aggressive inflows/outflows by taking into account change in open interest flows. Burst indications are activated when open interest is above its average turning point, coupled with a sufficient increase/decrease in flows simultaneously. Bursts are essentially a filtered version of abnormal flows and therefore a more reliable indication of exuberance/liquidations. Burst sensitivity can be adjusted via input menu, available in 5 settings. 1 sets OI burst requirements to loosest (more signals, more noise) while 5 sets OI burst requirements to strictest (less signals, less noise). Exact criteria applied to bursts can be viewed via input menu tooltip.
- Features
Users can opt for OI source auto-select for CRYPTO/USDT pairs. When auto-select is enabled and another chart is opened, corresponding open interest source is automatically selected as long as requirements mentioned above are met.
Open interest flows can be visualized as chart color, available separately for flow states and flow bursts.
Relative price line and flow guidelines (reminders for flow interpretation) can be enabled via input menu. All colors are customizable.
- Alerts
Available alerts are the following:
- Abnormal long inflows/outflows
- Abnormal short inflows/outflows
- Abnormal inflows/outflows from either side
- Aggressive longs/shorts (flow burst up)
- Liquidated longs/shorts (flow burst down)
- Aggressive or liquidated longs/shorts
- Practical guide
Open interest as a standalone data point does not reveal which side is likely opening/exiting positions and how extreme the participant behavior is. Using the additional data provided by open interest flows, moments of greed and fear can be detected. Smart money does not short into dips and buy into rips. When buyers or sellers have participated in a large move and continue to show interest even when efforts are not rewarded at an already overextended price, participants are asking for trouble.
Similar events can be observed when extreme outflows take place, indicating forced exits such as stop-losses triggering. When enough participants are forced out, price is likely to take the path of least resistance which is to the opposite direction.
Volatility patterns / quantifytools- Overview
Volatility patterns detect various forms of indecisive price action, on a larger scale as a compressed range and on a smaller scale as indecision candles. Indecisive and volatility suppressing price action can be thought of as a spring being pressed down. The more suppression, the more tension is built and eventually released as a spike or series of spikes in volatility. Each volatility pattern is assigned an influence period, during which average and peak relative volatility is recorded and stored to volatility metrics.
- Patterns
The following scenarios are qualified as indecision candles: inside candles, indecision engulfing candles and volatility shifts.
By default, each indecision candle is considered a valid pattern only when another indecision candle has taken place within 3 periods, e.g. prior inside candle + indecision engulfing candle = valid volatility pattern. This measurement is taken to filter noise by looking for multiple hints of pending volatility, rather than just one. Level of tolerated noise can be changed via input menu by using sensitivity setting, by default set to 2.
Sensitivity at 1: Any single indecision candle is considered a valid pattern
Sensitivity at 2: 2 indecision candles within 3 bars is considered a valid pattern
Sensitivity at 3: 2 indecision candles within 2 bars (consecutive) is considered a valid pattern
The following scenarios are qualified as range patterns: series of lower highs/higher lows and series of low volatility pivots.
A pivot is defined by highest/lowest point in price, by default within 2 periods back and 2 periods forward. When 4 pivots with qualities mentioned above are found, a box indicating compressed range will appear. Both required pivots and pivot definition can be adjusted via input menu.
- Influence time and metrics
By default, influence time for each volatility pattern is set to 6 candles, a period for which spike(s) in volatility is expected. For each influence period, average relative volatility (volatility relative to volatility SMA 20) and peak relative volatility is recorded and stored to volatility metrics. All metrics used in calculations are visible in "Data Window "tab. Average and peak volatility during influence period will vary depending on chart, timeframe and chosen settings. Tweaking the settings might result in an improvement and is worth experimenting with.
- Visuals
By default, indecision candles are visualized as yellow lines and range patterns as orange boxes. Influence time periods are respectively visualized as colored candle borders, applied as long as influence time period is active. All colors are fully customizable via input menu.
- Practical guide
Volatility patterns depict moments of equal strength from both bulls and bears. While this equilibrium is in place, price is stagnant and compresses until either side initiates volatility, releasing the built up tension. On top of hedging and playing the volatility using volatility based instruments, some other methods can be applied to take advantage of the somewhat tricky areas of indecision.
Example #1: Trading volatility
Volatility is not a bad thing from a trading perspective, but can actually be fertile ground for executing trade setups. Trading volatility influence periods from higher timeframes on lower timeframes gives greater resolution to work with and opportunities to take advantage of the wild swings created.
Example #2: Finding bias for patterns
Points of confluence where it anyway makes sense to favor one side over the other can be used for establishing bias for indecisive price action as well. At face value, it makes sense to expect bearish reactions at range highs and bullish reactions at range low, for which volatility patterns can provide a catalyst.
Example #3: Betting on initiation direction
Betting on direction of the first volatile move can easily go against you, but if risk/reward is able to compensate for the poor win rate, it's a valid idea to consider and explore.
Bar metrics / quantifytools— Overview
Rather than eyeball evaluating bullishness/bearishness in any given bar, bar metrics allow a quantified approach using three basic fundamental data points: relative close, relative volatility and relative volume. These data points are visualized in a discreet data dashboard form, next to all real-time bars. Each value also has a dot in front, representing color coded extremes in the values.
Relative close represents position of bar's close relative to high and low, high of bar being 100% and low of bar being 0%. Relative close indicates strength of bulls/bears in a given bar, the higher the better for bulls, the lower the better for bears. Relative volatility (bar range, high - low) and relative volume are presented in a form of a multiplier, relative to their respective moving averages (SMA 20). A value of 1x indicates volume/volatility being on par with moving average, 2x indicates volume/volatility being twice as much as moving average and so on. Relative volume and volatility can be used for measuring general market participant interest, the "weight of the bar" as it were.
— Features
Users can gauge past bar metrics using lookback via input menu. Past bars, especially recent ones, are helpful for giving context for current bar metrics. Lookback bars are highlighted on the chart using a yellow box and metrics presented on the data dashboard with lookback symbols:
To inspect bar metric data and its implications, users can highlight bars with specified bracket values for each metric:
When bar highlighter is toggled on and desired bar metric values set, alert for the specified combination can be toggled on via alert menu. Note that bar highlighter must be enabled in order for alerts to function.
— Visuals
Bar metric dots are gradient colored the following way:
Relative volatility & volume
0x -> 1x / Neutral (white) -> Light (yellow)
1x -> 1.7x / Light (yellow) -> Medium (orange)
1.7x -> 2.4x / Medium (orange) -> Heavy (red)
Relative close
0% -> 25% / Heavy bearish (red) -> Light bearish (dark red)
25% -> 45% / Light bearish (dark red) -> Neutral (white)
45% - 55% / Neutral (white)
55% -> 75% / Neutral (white) -> Light bullish (dark green)
75% -> 100% / Light bullish (dark green) -> Heavy bullish (green)
All colors can be adjusted via input menu. Label size, label distance from bar (offset) and text format (regular/stealth) can be adjusted via input menu as well:
— Practical guide
As interpretation of bar metrics is highly contextual, it is especially important to use other means in conjunction with the metrics. Levels, oscillators, moving averages, whatever you have found useful for your process. In short, relative close indicates directional bias and relative volume/volatility indicates "weight" of directional bias.
General interpretation
High relative close, low relative volume/volatility = mildly bullish, bias up/consolidation
High relative close, medium relative volume/volatility = bullish, bias up
High relative close, high relative volume/volatility = exuberantly bullish, bias up/down depending on context
Medium relative close, low relative volume/volatility = noise, no bias
Medium relative close, medium to high relative volume/volatility = indecision, further evidence needed to evaluate bias
Low relative close, low relative volume/volatility = mildly bearish, bias down/consolidation
Low relative close, medium relative volume/volatility = bearish, bias down
Low relative close, high relative volume/volatility = exuberantly bearish, bias down/up depending on context
Nuances & considerations
As to relative close, it's important to note that each bar is a trading range when viewed on a lower timeframe, ES 1W vs. ES 4H:
When relative close is high, bulls were able to push price to range high by the time of close. When relative close is low, bears were able to push price to range low by the time of close. In other words, bulls/bears were able to gain the upper hand over a given trading range, hinting strength for the side that made the final push. When relative close is around middle range (40-60%), it can be said neither side is clearly dominating the range, hinting neutral/indecision bias from a relative close perspective.
As to relative volume/volatility, low values (less than ~0.7x) imply bar has low market participant interest and therefore is likely insignificant, as it is "lacking weight". Values close to or above 1x imply meaningful market participant interest, whereas values well above 1x (greater than ~1.3x) imply exuberance. This exuberance can manifest as initiation (beginning of a trend) or as exhaustion (end of a trend):
Fair value bands / quantifytools— 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)
Smoothing
- SMA
- EMA
- HMA
- RMA
- WMA
- VWMA
- 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:
Individual
- 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
Grouped
- 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.