McNichollBandsLibrary "McNichollBands"
This is a library which only functions to make the McNicholl's Bollinger Bands modifications. It's also my first library, so I'll probably screw some things up.
mcNichollBands(alpha, useLogScale, widthMultiplier)
Calculates the McNicholl's Bollinger Bands modifications.
Parameters:
alpha : The alpha constant to be used on the EMA calculations.
useLogScale : Whether to use the log version of the prices or not.
widthMultiplier : The number that shall be multiplied by the volatility to form the bands.
Returns: A tuple containing the lower band, the center line, and the upper band.
Bands
Rollin' pseudo-Bollinger Bands 5 linear regression curves and new highs/lows mixed together from the basis for this indicator. Using slightly different logic an upper boundary and lower boundary are formed. Then the boundary's are built upon to show price channels within the band using variations of fib levels and the distance between the initial boundary's. Dots plotted show the inverse of the close price relative to either the upper or lower boundary depending on where the close is relative to the center of the band. This shows the market's tendency for symmetry which is useful when looking for reversals etc. If it's too cluttered feel free to turn off some things in the options and keep what you feel is helpful.
Weight Gain 4000 - (Adjustable Volume Weighted MA) - [mutantdog]Short Version:
This is a fairly self-contained system based upon a moving average crossover with several unique features. The most significant of these is the adjustable volume weighting system, allowing for transformations between standard and weighted versions of each included MA. With this feature it is possible to apply partial weighting which can help to improve responsiveness without dramatically altering shape. Included types are SMA, EMA, WMA, RMA, hSMA, DEMA and TEMA. Potentially more will be added in future (check updates below).
In addition there are a selection of alternative 'weighted' inputs, a pair of Bollinger-style deviation bands, a separate price tracker and a bunch of alert presets.
This can be used out-of-the-box or tweaked in multiple ways for unusual results. Default settings are a basic 8/21 EMA cross with partial volume weighting. Dev bands apply to MA2 and are based upon the type and the volume weighting. For standard Bollinger bands use SMA with length 20 and try adding a small amount of volume weighting.
A more detailed breakdown of the functionality follows.
Long Version:
ADJUSTABLE VOLUME WEIGHTING
In principle any moving average should have a volume weighted analogue, the standard VWMA is just an SMA with volume weighting for example. Actually, we can consider the SMA to be a special case where volume is a constant 1 per bar (the value is somewhat arbitrary, the important part is that it's constant). Similar principles apply to the 'elastic' EVWMA which is the volume weighted analogue of an RMA. In any case though, where we have standard and weighted variants it is possible to transform one into the other by gradually increasing or decreasing the weighting, which forms the basis of this system. This is not just a simple multiplier however, that would not work due to the relative proportions being the same when set at any non zero value. In order to create a meaningful transformation we need to use an exponent instead, eg: volume^x , where x is a variable determined in this case by the 'volume' parameter. When x=1, the full volume weighting applies and when x=0, the volume will be reduced to a constant 1. Values in between will result in the respective partial weighting, for example 0.5 will give the square root of the volume.
The obvious question here though is why would you want to do this? To answer that really it is best to actually try it. The advantages that volume weighting can bring to a moving average can sometimes come at the cost of unwanted or erratic behaviour. While it can tend towards much closer price tracking which may be desirable, sometimes it needs moderating especially in markets with lower liquidity. Here the adjustability can be useful, in many cases i have found that adding a small amount of volume weighting to a chosen MA can help to improve its responsiveness without overpowering it. Another possible use case would be to have two instances of the same MA with the same length but different weightings, the extent to which these diverge from each other can be a useful indicator of trend strength. Other uses will become apparent with experimentation and can vary from one market to another.
THE INCLUDED MODES
At the time of publication, there are 7 included moving average types with plans to add more in future. For now here is a brief explainer of what's on offer (continuing to use x as shorthand for the volume parameter), starting with the two most common types.
SMA: As mentioned above this is essentially a standard VWMA, calculated here as sma(source*volume^x,length)/sma(volume^x,length). In this case when x=0 then volume=1 and it reduces to a standard SMA.
RMA: Again mentioned above, this is an EVWMA (where E stands for elastic) with constant weighting. Without going into detail, this method takes the 1/length factor of an RMA and replaces it with volume^x/sum(volume^x,length). In this case again we can see that when x=0 then volume=1 and the original 1/length factor is restored.
EMA: This follows the same principle as the RMA where the standard 2/(length+1) factor is replaced with (2*volume^x)/(sum(volume^x,length)+volume^x). As with an RMA, when x=0 then volume=1 and this reduces back to the standard 2/(length+1).
DEMA: Just a standard Double EMA using the above.
TEMA: Likewise, a standard Triple EMA using the above.
hSMA: This is the same as the SMA except it uses harmonic mean calculations instead of arithmetic. In most cases the differences are negligible however they can become more pronounced when volume weighting is introduced. Furthermore, an argument can be made that harmonic mean calculations are better suited to downtrends or bear markets, in principle at least.
WMA: Probably the most contentious one included. Follows the same basic calculations as for the SMA except uses a WMA instead. Honestly, it makes little sense to combine both linear and volume weighting in this manner, included only for completeness and because it can easily be done. It may be the case that a superior composite could be created with some more complex calculations, in which case i may add that later. For now though this will do.
An additional 'volume filter' option is included, which applies a basic filter to the volume prior to calculation. For types based around the SMA/VWMA system, the volume filter is a WMA-4, for types based around the RMA/EVWMA system the filter is a RMA-2.
As and when i add more they will be listed in the updates at the bottom.
WEIGHTED INPUTS
The ohlc method of source calculations is really a leftover from a time when data was far more limited. Nevertheless it is still the method used in charting and for the most part is sufficient. Often the only important value is 'close' although sometimes 'high' and 'low' can be relevant also. Since we are volume weighting however, it can be useful to incorporate as much information as possible. To that end either 'hlc3' or 'hlcc4' tend to be the best of the defaults (in the case of 24/7 charting like crypto or intraday trading, 'ohlc4' should be avoided as it is effectively the same as a lagging version of 'hlcc4'). There are many other (infinitely many, in fact) possible combinations that can be created, i have included a few here.
The premise is fairly straightforward, by subtracting one value from another, the remaining difference can act as a kind of weight. In a simple case consider 'hl2' as simply the midrange ((high+low)/2), instead of this using 'high+low-open' would give more weight to the value furthest from the open, providing a good estimate of the median. An even better estimate can be achieved by combining that with 'high+low-close' to give the included result 'hl-oc2'. Similarly, 'hlc3' can be considered the basic mean of the three significant values, an included weighted version 'hlc2-o2' combines a sum with subtraction of open to give an estimated mean that may be more accurate. Finally we can apply a similar principle to the close, by subtracting the other values, this one potentially gets more complex so the included 'cc-ohlc4' is really the simplest. The result here is an overbias of the close in relation to the open and the midrange, while in most cases not as useful it can provide an estimate for the next bar assuming that the trend continues.
Of the three i've included, hlc2-o2 is in my opinion the most useful especially in this context, although it is perhaps best considered to be experimental in nature. For that reason, i've kept 'hlcc4' as the default for both MAs.
Additionally included is an 'aux input' which is the standard TV source menu and, where possible, can be set as outputs of other indicators.
THE SYSTEM
This one is fairly obvious and straightforward. It's just a moving average crossover with additional deviation (bollinger) bands. Not a lot to explain here as it should be apparent how it works.
Of the two, MA1 is considered to be the fast and MA2 is considered to be the slow. Both can be set with independent inputs, types and weighting. When MA1 is above, the colour of both is green and when it's below the colour of both is red. An additional gradient based fill is there and can be adjusted along with everything else in the visuals section at the bottom. Default alerts are available for crossover/crossunder conditions along with optional marker plots.
MA2 has the option for deviation bands, these are calculated based upon the MA type used and volume weighted according to the main parameter. In the case of a unweighted SMA being used they will be standard Bollinger bands.
An additional 'source direct' price tracker is included which can be used as the basis for an alert system for price crossings of bands or MAs, while taking advantage of the available weighted inputs. This is displayed as a stepped line on the chart so is also a good way to visualise the differences between input types.
That just about covers it then. The likelihood is that you've used some sort of moving average cross system before and are probably still using one or more. If so, then perhaps the additional functionality here will be of benefit.
Thanks for looking, I welcome any feedack
Adaptive Price ZoneThe Adaptive Price Zone was developed by Lee Leibfarth in 2006, and it attempts to create a band for mean-reversal strategies. It works by taking the double-smoothed average of the volatility from 5 days and adding/subtracting it from the average price of the day (hl2).
If you are planning to use it, remember that it changes throughout the day , so you might want to use an offset. You can also choose to use the true range for the volatility instead of the high and low difference.
Waddah Attar Hidden Levels [Loxx]Waddah Attar Hidden Levels is a dynamic indicator of support of resistance built by Ahmad Waddah Attar
Details
-Uses data from the Daily time frame only
-Used for intraday trading, restricted to timeframes 1 hour and below
-Best Time Frames 15, 30, 60 minutes
-Draws support and resistance lines on chart inside a boundary of fibonacci levels
How to use Waddah Attar Hidden Levels
-Breakout trading indicator
-Buy at the broken red line, or insert pending buy order
-Sell at the broken green line, or insert pending buy order
-Take profit/Stop-loss at blue lines
Bollinger CloudsThis indicator plots Bollinger Bands for your current timeframe (e.g 5 minutes) and also plots the Bollinger Bands for a higher timeframe (15 minutes for 5 minute timeframe). Then the gaps between the current and higher timeframe upper and lower bands is filled to create clouds which can be used as entry zones. Like Bollinger Bands, this indicator shouldn't be solely used for entries, use it in conjunction with other indicators.
Bollinger Band Timeframes
Current / Higher
1 minute / 5 minutes
3 minutes / 10 minutes
5 minutes / 15 minutes
10 minutes / 30 minutes
15 minutes / 1 hour
30 minutes / 2 hours
45 minutes / 1.5 hours
1 hour / 4 hours
2 hours / 8 hours
2.5 hours / 10 hours
4 hours / 1 Day
1 Day / 3 Days
3 Days / 9 Days
5 Days / 2 Weeks
1 Week / 1 Month
CommonMarkupLibrary "CommonMarkup"
Provides functions for chart markup, such as indicating recession bands.
markRecessionBands(showBands, lineY, labelY)
Mark vertical bands and show recession band labels if argument showBands is true. Example "markRecessionBands(bar_index ,3.0"
Parameters:
showBands : - show vertical recession bands when true. Functionally equiv to no op when false
lineY : - y-axis value for line positioning
labelY : - y-axis value for label positioning
@return true - always answers the value of showBands
TL WavesI created this indicator inspired by the miyuki waves indicator by eto_miyuki. In my indicator we have 17 types of moving averages which can be selected in the settings.
It is a trend indicator, the base of the wave is a moving average and 4 Average True Range (ATR) Bands derived from the baseline are formed.
There are also 3 moving averages in a guppy style, these 3 moving averages can also be configured.
The moving average options are:
SMA ---> Simple
WMA ---> Weighted
VWMA ---> Volume Weighted
EMA ---> Exponential
DEMA ---> Double EMA
ALMA ---> Arnaud Legoux
HMA ---> Hull MA
SMMA ---> Smoothed
LSMA ---> Least Squares
KAMA ---> Kaufman Adaptive
TEMA ---> Triple EMA
ZLEMA ---> Zero Lag
FRAMA ---> Fractal Adaptive
VIDYA ---> Variable Index Dynamic Average
JMA ---> Jurik Moving Average
T3 ---> Tillson
TRIMA ---> Triangular
All settings are available for changing inputs.
Root mean squared error range (RMSER)Similarly to Bollinger bands, the RMSER gives a support and resistance areas for the trading price. Unlike bollinger bands, which use standard deviation, this support and resistance is calculated with 2 * the root mean squared error away from the moving average. This works very well with indices, like $SPX, and prices only fall outside the range during black swan events like the 2020 crash.
wnG - VWAP MOD Modified version of VWAP :
Classic VWAP with 6 levels based on the Average True Range to identify the distance and distribution of the prices around the VWAP.
There are 2 calcul methodologies for the bands
- Last 24 Hours Average True Range
- Progressive Average True Range starting from 00:00
As prices tend to move around the VWAP level, favor LONG positions in the GREEN ZONE (and SHORT in the RED ZONE).
How to use it :
Avoid taking long position when price is in the RED ZONE
Avoid taking short position when price is in the GREEN ZONE
==> Adjust the settings depending on your timeframe and asset
ATR BandsIn many strategies, it's quite common to use a scaled ATR to help define a stop-loss, and it's not uncommon to use it for take-profit targets as well. While it's possible to use the built-in ATR indicator and manually calculate the offset value, we felt this wasn't particularly intuitive or efficient, and could lead to the potential for miscalculations. And while there are quite a few indicators that plot ATR bands in some form or another already on TV, we could not find one that actually performed the exact way that we wanted. They all had at least one of the following gaps:
The ATR offset was not configurable (usually hard-coded to be based off the high or low, while we generally prefer to use close)
It would only print a single band (either the upper or lower), which would require the same indicator to be added twice
The ATR scaling factor was either not configurable or only stepped in whole numbers (often time fractional factors like 1.5 yield better results)
To that end, we took to making this enhanced version to meet all of the above requirements. While we were doing so, we decided to take this opportunity to also make some non-functional enhancements as well:
Updated the indicator to the most recent version of Pine
Updated the indicator definition to allow alternate (non-chart) timeframe usage
Made the input types explicitly defined to improve consistency
Updated the inputs with appropriate minimum values and step sizes where appropriate
Separated settings into logical groups
Added helptext to the indicator settings noting usage and common settings values
Explicitly titled the on-chart plots of the ATR bands so that they can more easily be identified and referenced in other indicators/scripts, as well as the Data Window
Food for thought : When looking at some of the behaviors of these ATR bands, you can see that when price first levels out, you can draw a "consolidation zone" from the first peak of the upper ATR band to the first valley of the lower ATR band that price will generally respect. Look for price to break and close outside of that zone. When that happens, price will usually (but not always) make a notable move in that direction, which can be used as either a potential trigger or as an additional confluence with other indicators/price action.
Finally, while we have made what we feel are some noteworthy updates and enhancements to this indicator, and have every intention of continuing to do so as we find worthy opportunities for enhancement, credit is still due to the original author: AlexanderTeaH
Supertrend Channels [LuxAlgo]The Supertrend is one of the most used indicators by traders when it comes to determining whether the market is up-trending or down-trending.
This indicator is displayed as a trailing stop, showing a lower monotonic extremity during up-trends and an upper monotonic extremity during down-trends. Today we propose a channel indicator based on the Supertrend trailing stop using trailing maximas/minimas.
Settings
Length: Atr length used by the Supertrend indicator.
Mult: Multiplicative factor for the Atr used by the Supertrend indicator.
Usage
The ability of the indicator to show an up-trend or down-trend is the same as the Supertrend, with rising channels when an up-trend is detected by the Supertrend and declining channels when a down-trend is detected by the Supertrend.
The look of the channels can remind of the Donchian channels indicator, and as such a similar usage can be appropriate. The extremities can for example be used as supports and resistances.
Additionally, the channel's average can be used to filter out noisy variations in the price while keeping a good distance from the price.
Rudy's BB with MartingaleMy first strategy script that uses Bollinger Bands and Martingale to increase contract size after negative profit.
Mobo BandsThis indicator is the Mobo Bands (Momentum Breakout Bands). These bands are bollinger bands that have an adjusted standard deviation. There are Buy signals when it has momentum breakouts above the bands for moves to the upside and Sell signals when it has momentum breakouts below the bands for moves to the downside. The bands simply suggest that all markets have periods of chop which we all know to be true. While the price is inside the bands it is said to be trendless. Once the breakouts happen you can take trades in the breakout direction. I like to use these to swing trade options on the hourly timeframe but the bands should work on most instruments and timeframes. I like to use it to take swings on SPY on the 1 hour chart for entries and use the Daily chart for trend confirmation.
Weighted Standard Deviation BandsLinearly weighted standard deviations over linearly weighted mean.
The rationale of the study can be deduced from my latest publications where I go deeper into explaining the benefits of linear weighting, but in short, I can remind that by using linear weighting we are able to increase the information gain by communicating the sequential nature of time series to the calculations via linear weighting.
Note, that multiplier parameters can take both negative and positive values resulting in ability to have, for example, 1st and 6th weighted standard deviations higher than the weighted mean.
Despite the modification of the classic standard deviation formula, I assume that mathematical qualities of standard deviation will hold due to the fact we can alternately weight the window itself, and then apply the classic standard deviation over the weighted window. In both cases, the results will be the same.
Aight that was too formal, but your short strangles should be happy
Here is it, for you
Anchored TWAP with StDev Bands [MrShadow]TWAP with:
- Anchoring: Custom, Day, Week, Month, Quarter, Year (custom anchoring can be selected by dragging a vertical line through the chart)
- Standard Devation Bands
- Auto-coloring depending on the trend
Volatility ChannelThis script is based on an idea I have had for bands that react better to crypto volatility. It calculates a Donchian Channel, SMMA-Smoothed True Range, Bollinger Bands (standard deviation), and a Keltner Channel (average true range) and averages the components to construct its bands/envelopes. This way, hopefully band touches are a more reliable indicator of a temporary bottom, and so on. Secondary coloring for strength of trend is given as a gradient based on RSI.
BBands ChannelsBased on the Bollinger Bands system. This shows outer channels to the bollinger bands .
BEAM DCA Strategy MonthlyThis strategy is based on BEAM bands for BTC. The space between the original BEAM bands is broken up into 10 bands representing levels of risk for investing fresh capital.
The strategy will buy bitcoin when the price is in the bottom 5 bands, increasing the amount investmented as the price approaches the 1400 D SMA.
The strategy will limit sell bitcoin when the price is in the top 5 bands, increasing the amount sold as the price approaches the upper BEAM band.
Best used on Daily timeframe and on a chart with history of price data, i.e. INDEX:BTCUSD or BITSTAMP:BTCUSD
To use the strategy:
Set start date
Set day of month to invest
Set the maximum amount to be invested on any given month
Toggle buy/sell orders
Observe the backtest
You can see how the strategy backtests via the information boxes in the bottom right.
There is also functionality to adjust the bands for diminishing returns. Note, this should be used with great skepticism, as the adjustments were made by simple function fitting and not rigorous statistical processes.
That about sums it up! As you can see, even with just a small amount of capital invested at regular intervals can lead to huge realised gains using this version of BEAM bands!
Flat Detect By Bollinger BandsThis simple script indicate the potential flat market zones, calculated based on the Bollinger Bands width.
It's showing the Bollinger Bands in red when the market is detected as flat.
You can adjust the Width Threshold with precision on the inputs settings.
Enjoy :)
Projection Oscillator [CC]The Projection Oscillator was created by Mel Widner (Stocks and Commodities Jul 1995) and this is another hidden gem that is of course a great complementary indicator to my previous Projection Bands . I would recommend to use both on the same chart so you get the full array of information. This indicator tells you where the current price falls between the bands and the higher the oscillator is, the closer the price is to the upper band and vice versa. Now since the price never falls outside of the bands, the indicator is limited from 0 to 100. You will notice that with this indicator it gives even earlier signals than the Projection Bands so a very useful indicator indeed. I have included strong buy and sell signals in addition to normal ones so strong signals are darker in color and normal signals are lighter in color. Buy when the line turns green and sell when it turns red.
Let me know if there are any other indicators or scripts you would like to see me publish!
Projection Bandwidth [CC]The Projection Bandwidth was created by Mel Widner (Stocks and Commodities Jul 1995) and this is another of my series of indicators that I consider undiscovered gems. For those of you who are unaware, the Bandwidth indicator measures the distance between the high and low bands and if you remember from my Projection Bands script, the Projection Bands give pretty accurate early signals of trend reversals and followed fairly closely by a large bulge in the bands. The large bulges in the bands essentially act as the confirmation that the trend reversal is happening and so that brings me to this indicator. This indicator gives signals based on if it has reached a peak or a valley. Both extremes mean that the current trend is ending and I have color coded it based on the buy and sell signals from my Projection Bands indicator. I have included strong buy and sell signals in addition to normal ones so strong signals are darker in color and normal signals are lighter in color. Buy when the line turns green and sell when it turns red.
Let me know if there are any other scripts or indicators you would like to see me publish!
WAP Maverick - (Dual EMA Smoothed VWAP) - [mutantdog]Short Version:
This here is my take on the popular VWAP indicator with several novel features including:
Dual EMA smoothing.
Arithmetic and Harmonic Mean plots.
Custom Anchor feat. Intraday Session Sizes.
2 Pairs of Bands.
Side Input for Connection to other Indicator.
This can be used 'out of the box' as a replacement VWAP, benefitting from smoother transitions and easy-to-use custom alerts.
By design however, this is intended to be a highly customisable alternative with many adjustable parameters and a pseudo-modular input system to connect with another indicator. Well suited for the tweakers around here and those who like to get a little more creative.
I made this primarily for crypto although it should work for other markets. Default settings are best suited to 15m timeframe - the anchor of 1 week is ideal for crypto which often follows a cyclical nature from Monday through Sunday. In 15m, the default ema length of 21 means that the wap comes to match a standard vwap towards the end of Monday. If using higher chart timeframes, i recommend decreasing the ema length to closely match this principle (suggested: for 1h chart, try length = 8; for 4h chart, length = 2 or 3 should suffice).
Note: the use of harmonic mean calculations will cause problems on any data source incorporating both positive and negative values, it may also return unusable results on extremely low-value charts (eg: low-sat coins in /btc pairs).
Long version:
The development of this project was one driven more by experimentation than a specific end-goal, however i have tried to fine-tune everything into a coherent usable end-product. With that in mind then, this walkthrough will follow something of a development chronology as i dissect the various functions.
DUAL-EMA SMOOTHING
At its core this is based upon / adapted from the standard vwap indicator provided by TradingView although I have modified and changed most of it. The first mod is the dual ema smoothing. Rather than simply applying an ema to the output of the standard vwap function, instead i have incorporated the ema in a manner analogous to the way smas are used within a standard vwma. Sticking for now with the arithmetic mean, the basic vwap calculation is simply sum(source * volume) / sum(volume) across the anchored period. In this case i have simply applied an ema to each of the numerator and denominator values resulting in ema(sum(source * volume)) / ema(sum(volume)) with the ema length independent of the anchor. This results in smoother (albeit slower) transitions than the aforementioned post-vwap method. Furthermore in the case when anchor period is equal to current timeframe, the result is a basic volume-weighted ema.
The example below shows a standard vwap (1week anchor) in blue, a 21-ema applied to the vwap in purple and a dual-21-ema smoothed wap in gold. Notably both ema types come to effectively resemble the standard vwap after around 24 hours into the new anchor session but how they behave in the meantime is very different. The dual-ema transitions quite gradually while the post-vwap ema immediately sets about trying to catch up. Incidentally. a similar and slower variation of the dual-ema can be achieved with dual-rma although i have not included it in this indicator, attempted analogues using sma or wma were far less useful however.
STANDARD DEVIATION AND BANDS
With this updated calculation, a corresponding update to the standard deviation is also required. The vwap has its own anchored volume-weighted st.dev but this cannot be used in combination with the ema smoothing so instead it has been recalculated appropriately. There are two pairs of bands with separate multipliers (stepped to 0.1x) and in both cases high and low bands can be activated or deactivated individually. An example usage for this would be to create different upper and lower bands for profit and stoploss targets. Alerts can be set easily for different crossing conditions, more on this later.
Alongside the bands, i have also added the option to shift ('Deviate') the entire indicator up or down according to a multiple of the corrected st.dev value. This has many potential uses, for example if we want to bias our analysis in one direction it may be useful to move the wap in the opposite. Or if the asset is trading within a narrow range and we are waiting on a breakout, we could shift to the desired level and set alerts accordingly. The 'Deviate' parameter applies to the entire indicator including the bands which will remain centred on the main WAP.
CUSTOM (W)ANCHOR
Ever thought about using a vwap with anchor periods smaller than a day? Here you can do just that. I've removed the Earnings/Dividends/Splits options from the basic vwap and added an 'Intraday' option instead. When selected, a custom anchor length can be created as a multiple of minutes (default steps of 60 mins but can input any value from 0 - 1440). While this may not seem at first like a useful feature for anyone except hi-speed scalpers, this actually offers more interesting potential than it appears.
When set to 0 minutes the current timeframe is always used, turning this into the basic volume-weighted ema mentioned earlier. When using other low time frames the anchor can act as a pre-ema filter creating a stepped effect akin to an adaptive MA. Used in combination with the bands, the result is a kind of volume-weighted adaptive exponential bollinger band; if such a thing does not already exist then this is where you create it. Alternatively, by combining two instances you may find potential interesting crosses between an intraday wap and a standard timeframe wap. Below is an example set to intraday with 480 mins, 2x st.dev bands and ema length 21. Included for comparison in purple is a standard 21 ema.
I'm sure there are many potential uses to be found here, so be creative and please share anything you come up with in the comments.
ARITHMETIC AND HARMONIC MEAN CALCULATIONS
The standard vwap uses the arithmetic mean in its calculation. Indeed, most mean calculations tend to be arithmetic: sma being the most widely used example. When volume weighting is involved though this can lead to a slight bias in favour of upward moves over downward. While the effect of this is minor, over longer anchor periods it can become increasingly significant. The harmonic mean, on the other hand, has the opposite effect which results in a value that is always lower than the arithmetic mean. By viewing both arithmetic and harmonic waps together, the extent to which they diverge from each other can be used as a visual reference of how much price has changed during the anchored period.
Furthermore, the harmonic mean may actually be the more appropriate one to use during downtrends or bearish periods, in principle at least. Consider that a short trade is functionally the same as a long trade on the inverse of the pair (eg: selling BTC/USD is the same as buying USD/BTC). With the harmonic mean being an inverse of the arithmetic then, it makes sense to use it instead. To illustrate this below is a snapshot of LUNA/USDT on the left with its inverse 1/(LUNA/USDT) = USDT/LUNA on the right. On both charts is a wap with identical settings, note the resistance on the left and its corresponding support on the right. It should be easy from this to see that the lower harmonic wap on the left corresponds to the upper arithmetic wap on the right. Thus, it would appear that the harmonic mean should be used in a downtrend. In principle, at least...
In reality though, it is not quite so black and white. Rarely are these values exact in their predictions and the sort of range one should allow for inaccuracies will likely be greater than the difference between these two means. Furthermore, the ema smoothing has already introduced some lag and thus additional inaccuracies. Nevertheless, the symmetry warrants its inclusion.
SIDE INPUT & ALERTS
Finally we move on to the pseudo-modular component here. While TradingView allows some interoperability between indicators, it is limited to just one connection. Any attempt to use multiple source inputs will remove this functionality completely. The workaround here is to instead use custom 'string' input menus for additional sources, preserving this function in the sole 'source' input. In this case, since the wap itself is dependant only price and volume, i have repurposed the full 'source' into the second 'side' input. This allows for a separate indicator to interact with this one that can be used for triggering alerts. You could even use another instance of this one (there is a hidden wap:mid plot intended for this use which is the midpoint between both means). Note that deleting a connected indicator may result in the deletion of those connected to it.
Preset alertconditions are available for crossings of the side input above and below the main wap, alongside several customisable alerts with corresponding visual markers based upon selectable conditions. Alerts for band crossings apply only to those that are active and only crossings of the type specified within the 'crosses' subsection of the indicator settings. The included options make it easy to create buy alerts specific to certain bands with sell alerts specific to other bands. The chart below shows two instances with differing anchor periods, both are connected with buy and sell alerts enabled for visible bands.
Okay... So that just about covers it here, i think. As mentioned earlier this is the product of various experiments while i have been learning my way around PineScript. Some of those experiments have been branched off from this in order to not over-clutter it with functions. The pseudo-modular design and the 'side' input are the result of an attempt to create a connective framework across various projects. Even on its own though, this should offer plenty of tweaking potential for anyone who likes to venture away from the usual standards, all the while still retaining its core purpose as a traders tool.
Thanks for checking this out. I look forward to any feedback below.